mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-06 05:38:54 +08:00
SPE-2630: Fixed CSG operations on meshes splittable to parts with inward-facing normals (#13786)
This commit is contained in:
parent
5938fdb495
commit
963f96b31f
@ -46,17 +46,30 @@ void model_to_csgmesh(const ModelObject &mo,
|
||||
*out = std::move(part_begin);
|
||||
++out;
|
||||
|
||||
its_split(vol->mesh().its, SplitOutputFn{[&out, &vol, &trafo](indexed_triangle_set &&its) {
|
||||
// Collect partial meshes and keep outward and inward facing meshes separately.
|
||||
std::vector<indexed_triangle_set> meshes_union;
|
||||
std::vector<indexed_triangle_set> meshes_difference;
|
||||
its_split(vol->mesh().its, SplitOutputFn{[&meshes_union, &meshes_difference](indexed_triangle_set &&its) {
|
||||
if (its.empty())
|
||||
return;
|
||||
if (its_volume(its) >= 0.f)
|
||||
meshes_union.emplace_back(std::move(its));
|
||||
else {
|
||||
its_flip_triangles(its);
|
||||
meshes_difference.emplace_back(std::move(its));
|
||||
}
|
||||
}});
|
||||
|
||||
CSGPart part{std::make_unique<indexed_triangle_set>(std::move(its)),
|
||||
CSGType::Union,
|
||||
(trafo * vol->get_matrix()).cast<float>()};
|
||||
|
||||
// Add the operation for each of the partial mesh (outward-facing normals go first).
|
||||
for (auto* meshes : { &meshes_union, &meshes_difference}) {
|
||||
for (indexed_triangle_set& its : *meshes) {
|
||||
CSGPart part{ std::make_unique<indexed_triangle_set>(std::move(its)),
|
||||
meshes == &meshes_union ? CSGType::Union : CSGType::Difference,
|
||||
(trafo * vol->get_matrix()).cast<float>() };
|
||||
*out = std::move(part);
|
||||
++out;
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
CSGPart part_end{{}};
|
||||
part_end.stack_operation = CSGStackOp::Pop;
|
||||
|
Loading…
x
Reference in New Issue
Block a user