mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Rotate of ModelVolume as transformation component (without modifying the mesh)
This commit is contained in:
parent
edceb80b18
commit
fb6a08cfb0
2 changed files with 37 additions and 8 deletions
|
@ -864,31 +864,33 @@ void ModelObject::scale(const Vec3d &versor)
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelObject::rotate(float angle, const Axis& axis)
|
void ModelObject::rotate(double angle, Axis axis)
|
||||||
{
|
{
|
||||||
for (ModelVolume *v : this->volumes)
|
for (ModelVolume *v : this->volumes)
|
||||||
{
|
{
|
||||||
v->mesh.rotate(angle, axis);
|
v->rotate(angle, axis);
|
||||||
v->m_convex_hull.rotate(angle, axis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
center_around_origin();
|
center_around_origin();
|
||||||
|
|
||||||
|
#if !ENABLE_MODELVOLUME_TRANSFORM
|
||||||
this->origin_translation = Vec3d::Zero();
|
this->origin_translation = Vec3d::Zero();
|
||||||
|
#endif // !ENABLE_MODELVOLUME_TRANSFORM
|
||||||
this->invalidate_bounding_box();
|
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)
|
for (ModelVolume *v : this->volumes)
|
||||||
{
|
{
|
||||||
v->mesh.rotate(angle, axis);
|
v->rotate(angle, axis);
|
||||||
v->m_convex_hull.rotate(angle, axis);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
center_around_origin();
|
center_around_origin();
|
||||||
|
|
||||||
|
#if !ENABLE_MODELVOLUME_TRANSFORM
|
||||||
this->origin_translation = Vec3d::Zero();
|
this->origin_translation = Vec3d::Zero();
|
||||||
|
#endif // !ENABLE_MODELVOLUME_TRANSFORM
|
||||||
this->invalidate_bounding_box();
|
this->invalidate_bounding_box();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,6 +1251,31 @@ void ModelVolume::scale(const Vec3d& scaling_factors)
|
||||||
#endif // ENABLE_MODELVOLUME_TRANSFORM
|
#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
|
#if !ENABLE_MODELVOLUME_TRANSFORM
|
||||||
void ModelInstance::set_rotation(const Vec3d& rotation)
|
void ModelInstance::set_rotation(const Vec3d& rotation)
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,8 +231,8 @@ public:
|
||||||
void scale(const Vec3d &versor);
|
void scale(const Vec3d &versor);
|
||||||
void scale(const double s) { this->scale(Vec3d(s, s, s)); }
|
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 scale(double x, double y, double z) { this->scale(Vec3d(x, y, z)); }
|
||||||
void rotate(float angle, const Axis &axis);
|
void rotate(double angle, Axis axis);
|
||||||
void rotate(float angle, const Vec3d& axis);
|
void rotate(double angle, const Vec3d& axis);
|
||||||
void mirror(const Axis &axis);
|
void mirror(const Axis &axis);
|
||||||
size_t materials_count() const;
|
size_t materials_count() const;
|
||||||
size_t facets_count() const;
|
size_t facets_count() const;
|
||||||
|
@ -319,6 +319,8 @@ public:
|
||||||
void scale(const Vec3d& scaling_factors);
|
void scale(const Vec3d& scaling_factors);
|
||||||
void scale(double x, double y, double z) { scale(Vec3d(x, y, z)); }
|
void scale(double x, double y, double z) { scale(Vec3d(x, y, z)); }
|
||||||
void scale(double s) { scale(Vec3d(s, s, s)); }
|
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();
|
ModelMaterial* assign_unique_material();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue