Volumes always rotate as rigid bodies

This commit is contained in:
enricoturri1966 2023-02-03 09:41:43 +01:00
parent c345f6a02a
commit e3cc3be9ab

View file

@ -1074,12 +1074,11 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);
} }
else { else {
if (transformation_type.local() && transformation_type.absolute()) { if (transformation_type.instance()) {
// ensure that the volume rotates as a rigid body
const Geometry::Transformation& vol_trafo = volume_data.get_volume_transform(); const Geometry::Transformation& vol_trafo = volume_data.get_volume_transform();
Matrix3d vol_rotation, vol_scale; const Transform3d cached_vol_rotation_matrix = vol_trafo.get_rotation_matrix();
vol_trafo.get_matrix().computeRotationScaling(&vol_rotation, &vol_scale); v.set_volume_transformation(vol_trafo.get_matrix() * cached_vol_rotation_matrix.inverse() * rotation_matrix * cached_vol_rotation_matrix);
const Transform3d trafo = vol_trafo.get_rotation_matrix() * rotation_matrix;
v.set_volume_transformation(vol_trafo.get_offset_matrix() * trafo * Transform3d(vol_scale));
} }
else else
transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center); transform_volume_relative(v, volume_data, transformation_type, rotation_matrix, m_cache.dragging_center);