mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-07-17 02:31:49 +08:00
Flatten gizmo now correctly processes both instance and volume transformations
This commit is contained in:
parent
edceb80b18
commit
9442cb99f4
@ -1500,10 +1500,11 @@ void GLCanvas3D::Selection::flattening_rotate(const Vec3d& normal)
|
|||||||
|
|
||||||
for (unsigned int i : m_list)
|
for (unsigned int i : m_list)
|
||||||
{
|
{
|
||||||
Vec3d scaling_factor = m_cache.volumes_data[i].get_volume_scaling_factor();
|
Transform3d wst = m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_volume_scale_matrix();
|
||||||
scaling_factor = Vec3d(1./scaling_factor(0), 1./scaling_factor(1), 1./scaling_factor(2));
|
Vec3d scaling_factor = Vec3d(1./wst(0,0), 1./wst(1,1), 1./wst(2,2));
|
||||||
|
|
||||||
Vec3d transformed_normal = Geometry::assemble_transform(Vec3d::Zero(), m_cache.volumes_data[i].get_volume_rotation(), scaling_factor) * normal;
|
Vec3d rotation = Geometry::extract_euler_angles(m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_volume_rotation_matrix());
|
||||||
|
Vec3d transformed_normal = Geometry::assemble_transform(Vec3d::Zero(), rotation, scaling_factor) * normal;
|
||||||
transformed_normal.normalize();
|
transformed_normal.normalize();
|
||||||
|
|
||||||
Vec3d axis = transformed_normal(2) > 0.999f ? Vec3d(1., 0., 0.) : Vec3d(transformed_normal.cross(Vec3d(0., 0., -1.)));
|
Vec3d axis = transformed_normal(2) > 0.999f ? Vec3d(1., 0., 0.) : Vec3d(transformed_normal.cross(Vec3d(0., 0., -1.)));
|
||||||
@ -1512,8 +1513,8 @@ void GLCanvas3D::Selection::flattening_rotate(const Vec3d& normal)
|
|||||||
Transform3d extra_rotation = Transform3d::Identity();
|
Transform3d extra_rotation = Transform3d::Identity();
|
||||||
extra_rotation.rotate(Eigen::AngleAxisd(acos(-transformed_normal(2)), axis));
|
extra_rotation.rotate(Eigen::AngleAxisd(acos(-transformed_normal(2)), axis));
|
||||||
|
|
||||||
Vec3d new_rotation = Geometry::extract_euler_angles(extra_rotation * m_cache.volumes_data[i].get_volume_rotation_matrix() );
|
Vec3d new_rotation = Geometry::extract_euler_angles(extra_rotation * m_cache.volumes_data[i].get_instance_rotation_matrix() );
|
||||||
(*m_volumes)[i]->set_volume_rotation(new_rotation);
|
(*m_volumes)[i]->set_instance_rotation(new_rotation);
|
||||||
}
|
}
|
||||||
m_bounding_box_dirty = true;
|
m_bounding_box_dirty = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user