Place on bed should now correctly process instance mirror and respect transformations on subvolumes
This commit is contained in:
parent
207c87a3d1
commit
528546b6c8
@ -1784,11 +1784,14 @@ void GLCanvas3D::Selection::flattening_rotate(const Vec3d& normal)
|
||||
|
||||
for (unsigned int i : m_list)
|
||||
{
|
||||
Transform3d wst = m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_volume_scale_matrix();
|
||||
Transform3d wst = m_cache.volumes_data[i].get_instance_scale_matrix();
|
||||
Vec3d scaling_factor = Vec3d(1./wst(0,0), 1./wst(1,1), 1./wst(2,2));
|
||||
|
||||
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;
|
||||
Transform3d wmt = m_cache.volumes_data[i].get_instance_mirror_matrix();
|
||||
Vec3d mirror(wmt(0,0), wmt(1,1), wmt(2,2));
|
||||
|
||||
Vec3d rotation = Geometry::extract_euler_angles(m_cache.volumes_data[i].get_instance_rotation_matrix());
|
||||
Vec3d transformed_normal = Geometry::assemble_transform(Vec3d::Zero(), rotation, scaling_factor, mirror) * normal;
|
||||
transformed_normal.normalize();
|
||||
|
||||
Vec3d axis = transformed_normal(2) > 0.999f ? Vec3d(1., 0., 0.) : Vec3d(transformed_normal.cross(Vec3d(0., 0., -1.)));
|
||||
|
@ -1526,10 +1526,9 @@ void GLGizmoFlatten::update_planes()
|
||||
vol_ch.transform(vol->get_matrix());
|
||||
ch.merge(vol_ch);
|
||||
}
|
||||
|
||||
ch = ch.convex_hull_3d();
|
||||
m_planes.clear();
|
||||
const Transform3d& inst_matrix = m_model_object->instances.front()->get_matrix();
|
||||
const Transform3d& inst_matrix = m_model_object->instances.front()->get_matrix(true);
|
||||
|
||||
// Following constants are used for discarding too small polygons.
|
||||
const float minimal_area = 5.f; // in square mm (world coordinates)
|
||||
@ -1696,10 +1695,6 @@ void GLGizmoFlatten::update_planes()
|
||||
|
||||
// Transform back to 3D (and also back to mesh coordinates)
|
||||
polygon = transform(polygon, inst_matrix.inverse() * m.inverse());
|
||||
|
||||
// make sure the points are in correct order:
|
||||
if ( ((inst_matrix.inverse() * m.inverse()) * Vec3d(0., 0., 1.)).dot(normal) > 0.)
|
||||
std::reverse(polygon.begin(),polygon.end());
|
||||
}
|
||||
|
||||
// We'll sort the planes by area and only keep the 254 largest ones (because of the picking pass limitations):
|
||||
@ -1714,6 +1709,7 @@ void GLGizmoFlatten::update_planes()
|
||||
m_volumes_types.push_back(vol->type());
|
||||
}
|
||||
m_first_instance_scale = m_model_object->instances.front()->get_scaling_factor();
|
||||
m_first_instance_mirror = m_model_object->instances.front()->get_mirror();
|
||||
}
|
||||
|
||||
|
||||
@ -1726,7 +1722,8 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
|
||||
return true;
|
||||
|
||||
// We want to recalculate when the scale changes - some planes could (dis)appear.
|
||||
if (! m_model_object->instances.front()->get_scaling_factor().isApprox(m_first_instance_scale))
|
||||
if (! m_model_object->instances.front()->get_scaling_factor().isApprox(m_first_instance_scale)
|
||||
|| ! m_model_object->instances.front()->get_mirror().isApprox(m_first_instance_mirror))
|
||||
return true;
|
||||
|
||||
for (unsigned int i=0; i < m_model_object->volumes.size(); ++i)
|
||||
|
@ -405,6 +405,7 @@ private:
|
||||
std::vector<Transform3d> m_volumes_matrices;
|
||||
std::vector<ModelVolume::Type> m_volumes_types;
|
||||
Vec3d m_first_instance_scale;
|
||||
Vec3d m_first_instance_mirror;
|
||||
|
||||
std::vector<PlaneData> m_planes;
|
||||
mutable Vec3d m_starting_center;
|
||||
|
Loading…
Reference in New Issue
Block a user