Added Geometry::Transformation class. Use it into ModelInstance, ModelVolume and GLVolume
This commit is contained in:
parent
7f08f460f1
commit
d6d632d4fc
8 changed files with 449 additions and 8 deletions
src/libslic3r
|
@ -1124,6 +1124,7 @@ size_t ModelVolume::split(unsigned int max_extruders)
|
|||
return idx;
|
||||
}
|
||||
|
||||
#if !ENABLE_MODELVOLUME_TRANSFORM
|
||||
void ModelInstance::set_rotation(const Vec3d& rotation)
|
||||
{
|
||||
set_rotation(X, rotation(0));
|
||||
|
@ -1176,6 +1177,7 @@ void ModelInstance::set_mirror(Axis axis, double mirror)
|
|||
m_mirror(axis) = mirror;
|
||||
}
|
||||
#endif // ENABLE_MIRROR
|
||||
#endif // !ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
||||
void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
|
||||
{
|
||||
|
@ -1197,17 +1199,29 @@ BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mes
|
|||
// Scale the bounding box along the three axes.
|
||||
for (unsigned int i = 0; i < 3; ++i)
|
||||
{
|
||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||
if (std::abs(m_transformation.get_scaling_factor((Axis)i)-1.0) > EPSILON)
|
||||
{
|
||||
bbox.min(i) *= m_transformation.get_scaling_factor((Axis)i);
|
||||
bbox.max(i) *= m_transformation.get_scaling_factor((Axis)i);
|
||||
#else
|
||||
if (std::abs(this->m_scaling_factor(i) - 1.0) > EPSILON)
|
||||
{
|
||||
bbox.min(i) *= this->m_scaling_factor(i);
|
||||
bbox.max(i) *= this->m_scaling_factor(i);
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
}
|
||||
}
|
||||
|
||||
// Translate the bounding box.
|
||||
if (! dont_translate) {
|
||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||
bbox.min += m_transformation.get_offset();
|
||||
bbox.max += m_transformation.get_offset();
|
||||
#else
|
||||
bbox.min += this->m_offset;
|
||||
bbox.max += this->m_offset;
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
}
|
||||
}
|
||||
return bbox;
|
||||
|
@ -1225,12 +1239,20 @@ Vec3d ModelInstance::transform_vector(const Vec3d& v, bool dont_translate) const
|
|||
|
||||
void ModelInstance::transform_polygon(Polygon* polygon) const
|
||||
{
|
||||
#if ENABLE_MODELVOLUME_TRANSFORM
|
||||
// CHECK_ME -> Is the following correct or it should take in account all three rotations ?
|
||||
polygon->rotate(m_transformation.get_rotation(Z)); // rotate around polygon origin
|
||||
// CHECK_ME -> Is the following correct ?
|
||||
polygon->scale(m_transformation.get_scaling_factor(X), m_transformation.get_scaling_factor(Y)); // scale around polygon origin
|
||||
#else
|
||||
// CHECK_ME -> Is the following correct or it should take in account all three rotations ?
|
||||
polygon->rotate(this->m_rotation(2)); // rotate around polygon origin
|
||||
// CHECK_ME -> Is the following correct ?
|
||||
polygon->scale(this->m_scaling_factor(0), this->m_scaling_factor(1)); // scale around polygon origin
|
||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
||||
}
|
||||
|
||||
#if !ENABLE_MODELVOLUME_TRANSFORM
|
||||
#if ENABLE_MIRROR
|
||||
Transform3d ModelInstance::world_matrix(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const
|
||||
#else
|
||||
|
@ -1247,5 +1269,6 @@ Transform3d ModelInstance::world_matrix(bool dont_translate, bool dont_rotate, b
|
|||
return Geometry::assemble_transform(translation, rotation, scale);
|
||||
#endif // ENABLE_MIRROR
|
||||
}
|
||||
#endif // !ENABLE_MODELVOLUME_TRANSFORM
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue