mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Cut: Fix modifier transformation
This commit is contained in:
parent
0c7c9d5754
commit
c23c09c453
1 changed files with 10 additions and 2 deletions
|
@ -987,6 +987,8 @@ bool ModelObject::needed_repair() const
|
||||||
|
|
||||||
ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, bool keep_lower, bool rotate_lower)
|
ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, bool keep_lower, bool rotate_lower)
|
||||||
{
|
{
|
||||||
|
if (!keep_upper && !keep_lower) { return {}; }
|
||||||
|
|
||||||
// Clone the object to duplicate instances, materials etc.
|
// Clone the object to duplicate instances, materials etc.
|
||||||
ModelObject* upper = keep_upper ? ModelObject::new_clone(*this) : nullptr;
|
ModelObject* upper = keep_upper ? ModelObject::new_clone(*this) : nullptr;
|
||||||
ModelObject* lower = keep_lower ? ModelObject::new_clone(*this) : nullptr;
|
ModelObject* lower = keep_lower ? ModelObject::new_clone(*this) : nullptr;
|
||||||
|
@ -1024,15 +1026,21 @@ ModelObjectPtrs ModelObject::cut(size_t instance, coordf_t z, bool keep_upper, b
|
||||||
std::vector<BoundingBoxf3> lower_bboxes { instances.size() };
|
std::vector<BoundingBoxf3> lower_bboxes { instances.size() };
|
||||||
|
|
||||||
for (ModelVolume *volume : volumes) {
|
for (ModelVolume *volume : volumes) {
|
||||||
|
const auto volume_matrix = volume->get_matrix();
|
||||||
|
|
||||||
if (! volume->is_model_part()) {
|
if (! volume->is_model_part()) {
|
||||||
// Don't cut modifiers
|
// Modifiers are not cut, but we still need to add the instance transformation
|
||||||
|
// to the modifier volume transformation to preserve their shape properly.
|
||||||
|
|
||||||
|
volume->set_transformation(Geometry::Transformation(instance_matrix * volume_matrix));
|
||||||
|
|
||||||
if (keep_upper) { upper->add_volume(*volume); }
|
if (keep_upper) { upper->add_volume(*volume); }
|
||||||
if (keep_lower) { lower->add_volume(*volume); }
|
if (keep_lower) { lower->add_volume(*volume); }
|
||||||
} else {
|
} else {
|
||||||
TriangleMesh upper_mesh, lower_mesh;
|
TriangleMesh upper_mesh, lower_mesh;
|
||||||
|
|
||||||
// Transform the mesh by the combined transformation matrix
|
// Transform the mesh by the combined transformation matrix
|
||||||
volume->mesh.transform(instance_matrix * volume->get_matrix());
|
volume->mesh.transform(instance_matrix * volume_matrix);
|
||||||
|
|
||||||
// Perform cut
|
// Perform cut
|
||||||
TriangleMeshSlicer tms(&volume->mesh);
|
TriangleMeshSlicer tms(&volume->mesh);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue