diff --git a/src/GUI/Plater/PlaterObject.cpp b/src/GUI/Plater/PlaterObject.cpp index e0d9f598a..e1ca68b6f 100644 --- a/src/GUI/Plater/PlaterObject.cpp +++ b/src/GUI/Plater/PlaterObject.cpp @@ -16,11 +16,6 @@ Slic3r::ExPolygonCollection& PlaterObject::make_thumbnail(std::shared_ptrobjects[obj_idx]->raw_mesh()}; auto model_instance {model->objects[obj_idx]->instances[0]}; - // Apply any x/y rotations and scaling vector if this came from a 3MF object. - mesh.rotate_x(model_instance->x_rotation); - mesh.rotate_y(model_instance->y_rotation); - mesh.scale(model_instance->scaling_vector); - if (mesh.facets_count() <= 5000) { auto area_threshold {scale_(1.0)}; ExPolygons tmp {}; diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 12c2d40dd..2e6ed3b24 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -1074,19 +1074,11 @@ ModelInstance::swap(ModelInstance &other) void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const { - mesh->rotate_x(this->x_rotation); - mesh->rotate_y(this->y_rotation); mesh->rotate_z(this->rotation); // rotate around mesh origin - Pointf3 scale_versor = this->scaling_vector; - scale_versor.scale(this->scaling_factor); - mesh->scale(scale_versor); // scale around mesh origin + mesh->scale(this->scaling_factor); // scale around mesh origin if (!dont_translate) { - float z_trans = 0; - // In 3mf models avoid keeping the objects under z = 0 plane. - if (this->y_rotation || this->x_rotation) - z_trans = -(mesh->stl.stats.min.z); - mesh->translate(this->offset.x, this->offset.y, z_trans); + mesh->translate(this->offset.x, this->offset.y, 0); } } @@ -1096,10 +1088,6 @@ BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mes // rotate around mesh origin double c = cos(this->rotation); double s = sin(this->rotation); - double cx = cos(this->x_rotation); - double sx = sin(this->x_rotation); - double cy = cos(this->y_rotation); - double sy = sin(this->y_rotation); BoundingBoxf3 bbox; for (int i = 0; i < mesh->stl.stats.number_of_facets; ++ i) { const stl_facet &facet = mesh->stl.facet_start[i]; @@ -1107,26 +1095,15 @@ BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh* mes stl_vertex v = facet.vertex[j]; double xold = v.x; double yold = v.y; - double zold = v.z; - // Rotation around x axis. - v.z = float(sx * yold + cx * zold); - yold = v.y = float(cx * yold - sx * zold); - zold = v.z; - // Rotation around y axis. - v.x = float(cy * xold + sy * zold); - v.z = float(-sy * xold + cy * zold); - xold = v.x; // Rotation around z axis. v.x = float(c * xold - s * yold); v.y = float(s * xold + c * yold); - v.x *= float(this->scaling_factor * this->scaling_vector.x); - v.y *= float(this->scaling_factor * this->scaling_vector.y); - v.z *= float(this->scaling_factor * this->scaling_vector.z); + v.x *= float(this->scaling_factor); + v.y *= float(this->scaling_factor); + v.z *= float(this->scaling_factor); if (!dont_translate) { v.x += this->offset.x; v.y += this->offset.y; - if (this->y_rotation || this->x_rotation) - v.z += -(mesh->stl.stats.min.z); } bbox.merge(Pointf3(v.x, v.y, v.z)); } @@ -1139,10 +1116,6 @@ BoundingBoxf3 ModelInstance::transform_bounding_box(const BoundingBoxf3 &bbox, b // rotate around mesh origin double c = cos(this->rotation); double s = sin(this->rotation); - double cx = cos(this->x_rotation); - double sx = sin(this->x_rotation); - double cy = cos(this->y_rotation); - double sy = sin(this->y_rotation); Pointf3 pts[4] = { bbox.min, bbox.max, @@ -1154,21 +1127,10 @@ BoundingBoxf3 ModelInstance::transform_bounding_box(const BoundingBoxf3 &bbox, b Pointf3 &v = pts[i]; double xold = v.x; double yold = v.y; - double zold = v.z; - // Rotation around x axis. - v.z = float(sx * yold + cx * zold); - yold = v.y = float(cx * yold - sx * zold); - zold = v.z; - // Rotation around y axis. - v.x = float(cy * xold + sy * zold); - v.z = float(-sy * xold + cy * zold); - xold = v.x; // Rotation around z axis. v.x = float(c * xold - s * yold); v.y = float(s * xold + c * yold); - v.x *= this->scaling_factor * this->scaling_vector.x; - v.y *= this->scaling_factor * this->scaling_vector.y; - v.z *= this->scaling_factor * this->scaling_vector.z; + v.scale(this->scaling_factor); if (!dont_translate) { v.x += this->offset.x; v.y += this->offset.y; diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index d1e5e4922..5c4800aad 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -531,12 +531,8 @@ class ModelInstance friend class ModelObject; public: double rotation; ///< Rotation around the Z axis, in radians around mesh center point. -// double x_rotation; ///< Rotation around the X axis, in radians around mesh center point. Specific to 3MF format. -// double y_rotation; ///< Rotation around the Y axis, in radians around mesh center point. Specific to 3MF format. double scaling_factor; ///< uniform scaling factor. -// Pointf3 scaling_vector; ///< scaling vector. Specific to 3MF format. Pointf offset; ///< offset in unscaled coordinates. -// double z_translation; ///< translation in z axis. Specific to 3MF format. It's not used anywhere in Slic3r except at writing/reading 3mf. /// Get the owning ModelObject /// \return ModelObject* pointer to the owner ModelObject