Enhanced volumes manipulation - wip

This commit is contained in:
Enrico Turri 2018-11-12 08:54:22 +01:00
parent a72470079d
commit 22dbcbcd9c
5 changed files with 35 additions and 8 deletions

View file

@ -1177,10 +1177,12 @@ void ModelVolume::set_material(t_model_material_id material_id, const ModelMater
}
#if ENABLE_MODELVOLUME_TRANSFORM
void ModelVolume::translate_geometry(const Vec3d& displacement)
void ModelVolume::center_geometry()
{
mesh.translate((float)displacement(0), (float)displacement(1), (float)displacement(2));
m_convex_hull.translate((float)displacement(0), (float)displacement(1), (float)displacement(2));
Vec3d shift = -mesh.bounding_box().center();
mesh.translate((float)shift(0), (float)shift(1), (float)shift(2));
m_convex_hull.translate((float)shift(0), (float)shift(1), (float)shift(2));
translate(-shift);
}
#endif // ENABLE_MODELVOLUME_TRANSFORM

View file

@ -324,7 +324,8 @@ public:
void mirror(Axis axis);
#if ENABLE_MODELVOLUME_TRANSFORM
void translate_geometry(const Vec3d& displacement);
// translates the mesh and the convex hull so that the origin of their vertices is in the center of this volume's bounding box
void center_geometry();
#endif // ENABLE_MODELVOLUME_TRANSFORM
void calculate_convex_hull();