diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index 36403b8de..e86e09463 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -864,31 +864,33 @@ void ModelObject::scale(const Vec3d &versor) this->invalidate_bounding_box(); } -void ModelObject::rotate(float angle, const Axis& axis) +void ModelObject::rotate(double angle, Axis axis) { for (ModelVolume *v : this->volumes) { - v->mesh.rotate(angle, axis); - v->m_convex_hull.rotate(angle, axis); + v->rotate(angle, axis); } center_around_origin(); +#if !ENABLE_MODELVOLUME_TRANSFORM this->origin_translation = Vec3d::Zero(); +#endif // !ENABLE_MODELVOLUME_TRANSFORM this->invalidate_bounding_box(); } -void ModelObject::rotate(float angle, const Vec3d& axis) +void ModelObject::rotate(double angle, const Vec3d& axis) { for (ModelVolume *v : this->volumes) { - v->mesh.rotate(angle, axis); - v->m_convex_hull.rotate(angle, axis); + v->rotate(angle, axis); } center_around_origin(); +#if !ENABLE_MODELVOLUME_TRANSFORM this->origin_translation = Vec3d::Zero(); +#endif // !ENABLE_MODELVOLUME_TRANSFORM this->invalidate_bounding_box(); } @@ -1249,6 +1251,31 @@ void ModelVolume::scale(const Vec3d& scaling_factors) #endif // ENABLE_MODELVOLUME_TRANSFORM } +void ModelVolume::rotate(double angle, Axis axis) +{ +#if ENABLE_MODELVOLUME_TRANSFORM + switch (axis) + { + case X: { rotate(angle, Vec3d::UnitX()); break; } + case Y: { rotate(angle, Vec3d::UnitY()); break; } + case Z: { rotate(angle, Vec3d::UnitZ()); break; } + } +#else + mesh.rotate(angle, axis); + m_convex_hull.rotate(angle, axis); +#endif // ENABLE_MODELVOLUME_TRANSFORM +} + +void ModelVolume::rotate(double angle, const Vec3d& axis) +{ +#if ENABLE_MODELVOLUME_TRANSFORM + m_transformation.set_rotation(m_transformation.get_rotation() + Geometry::extract_euler_angles(Eigen::Quaterniond(Eigen::AngleAxisd(angle, axis)).toRotationMatrix())); +#else + mesh.rotate(angle, axis); + m_convex_hull.rotate(angle, axis); +#endif // ENABLE_MODELVOLUME_TRANSFORM +} + #if !ENABLE_MODELVOLUME_TRANSFORM void ModelInstance::set_rotation(const Vec3d& rotation) { diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index 828dfc817..c420c5ead 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -231,8 +231,8 @@ public: void scale(const Vec3d &versor); void scale(const double s) { this->scale(Vec3d(s, s, s)); } void scale(double x, double y, double z) { this->scale(Vec3d(x, y, z)); } - void rotate(float angle, const Axis &axis); - void rotate(float angle, const Vec3d& axis); + void rotate(double angle, Axis axis); + void rotate(double angle, const Vec3d& axis); void mirror(const Axis &axis); size_t materials_count() const; size_t facets_count() const; @@ -319,6 +319,8 @@ public: void scale(const Vec3d& scaling_factors); void scale(double x, double y, double z) { scale(Vec3d(x, y, z)); } void scale(double s) { scale(Vec3d(s, s, s)); } + void rotate(double angle, Axis axis); + void rotate(double angle, const Vec3d& axis); ModelMaterial* assign_unique_material();