mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-06 05:38:54 +08:00
Align objects imported from AMF to ground. #3785
This commit is contained in:
parent
84a5075fce
commit
bd2117d346
@ -671,6 +671,9 @@ sub load_model_objects {
|
|||||||
# add a default instance and center object around origin
|
# add a default instance and center object around origin
|
||||||
$o->center_around_origin; # also aligns object to Z = 0
|
$o->center_around_origin; # also aligns object to Z = 0
|
||||||
$o->add_instance(offset => $bed_centerf);
|
$o->add_instance(offset => $bed_centerf);
|
||||||
|
} else {
|
||||||
|
# if object has defined positions we still need to ensure it's aligned to Z = 0
|
||||||
|
$o->align_to_ground;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -597,6 +597,20 @@ ModelObject::instance_bounding_box(size_t instance_idx) const
|
|||||||
return bb;
|
return bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ModelObject::align_to_ground()
|
||||||
|
{
|
||||||
|
// calculate the displacements needed to
|
||||||
|
// center this object around the origin
|
||||||
|
BoundingBoxf3 bb;
|
||||||
|
for (const ModelVolume* v : this->volumes)
|
||||||
|
if (!v->modifier)
|
||||||
|
bb.merge(v->mesh.bounding_box());
|
||||||
|
|
||||||
|
this->translate(0, 0, -bb.min.z);
|
||||||
|
this->origin_translation.translate(0, 0, -bb.min.z);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ModelObject::center_around_origin()
|
ModelObject::center_around_origin()
|
||||||
{
|
{
|
||||||
|
@ -149,6 +149,7 @@ class ModelObject
|
|||||||
TriangleMesh raw_mesh() const;
|
TriangleMesh raw_mesh() const;
|
||||||
BoundingBoxf3 raw_bounding_box() const;
|
BoundingBoxf3 raw_bounding_box() const;
|
||||||
BoundingBoxf3 instance_bounding_box(size_t instance_idx) const;
|
BoundingBoxf3 instance_bounding_box(size_t instance_idx) const;
|
||||||
|
void align_to_ground();
|
||||||
void center_around_origin();
|
void center_around_origin();
|
||||||
void translate(const Vectorf3 &vector);
|
void translate(const Vectorf3 &vector);
|
||||||
void translate(coordf_t x, coordf_t y, coordf_t z);
|
void translate(coordf_t x, coordf_t y, coordf_t z);
|
||||||
|
@ -207,6 +207,7 @@ ModelMaterial::attributes()
|
|||||||
bool needed_repair() const;
|
bool needed_repair() const;
|
||||||
int materials_count() const;
|
int materials_count() const;
|
||||||
int facets_count();
|
int facets_count();
|
||||||
|
void align_to_ground();
|
||||||
void center_around_origin();
|
void center_around_origin();
|
||||||
void translate(double x, double y, double z);
|
void translate(double x, double y, double z);
|
||||||
void scale_xyz(Pointf3* versor)
|
void scale_xyz(Pointf3* versor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user