diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 5d5e3911a..f05c4c1b7 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -704,14 +704,14 @@ sub rotate { $self->stop_background_process; if ($axis == Z) { - my $new_angle = $model_instance->rotation + $angle; + my $new_angle = $model_instance->rotation + deg2rad($angle); $_->set_rotation($new_angle) for @{ $model_object->instances }; $object->transform_thumbnail($self->{model}, $obj_idx); } else { # rotation around X and Y needs to be performed on mesh # so we first apply any Z rotation if ($model_instance->rotation != 0) { - $model_object->rotate(deg2rad($model_instance->rotation), Z); + $model_object->rotate($model_instance->rotation, Z); $_->set_rotation(0) for @{ $model_object->instances }; } $model_object->rotate(deg2rad($angle), $axis); @@ -741,7 +741,7 @@ sub flip { # apply Z rotation before flipping if ($model_instance->rotation != 0) { - $model_object->rotate(deg2rad($model_instance->rotation), Z); + $model_object->rotate($model_instance->rotation, Z); $_->set_rotation(0) for @{ $model_object->instances }; } @@ -780,7 +780,7 @@ sub changescale { # apply Z rotation before scaling if ($model_instance->rotation != 0) { - $model_object->rotate(deg2rad($model_instance->rotation), Z); + $model_object->rotate($model_instance->rotation, Z); $_->set_rotation(0) for @{ $model_object->instances }; } @@ -1730,7 +1730,7 @@ sub transform_thumbnail { # the order of these transformations MUST be the same everywhere, including # in Slic3r::Print->add_model_object() my $t = $self->thumbnail->clone; - $t->rotate(deg2rad($model_instance->rotation), Slic3r::Point->new(0,0)); + $t->rotate($model_instance->rotation, Slic3r::Point->new(0,0)); $t->scale($model_instance->scaling_factor); $self->transformed_thumbnail($t); diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index fc9f39b3f..8d98b4d6b 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -485,7 +485,7 @@ ModelObject::center_around_origin() // apply rotation and scaling to vector as well before translating instance, // in order to leave final position unaltered Vectorf3 v = vector.negative(); - v.rotate(Slic3r::Geometry::deg2rad((*i)->rotation), (*i)->offset); + v.rotate((*i)->rotation, (*i)->offset); v.scale((*i)->scaling_factor); (*i)->offset.translate(v.x, v.y); } @@ -523,9 +523,6 @@ ModelObject::scale(const Pointf3 &versor) void ModelObject::rotate(float angle, const Axis &axis) { - // we accept angle in radians but mesh currently uses degrees - angle = Slic3r::Geometry::rad2deg(angle); - for (ModelVolumePtrs::const_iterator v = this->volumes.begin(); v != this->volumes.end(); ++v) { (*v)->mesh.rotate(angle, axis); } diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index edce23d9c..e5683cb57 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -177,7 +177,7 @@ class ModelInstance { friend class ModelObject; public: - double rotation; // around mesh center point + double rotation; // in radians around mesh center point double scaling_factor; Pointf offset; // in unscaled coordinates diff --git a/xs/src/libslic3r/TriangleMesh.cpp b/xs/src/libslic3r/TriangleMesh.cpp index e8c8ef781..822d6ffb3 100644 --- a/xs/src/libslic3r/TriangleMesh.cpp +++ b/xs/src/libslic3r/TriangleMesh.cpp @@ -202,6 +202,9 @@ void TriangleMesh::translate(float x, float y, float z) void TriangleMesh::rotate(float angle, const Axis &axis) { + // admesh uses degrees + angle = Slic3r::Geometry::rad2deg(angle); + if (axis == X) { stl_rotate_x(&(this->stl), angle); } else if (axis == Y) {