mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-09 05:51:50 +08:00
Fix of a regression bug - joint rotation of multiple instances.
The bug was likely introduced with b89e95aea7d2ef665973a812ba03c263cc82a3ba
This commit is contained in:
parent
84f09df03e
commit
036920a43b
@ -522,6 +522,10 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||||||
//FIXME this does not work for absolute rotations (transformation_type.absolute() is true)
|
//FIXME this does not work for absolute rotations (transformation_type.absolute() is true)
|
||||||
rotation.cwiseAbs().maxCoeff(&rot_axis_max);
|
rotation.cwiseAbs().maxCoeff(&rot_axis_max);
|
||||||
|
|
||||||
|
// if ( single instance or single volume )
|
||||||
|
// Rotate around center , if only a single object or volume
|
||||||
|
// transformation_type.set_independent();
|
||||||
|
|
||||||
// For generic rotation, we want to rotate the first volume in selection, and then to synchronize the other volumes with it.
|
// For generic rotation, we want to rotate the first volume in selection, and then to synchronize the other volumes with it.
|
||||||
std::vector<int> object_instance_first(m_model->objects.size(), -1);
|
std::vector<int> object_instance_first(m_model->objects.size(), -1);
|
||||||
auto rotate_instance = [this, &rotation, &object_instance_first, rot_axis_max, transformation_type](GLVolume &volume, int i) {
|
auto rotate_instance = [this, &rotation, &object_instance_first, rot_axis_max, transformation_type](GLVolume &volume, int i) {
|
||||||
@ -542,8 +546,8 @@ void Selection::rotate(const Vec3d& rotation, TransformationType transformation_
|
|||||||
transformation_type.absolute() ? rotation : rotation + m_cache.volumes_data[i].get_instance_rotation();
|
transformation_type.absolute() ? rotation : rotation + m_cache.volumes_data[i].get_instance_rotation();
|
||||||
if (rot_axis_max == 2 && transformation_type.joint()) {
|
if (rot_axis_max == 2 && transformation_type.joint()) {
|
||||||
// Only allow rotation of multiple instances as a single rigid body when rotating around the Z axis.
|
// Only allow rotation of multiple instances as a single rigid body when rotating around the Z axis.
|
||||||
Vec3d offset = Geometry::assemble_transform(Vec3d::Zero(), Vec3d(0.0, 0.0, new_rotation(2) - m_cache.volumes_data[i].get_instance_rotation()(2))) * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center);
|
double z_diff = Geometry::rotation_diff_z(m_cache.volumes_data[i].get_instance_rotation(), new_rotation);
|
||||||
volume.set_instance_offset(m_cache.dragging_center + offset);
|
volume.set_instance_offset(m_cache.dragging_center + Eigen::AngleAxisd(z_diff, Vec3d::UnitZ()) * (m_cache.volumes_data[i].get_instance_position() - m_cache.dragging_center));
|
||||||
}
|
}
|
||||||
volume.set_instance_rotation(new_rotation);
|
volume.set_instance_rotation(new_rotation);
|
||||||
object_instance_first[volume.object_idx()] = i;
|
object_instance_first[volume.object_idx()] = i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user