Merge branch 'master' of https://github.com/prusa3d/Slic3r into objects_centering
This commit is contained in:
commit
7de73bb967
3 changed files with 11 additions and 10 deletions
|
@ -1771,11 +1771,14 @@ void GLCanvas3D::Selection::flattening_rotate(const Vec3d& normal)
|
||||||
|
|
||||||
for (unsigned int i : m_list)
|
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 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());
|
Transform3d wmt = m_cache.volumes_data[i].get_instance_mirror_matrix();
|
||||||
Vec3d transformed_normal = Geometry::assemble_transform(Vec3d::Zero(), rotation, scaling_factor) * normal;
|
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();
|
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.)));
|
||||||
|
|
|
@ -1515,10 +1515,9 @@ void GLGizmoFlatten::update_planes()
|
||||||
vol_ch.transform(vol->get_matrix());
|
vol_ch.transform(vol->get_matrix());
|
||||||
ch.merge(vol_ch);
|
ch.merge(vol_ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
ch = ch.convex_hull_3d();
|
ch = ch.convex_hull_3d();
|
||||||
m_planes.clear();
|
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.
|
// Following constants are used for discarding too small polygons.
|
||||||
const float minimal_area = 5.f; // in square mm (world coordinates)
|
const float minimal_area = 5.f; // in square mm (world coordinates)
|
||||||
|
@ -1685,10 +1684,6 @@ void GLGizmoFlatten::update_planes()
|
||||||
|
|
||||||
// Transform back to 3D (and also back to mesh coordinates)
|
// Transform back to 3D (and also back to mesh coordinates)
|
||||||
polygon = transform(polygon, inst_matrix.inverse() * m.inverse());
|
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):
|
// We'll sort the planes by area and only keep the 254 largest ones (because of the picking pass limitations):
|
||||||
|
@ -1703,6 +1698,7 @@ void GLGizmoFlatten::update_planes()
|
||||||
m_volumes_types.push_back(vol->type());
|
m_volumes_types.push_back(vol->type());
|
||||||
}
|
}
|
||||||
m_first_instance_scale = m_model_object->instances.front()->get_scaling_factor();
|
m_first_instance_scale = m_model_object->instances.front()->get_scaling_factor();
|
||||||
|
m_first_instance_mirror = m_model_object->instances.front()->get_mirror();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1715,7 +1711,8 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// We want to recalculate when the scale changes - some planes could (dis)appear.
|
// 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;
|
return true;
|
||||||
|
|
||||||
for (unsigned int i=0; i < m_model_object->volumes.size(); ++i)
|
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<Transform3d> m_volumes_matrices;
|
||||||
std::vector<ModelVolume::Type> m_volumes_types;
|
std::vector<ModelVolume::Type> m_volumes_types;
|
||||||
Vec3d m_first_instance_scale;
|
Vec3d m_first_instance_scale;
|
||||||
|
Vec3d m_first_instance_mirror;
|
||||||
|
|
||||||
std::vector<PlaneData> m_planes;
|
std::vector<PlaneData> m_planes;
|
||||||
mutable Vec3d m_starting_center;
|
mutable Vec3d m_starting_center;
|
||||||
|
|
Loading…
Add table
Reference in a new issue