mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-05 14:10:45 +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
|
||||
$o->center_around_origin; # also aligns object to Z = 0
|
||||
$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;
|
||||
}
|
||||
|
||||
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
|
||||
ModelObject::center_around_origin()
|
||||
{
|
||||
|
@ -149,6 +149,7 @@ class ModelObject
|
||||
TriangleMesh raw_mesh() const;
|
||||
BoundingBoxf3 raw_bounding_box() const;
|
||||
BoundingBoxf3 instance_bounding_box(size_t instance_idx) const;
|
||||
void align_to_ground();
|
||||
void center_around_origin();
|
||||
void translate(const Vectorf3 &vector);
|
||||
void translate(coordf_t x, coordf_t y, coordf_t z);
|
||||
|
@ -207,6 +207,7 @@ ModelMaterial::attributes()
|
||||
bool needed_repair() const;
|
||||
int materials_count() const;
|
||||
int facets_count();
|
||||
void align_to_ground();
|
||||
void center_around_origin();
|
||||
void translate(double x, double y, double z);
|
||||
void scale_xyz(Pointf3* versor)
|
||||
|
Loading…
x
Reference in New Issue
Block a user