mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Fixed rotation of multivolumes selection - Added local rotation by pressing Alt key while dragging the rotate gizmo
This commit is contained in:
parent
aa22f75829
commit
b961d1011a
3 changed files with 13 additions and 7 deletions
|
@ -1412,7 +1412,7 @@ void GLCanvas3D::Selection::translate(const Vec3d& displacement)
|
||||||
m_bounding_box_dirty = true;
|
m_bounding_box_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Selection::rotate(const Vec3d& rotation)
|
void GLCanvas3D::Selection::rotate(const Vec3d& rotation, bool local)
|
||||||
{
|
{
|
||||||
if (!m_valid)
|
if (!m_valid)
|
||||||
return;
|
return;
|
||||||
|
@ -1437,14 +1437,20 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation)
|
||||||
{
|
{
|
||||||
// extracts rotations from the composed transformation
|
// extracts rotations from the composed transformation
|
||||||
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_instance_rotation_matrix());
|
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_instance_rotation_matrix());
|
||||||
(*m_volumes)[i]->set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
if (!local)
|
||||||
|
(*m_volumes)[i]->set_instance_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||||
|
|
||||||
(*m_volumes)[i]->set_instance_rotation(new_rotation);
|
(*m_volumes)[i]->set_instance_rotation(new_rotation);
|
||||||
}
|
}
|
||||||
else if (m_mode == Volume)
|
else if (m_mode == Volume)
|
||||||
{
|
{
|
||||||
// extracts rotations from the composed transformation
|
// extracts rotations from the composed transformation
|
||||||
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix());
|
Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_volume_rotation_matrix());
|
||||||
(*m_volumes)[i]->set_volume_offset(m * m_cache.volumes_data[i].get_volume_position());
|
if (!local)
|
||||||
|
{
|
||||||
|
Vec3d offset = m * (m_cache.volumes_data[i].get_volume_position() + m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center);
|
||||||
|
(*m_volumes)[i]->set_volume_offset(m_cache.dragging_center - m_cache.volumes_data[i].get_instance_position() + offset);
|
||||||
|
}
|
||||||
(*m_volumes)[i]->set_volume_rotation(new_rotation);
|
(*m_volumes)[i]->set_volume_rotation(new_rotation);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -4042,7 +4048,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
}
|
}
|
||||||
case Gizmos::Rotate:
|
case Gizmos::Rotate:
|
||||||
{
|
{
|
||||||
m_selection.rotate(m_gizmos.get_rotation());
|
m_selection.rotate(m_gizmos.get_rotation(), false);
|
||||||
_on_rotate();
|
_on_rotate();
|
||||||
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
|
@ -4252,7 +4258,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
case Gizmos::Rotate:
|
case Gizmos::Rotate:
|
||||||
{
|
{
|
||||||
// Apply new temporary rotations
|
// Apply new temporary rotations
|
||||||
m_selection.rotate(m_gizmos.get_rotation());
|
m_selection.rotate(m_gizmos.get_rotation(), evt.AltDown());
|
||||||
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
wxGetApp().obj_manipul()->update_settings_value(m_selection);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,7 @@ public:
|
||||||
void start_dragging();
|
void start_dragging();
|
||||||
|
|
||||||
void translate(const Vec3d& displacement);
|
void translate(const Vec3d& displacement);
|
||||||
void rotate(const Vec3d& rotation);
|
void rotate(const Vec3d& rotation, bool local);
|
||||||
void flattening_rotate(const Vec3d& normal);
|
void flattening_rotate(const Vec3d& normal);
|
||||||
void scale(const Vec3d& scale);
|
void scale(const Vec3d& scale);
|
||||||
void mirror(Axis axis);
|
void mirror(Axis axis);
|
||||||
|
|
|
@ -416,7 +416,7 @@ void ObjectManipulation::change_rotation_value(const Vec3d& rotation)
|
||||||
rad_rotation(i) = Geometry::deg2rad(rotation(i));
|
rad_rotation(i) = Geometry::deg2rad(rotation(i));
|
||||||
auto canvas = _3DScene::get_canvas(wxGetApp().canvas3D());
|
auto canvas = _3DScene::get_canvas(wxGetApp().canvas3D());
|
||||||
canvas->get_selection().start_dragging();
|
canvas->get_selection().start_dragging();
|
||||||
canvas->get_selection().rotate(rad_rotation);
|
canvas->get_selection().rotate(rad_rotation, false);
|
||||||
canvas->_on_rotate();
|
canvas->_on_rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue