Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'xs/src/libslic3r/Model.cpp')
-rw-r--r--xs/src/libslic3r/Model.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp
index ec7447352..65743da8d 100644
--- a/xs/src/libslic3r/Model.cpp
+++ b/xs/src/libslic3r/Model.cpp
@@ -1054,6 +1054,29 @@ size_t ModelVolume::split(unsigned int max_extruders)
return idx;
}
+#if ENABLE_MODELINSTANCE_3D_ROTATION
+void ModelInstance::set_rotation(const Vec3d& rotation)
+{
+ set_rotation(X, rotation(0));
+ set_rotation(Y, rotation(1));
+ set_rotation(Z, rotation(2));
+}
+
+void ModelInstance::set_rotation(Axis axis, double rotation)
+{
+ static const double TWO_PI = 2.0 * (double)PI;
+ while (rotation < 0.0)
+ {
+ rotation += TWO_PI;
+ }
+ while (TWO_PI < rotation)
+ {
+ rotation -= TWO_PI;
+ }
+ m_rotation(axis) = rotation;
+}
+#endif // ENABLE_MODELINSTANCE_3D_ROTATION
+
void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const
{
mesh->transform(world_matrix(dont_translate).cast<float>());
@@ -1098,7 +1121,12 @@ Vec3d ModelInstance::transform_vector(const Vec3d& v, bool dont_translate) const
void ModelInstance::transform_polygon(Polygon* polygon) const
{
+#if ENABLE_MODELINSTANCE_3D_ROTATION
+ // 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
+#else
polygon->rotate(this->rotation); // rotate around polygon origin
+#endif // ENABLE_MODELINSTANCE_3D_ROTATION
polygon->scale(this->scaling_factor); // scale around polygon origin
}
@@ -1114,7 +1142,15 @@ Transform3d ModelInstance::world_matrix(bool dont_translate, bool dont_rotate, b
#endif // ENABLE_MODELINSTANCE_3D_OFFSET
if (!dont_rotate)
+#if ENABLE_MODELINSTANCE_3D_ROTATION
+ {
+ m.rotate(Eigen::AngleAxisd(m_rotation(2), Vec3d::UnitZ()));
+ m.rotate(Eigen::AngleAxisd(m_rotation(1), Vec3d::UnitY()));
+ m.rotate(Eigen::AngleAxisd(m_rotation(0), Vec3d::UnitX()));
+ }
+#else
m.rotate(Eigen::AngleAxisd(rotation, Vec3d::UnitZ()));
+#endif // ENABLE_MODELINSTANCE_3D_ROTATION
if (!dont_scale)
m.scale(scaling_factor);