mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
ModelObject::instance_bounding_box() fixed to take in account for volumes' transforms
This commit is contained in:
parent
06a51f9ed3
commit
12ef6913d5
2 changed files with 16 additions and 4 deletions
|
@ -787,7 +787,7 @@ BoundingBoxf3 ModelObject::raw_bounding_box() const
|
||||||
if (v->is_model_part()) {
|
if (v->is_model_part()) {
|
||||||
if (this->instances.empty())
|
if (this->instances.empty())
|
||||||
throw std::invalid_argument("Can't call raw_bounding_box() with no instances");
|
throw std::invalid_argument("Can't call raw_bounding_box() with no instances");
|
||||||
bb.merge(this->instances.front()->transform_mesh_bounding_box(&v->mesh, true));
|
bb.merge(this->instances.front()->transform_mesh_bounding_box(v->mesh, true));
|
||||||
}
|
}
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
@ -796,9 +796,21 @@ BoundingBoxf3 ModelObject::raw_bounding_box() const
|
||||||
BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_translate) const
|
BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_translate) const
|
||||||
{
|
{
|
||||||
BoundingBoxf3 bb;
|
BoundingBoxf3 bb;
|
||||||
|
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||||
|
for (ModelVolume *v : this->volumes)
|
||||||
|
{
|
||||||
|
if (v->is_model_part())
|
||||||
|
{
|
||||||
|
TriangleMesh mesh(v->mesh);
|
||||||
|
mesh.transform(v->get_matrix());
|
||||||
|
bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(mesh, dont_translate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
for (ModelVolume *v : this->volumes)
|
for (ModelVolume *v : this->volumes)
|
||||||
if (v->is_model_part())
|
if (v->is_model_part())
|
||||||
bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(&v->mesh, dont_translate));
|
bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(&v->mesh, dont_translate));
|
||||||
|
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1368,10 +1380,10 @@ void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) cons
|
||||||
mesh->transform(get_matrix(dont_translate));
|
mesh->transform(get_matrix(dont_translate));
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate) const
|
BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh& mesh, bool dont_translate) const
|
||||||
{
|
{
|
||||||
// Rotate around mesh origin.
|
// Rotate around mesh origin.
|
||||||
TriangleMesh copy(*mesh);
|
TriangleMesh copy(mesh);
|
||||||
copy.transform(get_matrix(true, false, true, true));
|
copy.transform(get_matrix(true, false, true, true));
|
||||||
BoundingBoxf3 bbox = copy.bounding_box();
|
BoundingBoxf3 bbox = copy.bounding_box();
|
||||||
|
|
||||||
|
|
|
@ -516,7 +516,7 @@ public:
|
||||||
// To be called on an external mesh
|
// To be called on an external mesh
|
||||||
void transform_mesh(TriangleMesh* mesh, bool dont_translate = false) const;
|
void transform_mesh(TriangleMesh* mesh, bool dont_translate = false) const;
|
||||||
// Calculate a bounding box of a transformed mesh. To be called on an external mesh.
|
// Calculate a bounding box of a transformed mesh. To be called on an external mesh.
|
||||||
BoundingBoxf3 transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate = false) const;
|
BoundingBoxf3 transform_mesh_bounding_box(const TriangleMesh& mesh, bool dont_translate = false) const;
|
||||||
// Transform an external bounding box.
|
// Transform an external bounding box.
|
||||||
BoundingBoxf3 transform_bounding_box(const BoundingBoxf3 &bbox, bool dont_translate = false) const;
|
BoundingBoxf3 transform_bounding_box(const BoundingBoxf3 &bbox, bool dont_translate = false) const;
|
||||||
// Transform an external vector.
|
// Transform an external vector.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue