Tech ENABLE_WORLD_COORDINATE - Fixed translation in local coordinate for single instance selection

Fixed conflicts during rebase with master
This commit is contained in:
enricoturri1966 2021-10-19 10:04:22 +02:00
parent ca5c04bab2
commit f89a902bbb
3 changed files with 9 additions and 72 deletions

View File

@ -95,13 +95,17 @@ void GLGizmoMove3D::on_start_dragging()
#if ENABLE_WORLD_COORDINATE
const BoundingBoxf3 box = get_selection_box();
Vec3d center;
if (wxGetApp().obj_manipul()->get_world_coordinates())
if (wxGetApp().obj_manipul()->get_world_coordinates()) {
center = box.center();
m_starting_drag_position = center + m_grabbers[m_hover_id].center;
}
else {
const Selection& selection = m_parent.get_selection();
center = selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_transformation().get_matrix() * box.center();
const GLVolume& v = *selection.get_volume(*selection.get_volume_idxs().begin());
const Transform3d trafo = Geometry::assemble_transform(Vec3d::Zero(), v.get_instance_rotation());
center = v.get_instance_offset() + trafo * box.center();
m_starting_drag_position = center + trafo * m_grabbers[m_hover_id].center;
}
m_starting_drag_position = center + m_grabbers[m_hover_id].center;
m_starting_box_center = center;
m_starting_box_bottom_center = center;
m_starting_box_bottom_center.z() = box.min.z();
@ -112,8 +116,8 @@ void GLGizmoMove3D::on_start_dragging()
m_starting_box_bottom_center = box.center();
m_starting_box_bottom_center.z() = box.min.z();
#endif // ENABLE_WORLD_COORDINATE
}
}
}
void GLGizmoMove3D::on_stop_dragging()
{

View File

@ -227,79 +227,12 @@ void GLGizmosManager::set_hover_id(int id)
void GLGizmosManager::update_data()
{
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//<<<<<<< HEAD
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (!m_enabled) return;
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//=======
// if (!m_enabled)
// return;
//
// const Selection& selection = m_parent.get_selection();
//
// bool is_wipe_tower = selection.is_wipe_tower();
// enable_grabber(Move, 2, !is_wipe_tower);
// enable_grabber(Rotate, 0, !is_wipe_tower);
// enable_grabber(Rotate, 1, !is_wipe_tower);
//
//#if ENABLE_WORLD_COORDINATE
// bool enable_scale_xyz = !selection.requires_uniform_scale();
//#else
// bool enable_scale_xyz = selection.is_single_full_instance() || selection.is_single_volume() || selection.is_single_modifier();
//#endif // ENABLE_WORLD_COORDINATE
// for (unsigned int i = 0; i < 6; ++i) {
// enable_grabber(Scale, i, enable_scale_xyz);
// }
//
//>>>>>>> 8cf66f52f (Tech ENABLE_WORLD_COORDINATE - Modified method Selection::requires_uniform_scale())
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (m_common_gizmos_data)
m_common_gizmos_data->update(get_current()
? get_current()->get_requirements()
: CommonGizmosDataID(0));
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//<<<<<<< HEAD
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
if (m_current != Undefined) m_gizmos[m_current]->data_changed();
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
//=======
//
// if (selection.is_single_full_instance()) {
// // all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first
// const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
// set_scale(volume->get_instance_scaling_factor());
// set_rotation(Vec3d::Zero());
// ModelObject* model_object = selection.get_model()->objects[selection.get_object_idx()];
// set_flattening_data(model_object);
// set_sla_support_data(model_object);
// set_painter_gizmo_data();
// }
// else if (selection.is_single_volume() || selection.is_single_modifier()) {
// const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin());
// set_scale(volume->get_volume_scaling_factor());
// set_rotation(Vec3d::Zero());
// set_flattening_data(nullptr);
// set_sla_support_data(nullptr);
// set_painter_gizmo_data();
// }
// else if (is_wipe_tower) {
// DynamicPrintConfig& config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
// set_scale(Vec3d::Ones());
// set_rotation(Vec3d(0., 0., (M_PI/180.) * dynamic_cast<const ConfigOptionFloat*>(config.option("wipe_tower_rotation_angle"))->value));
// set_flattening_data(nullptr);
// set_sla_support_data(nullptr);
// set_painter_gizmo_data();
// }
// else {
// set_scale(Vec3d::Ones());
// set_rotation(Vec3d::Zero());
// set_flattening_data(selection.is_from_single_object() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
// set_sla_support_data(selection.is_from_single_instance() ? selection.get_model()->objects[selection.get_object_idx()] : nullptr);
// set_painter_gizmo_data();
// }
//>>>>>>> 8cf66f52f (Tech ENABLE_WORLD_COORDINATE - Modified method Selection::requires_uniform_scale())
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
}
bool GLGizmosManager::is_running() const

View File

@ -721,7 +721,7 @@ void Selection::translate(const Vec3d& displacement, bool local)
if (is_from_fully_selected_instance(i)) {
if (local) {
const VolumeCache& volume_data = m_cache.volumes_data[i];
const Vec3d world_displacement = (volume_data.get_instance_rotation_matrix() * volume_data.get_instance_scale_matrix() * volume_data.get_instance_mirror_matrix()) * displacement;
const Vec3d world_displacement = (volume_data.get_instance_rotation_matrix() * volume_data.get_instance_mirror_matrix()) * displacement;
v.set_instance_offset(volume_data.get_instance_position() + world_displacement);
}
else