From 611d9aa0d814d945e1e60f3b7da66d22908c0c17 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 2 Jan 2019 10:49:13 +0100 Subject: [PATCH] Model's volume transform set as default --- src/libslic3r/Format/3mf.cpp | 45 ------ src/libslic3r/Geometry.cpp | 2 - src/libslic3r/Geometry.hpp | 2 - src/libslic3r/Model.cpp | 184 +--------------------- src/libslic3r/Model.hpp | 71 --------- src/libslic3r/PrintObject.cpp | 4 - src/libslic3r/Technologies.hpp | 4 +- src/slic3r/GUI/3DScene.cpp | 167 -------------------- src/slic3r/GUI/3DScene.hpp | 39 +---- src/slic3r/GUI/GLCanvas3D.cpp | 176 +-------------------- src/slic3r/GUI/GLCanvas3D.hpp | 27 ---- src/slic3r/GUI/GLGizmo.cpp | 23 --- src/slic3r/GUI/GUI_ObjectList.cpp | 12 -- src/slic3r/GUI/GUI_ObjectManipulation.cpp | 32 +--- src/slic3r/GUI/Plater.cpp | 10 -- 15 files changed, 6 insertions(+), 792 deletions(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index f5750162f..3b99ccd82 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -1336,49 +1336,12 @@ namespace Slic3r { void _3MF_Importer::_apply_transform(ModelInstance& instance, const Transform3d& transform) { -#if ENABLE_MODELVOLUME_TRANSFORM Slic3r::Geometry::Transformation t(transform); // invalid scale value, return if (!t.get_scaling_factor().all()) return; instance.set_transformation(t); -#else - // translation - Vec3d offset = transform.matrix().block(0, 3, 3, 1); - - Eigen::Matrix m3x3 = transform.matrix().block(0, 0, 3, 3); - // mirror - // it is impossible to reconstruct the original mirroring factors from a matrix, - // we can only detect if the matrix contains a left handed reference system - // in which case we reorient it back to right handed by mirroring the x axis - Vec3d mirror = Vec3d::Ones(); - if (m3x3.col(0).dot(m3x3.col(1).cross(m3x3.col(2))) < 0.0) - { - mirror(0) = -1.0; - // remove mirror - m3x3.col(0) *= -1.0; - } - - // scale - Vec3d scale(m3x3.col(0).norm(), m3x3.col(1).norm(), m3x3.col(2).norm()); - - // invalid scale value, return - if ((scale(0) == 0.0) || (scale(1) == 0.0) || (scale(2) == 0.0)) - return; - - // remove scale - m3x3.col(0).normalize(); - m3x3.col(1).normalize(); - m3x3.col(2).normalize(); - - Vec3d rotation = Slic3r::Geometry::extract_euler_angles(m3x3); - - instance.set_offset(offset); - instance.set_scaling_factor(scale); - instance.set_rotation(rotation); - instance.set_mirror(mirror); -#endif // ENABLE_MODELVOLUME_TRANSFORM } bool _3MF_Importer::_handle_start_config(const char** attributes, unsigned int num_attributes) @@ -1875,23 +1838,15 @@ namespace Slic3r { vertices_count += stl.stats.shared_vertices; -#if ENABLE_MODELVOLUME_TRANSFORM const Transform3d& matrix = volume->get_matrix(); -#endif // ENABLE_MODELVOLUME_TRANSFORM for (int i = 0; i < stl.stats.shared_vertices; ++i) { stream << " <" << VERTEX_TAG << " "; -#if ENABLE_MODELVOLUME_TRANSFORM Vec3d v = matrix * stl.v_shared[i].cast(); stream << "x=\"" << v(0) << "\" "; stream << "y=\"" << v(1) << "\" "; stream << "z=\"" << v(2) << "\" />\n"; -#else - stream << "x=\"" << stl.v_shared[i](0) << "\" "; - stream << "y=\"" << stl.v_shared[i](1) << "\" "; - stream << "z=\"" << stl.v_shared[i](2) << "\" />\n"; -#endif // ENABLE_MODELVOLUME_TRANSFORM } } diff --git a/src/libslic3r/Geometry.cpp b/src/libslic3r/Geometry.cpp index 256f48e85..317ca4f65 100644 --- a/src/libslic3r/Geometry.cpp +++ b/src/libslic3r/Geometry.cpp @@ -1213,7 +1213,6 @@ Vec3d extract_euler_angles(const Transform3d& transform) return extract_euler_angles(m); } -#if ENABLE_MODELVOLUME_TRANSFORM Transformation::Flags::Flags() : dont_translate(true) , dont_rotate(true) @@ -1383,6 +1382,5 @@ Transformation Transformation::operator * (const Transformation& other) const { return Transformation(get_matrix() * other.get_matrix()); } -#endif // ENABLE_MODELVOLUME_TRANSFORM } } diff --git a/src/libslic3r/Geometry.hpp b/src/libslic3r/Geometry.hpp index c21c3946d..111fc3ca4 100644 --- a/src/libslic3r/Geometry.hpp +++ b/src/libslic3r/Geometry.hpp @@ -197,7 +197,6 @@ Vec3d extract_euler_angles(const Eigen::Matrix& // Warning -> The transform should not contain any shear !!! Vec3d extract_euler_angles(const Transform3d& transform); -#if ENABLE_MODELVOLUME_TRANSFORM class Transformation { struct Flags @@ -256,7 +255,6 @@ public: Transformation operator * (const Transformation& other) const; }; -#endif // ENABLE_MODELVOLUME_TRANSFORM } } diff --git a/src/libslic3r/Model.cpp b/src/libslic3r/Model.cpp index e56a4b6e1..20c4a44b2 100644 --- a/src/libslic3r/Model.cpp +++ b/src/libslic3r/Model.cpp @@ -757,16 +757,11 @@ const BoundingBoxf3& ModelObject::bounding_box() const BoundingBoxf3 raw_bbox; for (const ModelVolume *v : this->volumes) if (v->is_model_part()) -#if ENABLE_MODELVOLUME_TRANSFORM { TriangleMesh m = v->mesh; m.transform(v->get_matrix()); raw_bbox.merge(m.bounding_box()); } -#else - // mesh.bounding_box() returns a cached value. - raw_bbox.merge(v->mesh.bounding_box()); -#endif // ENABLE_MODELVOLUME_TRANSFORM BoundingBoxf3 bb; for (const ModelInstance *i : this->instances) bb.merge(i->transform_bounding_box(raw_bbox)); @@ -797,15 +792,11 @@ TriangleMesh ModelObject::raw_mesh() const TriangleMesh mesh; for (const ModelVolume *v : this->volumes) if (v->is_model_part()) -#if ENABLE_MODELVOLUME_TRANSFORM { TriangleMesh vol_mesh(v->mesh); vol_mesh.transform(v->get_matrix()); mesh.merge(vol_mesh); } -#else - mesh.merge(v->mesh); -#endif // ENABLE_MODELVOLUME_TRANSFORM return mesh; } @@ -814,17 +805,11 @@ TriangleMesh ModelObject::full_raw_mesh() const { TriangleMesh mesh; for (const ModelVolume *v : this->volumes) -#if ENABLE_MODELVOLUME_TRANSFORM { TriangleMesh vol_mesh(v->mesh); vol_mesh.transform(v->get_matrix()); mesh.merge(vol_mesh); } -#else - { - mesh.merge(v->mesh); - } -#endif // ENABLE_MODELVOLUME_TRANSFORM return mesh; } @@ -838,13 +823,9 @@ BoundingBoxf3 ModelObject::raw_bounding_box() const if (this->instances.empty()) throw std::invalid_argument("Can't call raw_bounding_box() with no instances"); -#if ENABLE_MODELVOLUME_TRANSFORM TriangleMesh vol_mesh(v->mesh); vol_mesh.transform(v->get_matrix()); bb.merge(this->instances.front()->transform_mesh_bounding_box(vol_mesh, true)); -#else - bb.merge(this->instances.front()->transform_mesh_bounding_box(v->mesh, true)); -#endif // ENABLE_MODELVOLUME_TRANSFORM } return bb; } @@ -853,7 +834,6 @@ BoundingBoxf3 ModelObject::raw_bounding_box() const BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_translate) const { BoundingBoxf3 bb; -#if ENABLE_MODELVOLUME_TRANSFORM for (ModelVolume *v : this->volumes) { if (v->is_model_part()) @@ -863,11 +843,6 @@ BoundingBoxf3 ModelObject::instance_bounding_box(size_t instance_idx, bool dont_ bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(mesh, dont_translate)); } } -#else - for (ModelVolume *v : this->volumes) - if (v->is_model_part()) - bb.merge(this->instances[instance_idx]->transform_mesh_bounding_box(&v->mesh, dont_translate)); -#endif // ENABLE_MODELVOLUME_TRANSFORM return bb; } @@ -885,15 +860,6 @@ void ModelObject::center_around_origin() this->translate(shift); this->origin_translation += shift; - -#if !ENABLE_MODELVOLUME_TRANSFORM - if (!this->instances.empty()) { - for (ModelInstance *i : this->instances) { - i->set_offset(i->get_offset() - shift); - } - this->invalidate_bounding_box(); - } -#endif // !ENABLE_MODELVOLUME_TRANSFORM } void ModelObject::ensure_on_bed() @@ -933,10 +899,6 @@ void ModelObject::scale(const Vec3d &versor) { v->scale(versor); } -#if !ENABLE_MODELVOLUME_TRANSFORM - // reset origin translation since it doesn't make sense anymore - this->origin_translation = Vec3d::Zero(); -#endif // !ENABLE_MODELVOLUME_TRANSFORM this->invalidate_bounding_box(); } @@ -948,10 +910,6 @@ void ModelObject::rotate(double angle, Axis axis) } center_around_origin(); - -#if !ENABLE_MODELVOLUME_TRANSFORM - this->origin_translation = Vec3d::Zero(); -#endif // !ENABLE_MODELVOLUME_TRANSFORM this->invalidate_bounding_box(); } @@ -963,10 +921,6 @@ void ModelObject::rotate(double angle, const Vec3d& axis) } center_around_origin(); - -#if !ENABLE_MODELVOLUME_TRANSFORM - this->origin_translation = Vec3d::Zero(); -#endif // !ENABLE_MODELVOLUME_TRANSFORM this->invalidate_bounding_box(); } @@ -977,9 +931,6 @@ void ModelObject::mirror(Axis axis) v->mirror(axis); } -#if !ENABLE_MODELVOLUME_TRANSFORM - this->origin_translation = Vec3d::Zero(); -#endif // !ENABLE_MODELVOLUME_TRANSFORM this->invalidate_bounding_box(); } @@ -1179,7 +1130,6 @@ void ModelObject::split(ModelObjectPtrs* new_objects) new_object->instances.reserve(this->instances.size()); for (const ModelInstance *model_instance : this->instances) new_object->add_instance(*model_instance); -#if ENABLE_MODELVOLUME_TRANSFORM ModelVolume* new_vol = new_object->add_volume(*volume, std::move(*mesh)); new_vol->center_geometry(); @@ -1190,9 +1140,6 @@ void ModelObject::split(ModelObjectPtrs* new_objects) } new_vol->set_offset(Vec3d::Zero()); -#else - new_object->add_volume(*volume, std::move(*mesh)); -#endif // ENABLE_MODELVOLUME_TRANSFORM new_objects->emplace_back(new_object); delete mesh; } @@ -1233,7 +1180,6 @@ double ModelObject::get_instance_min_z(size_t instance_idx) const if (!v->is_model_part()) continue; -#if ENABLE_MODELVOLUME_TRANSFORM Transform3d mv = mi * v->get_matrix(); const TriangleMesh& hull = v->get_convex_hull(); for (uint32_t f = 0; f < hull.stl.stats.number_of_facets; ++f) @@ -1243,15 +1189,6 @@ double ModelObject::get_instance_min_z(size_t instance_idx) const min_z = std::min(min_z, Vec3d::UnitZ().dot(mv * facet->vertex[1].cast())); min_z = std::min(min_z, Vec3d::UnitZ().dot(mv * facet->vertex[2].cast())); } -#else - for (uint32_t f = 0; f < v->mesh.stl.stats.number_of_facets; ++f) - { - const stl_facet* facet = v->mesh.stl.facet_start + f; - min_z = std::min(min_z, Vec3d::UnitZ().dot(mi * facet->vertex[0].cast())); - min_z = std::min(min_z, Vec3d::UnitZ().dot(mi * facet->vertex[1].cast())); - min_z = std::min(min_z, Vec3d::UnitZ().dot(mi * facet->vertex[2].cast())); - } -#endif // ENABLE_MODELVOLUME_TRANSFORM } return min_z + inst->get_offset(Z); @@ -1268,11 +1205,7 @@ unsigned int ModelObject::check_instances_print_volume_state(const BoundingBoxf3 unsigned int inside_outside = 0; for (const ModelVolume *vol : this->volumes) if (vol->is_model_part()) { -#if ENABLE_MODELVOLUME_TRANSFORM BoundingBoxf3 bb = vol->get_convex_hull().transformed_bounding_box(model_instance->get_matrix() * vol->get_matrix()); -#else - BoundingBoxf3 bb = vol->get_convex_hull().transformed_bounding_box(model_instance->get_matrix()); -#endif // ENABLE_MODELVOLUME_TRANSFORM if (print_volume.contains(bb)) inside_outside |= INSIDE; else if (print_volume.intersects(bb)) @@ -1364,7 +1297,6 @@ int ModelVolume::extruder_id() const return extruder_id; } -#if ENABLE_MODELVOLUME_TRANSFORM void ModelVolume::center_geometry() { Vec3d shift = -mesh.bounding_box().center(); @@ -1372,7 +1304,6 @@ void ModelVolume::center_geometry() m_convex_hull.translate((float)shift(0), (float)shift(1), (float)shift(2)); translate(-shift); } -#endif // ENABLE_MODELVOLUME_TRANSFORM void ModelVolume::calculate_convex_hull() { @@ -1432,9 +1363,7 @@ size_t ModelVolume::split(unsigned int max_extruders) std::string name = this->name; Model::reset_auto_extruder_id(); -#if ENABLE_MODELVOLUME_TRANSFORM Vec3d offset = this->get_offset(); -#endif // ENABLE_MODELVOLUME_TRANSFORM for (TriangleMesh *mesh : meshptrs) { mesh->repair(); @@ -1448,11 +1377,9 @@ size_t ModelVolume::split(unsigned int max_extruders) else this->object->volumes.insert(this->object->volumes.begin() + (++ivolume), new ModelVolume(object, *this, std::move(*mesh))); -#if ENABLE_MODELVOLUME_TRANSFORM this->object->volumes[ivolume]->set_offset(Vec3d::Zero()); this->object->volumes[ivolume]->center_geometry(); this->object->volumes[ivolume]->translate(offset); -#endif // ENABLE_MODELVOLUME_TRANSFORM this->object->volumes[ivolume]->name = name + "_" + std::to_string(idx + 1); this->object->volumes[ivolume]->config.set_deserialize("extruder", Model::get_auto_extruder_id_as_string(max_extruders)); delete mesh; @@ -1464,52 +1391,31 @@ size_t ModelVolume::split(unsigned int max_extruders) void ModelVolume::translate(const Vec3d& displacement) { -#if ENABLE_MODELVOLUME_TRANSFORM set_offset(get_offset() + displacement); -#else - mesh.translate((float)displacement(0), (float)displacement(1), (float)displacement(2)); - m_convex_hull.translate((float)displacement(0), (float)displacement(1), (float)displacement(2)); -#endif // ENABLE_MODELVOLUME_TRANSFORM } void ModelVolume::scale(const Vec3d& scaling_factors) { -#if ENABLE_MODELVOLUME_TRANSFORM set_scaling_factor(get_scaling_factor().cwiseProduct(scaling_factors)); -#else - mesh.scale(scaling_factors); - m_convex_hull.scale(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 set_rotation(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 } void ModelVolume::mirror(Axis axis) { -#if ENABLE_MODELVOLUME_TRANSFORM Vec3d mirror = get_mirror(); switch (axis) { @@ -1518,10 +1424,6 @@ void ModelVolume::mirror(Axis axis) case Z: { mirror(2) *= -1.0; break; } } set_mirror(mirror); -#else - mesh.mirror(axis); - m_convex_hull.mirror(axis); -#endif // ENABLE_MODELVOLUME_TRANSFORM } void ModelVolume::scale_geometry(const Vec3d& versor) @@ -1530,59 +1432,6 @@ void ModelVolume::scale_geometry(const Vec3d& versor) m_convex_hull.scale(versor); } -#if !ENABLE_MODELVOLUME_TRANSFORM -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; -} - -void ModelInstance::set_scaling_factor(const Vec3d& scaling_factor) -{ - set_scaling_factor(X, scaling_factor(0)); - set_scaling_factor(Y, scaling_factor(1)); - set_scaling_factor(Z, scaling_factor(2)); -} - -void ModelInstance::set_scaling_factor(Axis axis, double scaling_factor) -{ - m_scaling_factor(axis) = std::abs(scaling_factor); -} - -void ModelInstance::set_mirror(const Vec3d& mirror) -{ - set_mirror(X, mirror(0)); - set_mirror(Y, mirror(1)); - set_mirror(Z, mirror(2)); -} - -void ModelInstance::set_mirror(Axis axis, double mirror) -{ - double abs_mirror = std::abs(mirror); - if (abs_mirror == 0.0) - mirror = 1.0; - else if (abs_mirror != 1.0) - mirror /= abs_mirror; - - m_mirror(axis) = mirror; -} -#endif // !ENABLE_MODELVOLUME_TRANSFORM - void ModelInstance::transform_mesh(TriangleMesh* mesh, bool dont_translate) const { mesh->transform(get_matrix(dont_translate)); @@ -1599,29 +1448,17 @@ BoundingBoxf3 ModelInstance::transform_mesh_bounding_box(const TriangleMesh& mes // Scale the bounding box along the three axes. for (unsigned int i = 0; i < 3; ++i) { -#if ENABLE_MODELVOLUME_TRANSFORM if (std::abs(get_scaling_factor((Axis)i)-1.0) > EPSILON) { bbox.min(i) *= get_scaling_factor((Axis)i); bbox.max(i) *= get_scaling_factor((Axis)i); -#else - if (std::abs(this->m_scaling_factor(i) - 1.0) > EPSILON) - { - bbox.min(i) *= this->m_scaling_factor(i); - bbox.max(i) *= this->m_scaling_factor(i); -#endif // ENABLE_MODELVOLUME_TRANSFORM } } // Translate the bounding box. if (! dont_translate) { -#if ENABLE_MODELVOLUME_TRANSFORM bbox.min += get_offset(); bbox.max += get_offset(); -#else - bbox.min += this->m_offset; - bbox.max += this->m_offset; -#endif // ENABLE_MODELVOLUME_TRANSFORM } } return bbox; @@ -1639,30 +1476,12 @@ Vec3d ModelInstance::transform_vector(const Vec3d& v, bool dont_translate) const void ModelInstance::transform_polygon(Polygon* polygon) const { -#if ENABLE_MODELVOLUME_TRANSFORM // CHECK_ME -> Is the following correct or it should take in account all three rotations ? polygon->rotate(get_rotation(Z)); // rotate around polygon origin // CHECK_ME -> Is the following correct ? polygon->scale(get_scaling_factor(X), get_scaling_factor(Y)); // scale around polygon origin -#else - // 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 - // CHECK_ME -> Is the following correct ? - polygon->scale(this->m_scaling_factor(0), this->m_scaling_factor(1)); // scale around polygon origin -#endif // ENABLE_MODELVOLUME_TRANSFORM } -#if !ENABLE_MODELVOLUME_TRANSFORM -Transform3d ModelInstance::get_matrix(bool dont_translate, bool dont_rotate, bool dont_scale, bool dont_mirror) const -{ - Vec3d translation = dont_translate ? Vec3d::Zero() : m_offset; - Vec3d rotation = dont_rotate ? Vec3d::Zero() : m_rotation; - Vec3d scale = dont_scale ? Vec3d::Ones() : m_scaling_factor; - Vec3d mirror = dont_mirror ? Vec3d::Ones() : m_mirror; - return Geometry::assemble_transform(translation, rotation, scale, mirror); -} -#endif // !ENABLE_MODELVOLUME_TRANSFORM - // Test whether the two models contain the same number of ModelObjects with the same set of IDs // ordered in the same order. In that case it is not necessary to kill the background processing. bool model_object_list_equal(const Model &model_old, const Model &model_new) @@ -1706,10 +1525,9 @@ bool model_volume_list_changed(const ModelObject &model_object_old, const ModelO return true; //FIXME test for the content of the mesh! -#if ENABLE_MODELVOLUME_TRANSFORM if (!mv_old.get_matrix().isApprox(mv_new.get_matrix())) return true; -#endif // ENABLE_MODELVOLUME_TRANSFORM + ++i_old; ++ i_new; } diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index c26eb0f7a..e65228d80 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -11,9 +11,7 @@ #include #include #include -#if ENABLE_MODELVOLUME_TRANSFORM #include "Geometry.hpp" -#endif // ENABLE_MODELVOLUME_TRANSFORM namespace Slic3r { @@ -336,10 +334,8 @@ public: void scale_geometry(const Vec3d& versor); -#if ENABLE_MODELVOLUME_TRANSFORM // translates the mesh and the convex hull so that the origin of their vertices is in the center of this volume's bounding box void center_geometry(); -#endif // ENABLE_MODELVOLUME_TRANSFORM void calculate_convex_hull(); const TriangleMesh& get_convex_hull() const; @@ -348,7 +344,6 @@ public: static Type type_from_string(const std::string &s); static std::string type_to_string(const Type t); -#if ENABLE_MODELVOLUME_TRANSFORM const Geometry::Transformation& get_transformation() const { return m_transformation; } void set_transformation(const Geometry::Transformation& transformation) { m_transformation = transformation; } @@ -377,7 +372,6 @@ public: void set_mirror(Axis axis, double mirror) { m_transformation.set_mirror(axis, mirror); } const Transform3d& get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const { return m_transformation.get_matrix(dont_translate, dont_rotate, dont_scale, dont_mirror); } -#endif // ENABLE_MODELVOLUME_TRANSFORM protected: friend class Print; @@ -395,9 +389,7 @@ private: t_model_material_id m_material_id; // The convex hull of this model's mesh. TriangleMesh m_convex_hull; -#if ENABLE_MODELVOLUME_TRANSFORM Geometry::Transformation m_transformation; -#endif // ENABLE_MODELVOLUME_TRANSFORM ModelVolume(ModelObject *object, const TriangleMesh &mesh) : mesh(mesh), m_type(MODEL_PART), object(object) { @@ -407,7 +399,6 @@ private: ModelVolume(ModelObject *object, TriangleMesh &&mesh, TriangleMesh &&convex_hull) : mesh(std::move(mesh)), m_convex_hull(std::move(convex_hull)), m_type(MODEL_PART), object(object) {} -#if ENABLE_MODELVOLUME_TRANSFORM // Copying an existing volume, therefore this volume will get a copy of the ID assigned. ModelVolume(ModelObject *object, const ModelVolume &other) : ModelBase(other), // copy the ID @@ -423,25 +414,6 @@ private: if (mesh.stl.stats.number_of_facets > 1) calculate_convex_hull(); } -#else - // Copying an existing volume, therefore this volume will get a copy of the ID assigned. - ModelVolume(ModelObject *object, const ModelVolume &other) : - ModelBase(other), // copy the ID - name(other.name), mesh(other.mesh), m_convex_hull(other.m_convex_hull), config(other.config), m_type(other.m_type), object(object) - { - if (! other.material_id().empty()) - this->set_material_id(other.material_id()); - } - // Providing a new mesh, therefore this volume will get a new unique ID assigned. - ModelVolume(ModelObject *object, const ModelVolume &other, TriangleMesh &&mesh) : - name(other.name), mesh(std::move(mesh)), config(other.config), m_type(other.m_type), object(object) - { - if (! other.material_id().empty()) - this->set_material_id(other.material_id()); - if (mesh.stl.stats.number_of_facets > 1) - calculate_convex_hull(); - } -#endif // ENABLE_MODELVOLUME_TRANSFORM ModelVolume& operator=(ModelVolume &rhs) = delete; }; @@ -460,14 +432,7 @@ public: }; private: -#if ENABLE_MODELVOLUME_TRANSFORM Geometry::Transformation m_transformation; -#else - Vec3d m_offset; // in unscaled coordinates - Vec3d m_rotation; // Rotation around the three axes, in radians around mesh center point - Vec3d m_scaling_factor; // Scaling factors along the three axes - Vec3d m_mirror; // Mirroring along the three axes -#endif // ENABLE_MODELVOLUME_TRANSFORM public: // flag showing the position of this instance with respect to the print volume (set by Print::validate() using ModelObject::check_instances_print_volume_state()) @@ -475,7 +440,6 @@ public: ModelObject* get_object() const { return this->object; } -#if ENABLE_MODELVOLUME_TRANSFORM const Geometry::Transformation& get_transformation() const { return m_transformation; } void set_transformation(const Geometry::Transformation& transformation) { m_transformation = transformation; } @@ -502,31 +466,6 @@ public: void set_mirror(const Vec3d& mirror) { m_transformation.set_mirror(mirror); } void set_mirror(Axis axis, double mirror) { m_transformation.set_mirror(axis, mirror); } -#else - const Vec3d& get_offset() const { return m_offset; } - double get_offset(Axis axis) const { return m_offset(axis); } - - void set_offset(const Vec3d& offset) { m_offset = offset; } - void set_offset(Axis axis, double offset) { m_offset(axis) = offset; } - - const Vec3d& get_rotation() const { return m_rotation; } - double get_rotation(Axis axis) const { return m_rotation(axis); } - - void set_rotation(const Vec3d& rotation); - void set_rotation(Axis axis, double rotation); - - Vec3d get_scaling_factor() const { return m_scaling_factor; } - double get_scaling_factor(Axis axis) const { return m_scaling_factor(axis); } - - void set_scaling_factor(const Vec3d& scaling_factor); - void set_scaling_factor(Axis axis, double scaling_factor); - - const Vec3d& get_mirror() const { return m_mirror; } - double get_mirror(Axis axis) const { return m_mirror(axis); } - - void set_mirror(const Vec3d& mirror); - void set_mirror(Axis axis, double mirror); -#endif // ENABLE_MODELVOLUME_TRANSFORM // To be called on an external mesh void transform_mesh(TriangleMesh* mesh, bool dont_translate = false) const; @@ -539,11 +478,7 @@ public: // To be called on an external polygon. It does not translate the polygon, only rotates and scales. void transform_polygon(Polygon* polygon) const; -#if ENABLE_MODELVOLUME_TRANSFORM const Transform3d& get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const { return m_transformation.get_matrix(dont_translate, dont_rotate, dont_scale, dont_mirror); } -#else - Transform3d get_matrix(bool dont_translate = false, bool dont_rotate = false, bool dont_scale = false, bool dont_mirror = false) const; -#endif // ENABLE_MODELVOLUME_TRANSFORM bool is_printable() const { return print_volume_state == PVS_Inside; } @@ -559,17 +494,11 @@ private: // Parent object, owning this instance. ModelObject* object; -#if ENABLE_MODELVOLUME_TRANSFORM // Constructor, which assigns a new unique ID. explicit ModelInstance(ModelObject *object) : object(object), print_volume_state(PVS_Inside) {} // Constructor, which assigns a new unique ID. explicit ModelInstance(ModelObject *object, const ModelInstance &other) : m_transformation(other.m_transformation), object(object), print_volume_state(PVS_Inside) {} -#else - explicit ModelInstance(ModelObject *object) : m_offset(Vec3d::Zero()), m_rotation(Vec3d::Zero()), m_scaling_factor(Vec3d::Ones()), m_mirror(Vec3d::Ones()), object(object), print_volume_state(PVS_Inside) {} - explicit ModelInstance(ModelObject *object, const ModelInstance &other) : - m_offset(other.m_offset), m_rotation(other.m_rotation), m_scaling_factor(other.m_scaling_factor), m_mirror(other.m_mirror), object(object), print_volume_state(PVS_Inside) {} -#endif // ENABLE_MODELVOLUME_TRANSFORM ModelInstance() = delete; explicit ModelInstance(ModelInstance &&rhs) = delete; diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 3019233d1..a7214afa3 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1578,15 +1578,11 @@ std::vector PrintObject::_slice_volumes(const std::vector &z, //FIXME better to perform slicing over each volume separately and then to use a Boolean operation to merge them. TriangleMesh mesh; for (const ModelVolume *v : volumes) -#if ENABLE_MODELVOLUME_TRANSFORM { TriangleMesh vol_mesh(v->mesh); vol_mesh.transform(v->get_matrix()); mesh.merge(vol_mesh); } -#else - mesh.merge(v->mesh); -#endif // ENABLE_MODELVOLUME_TRANSFORM if (mesh.stl.stats.number_of_facets > 0) { mesh.transform(m_trafo); // apply XY shift diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 16c610517..a2952a7d3 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -21,10 +21,8 @@ #define DISABLE_INSTANCES_SYNCH (0 && ENABLE_1_42_0) // Modified camera target behavior #define ENABLE_MODIFIED_CAMERA_TARGET (1 && ENABLE_1_42_0) -// Add Geometry::Transformation class and use it into ModelInstance, ModelVolume and GLVolume -#define ENABLE_MODELVOLUME_TRANSFORM (1 && ENABLE_1_42_0) // Keeps objects on bed while scaling them using the scale gizmo -#define ENABLE_ENSURE_ON_BED_WHILE_SCALING (1 && ENABLE_MODELVOLUME_TRANSFORM) +#define ENABLE_ENSURE_ON_BED_WHILE_SCALING (1 && ENABLE_1_42_0) // All rotations made using the rotate gizmo are done with respect to the world reference system #define ENABLE_WORLD_ROTATIONS (1 && ENABLE_1_42_0) // Scene's GUI made using imgui library diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index d0ae03e26..42b025093 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -205,17 +205,7 @@ const float GLVolume::SLA_SUPPORT_COLOR[4] = { 0.75f, 0.75f, 0.75f, 1.0f }; const float GLVolume::SLA_PAD_COLOR[4] = { 0.0f, 0.2f, 0.0f, 1.0f }; GLVolume::GLVolume(float r, float g, float b, float a) -#if ENABLE_MODELVOLUME_TRANSFORM : m_transformed_bounding_box_dirty(true) -#else - : m_offset(Vec3d::Zero()) - , m_rotation(Vec3d::Zero()) - , m_scaling_factor(Vec3d::Ones()) - , m_mirror(Vec3d::Ones()) - , m_world_matrix(Transform3f::Identity()) - , m_world_matrix_dirty(true) - , m_transformed_bounding_box_dirty(true) -#endif // ENABLE_MODELVOLUME_TRANSFORM , m_sla_shift_z(0.0) , m_transformed_convex_hull_bounding_box_dirty(true) , m_convex_hull(nullptr) @@ -300,125 +290,18 @@ void GLVolume::set_color_from_model_volume(const ModelVolume *model_volume) color[3] = model_volume->is_model_part() ? 1.f : 0.5f; } -#if !ENABLE_MODELVOLUME_TRANSFORM -const Vec3d& GLVolume::get_rotation() const -{ - return m_rotation; -} - -void GLVolume::set_rotation(const Vec3d& rotation) -{ - static const double TWO_PI = 2.0 * (double)PI; - - if (m_rotation != rotation) - { - m_rotation = rotation; - for (int i = 0; i < 3; ++i) - { - while (m_rotation(i) < 0.0) - { - m_rotation(i) += TWO_PI; - } - while (TWO_PI < m_rotation(i)) - { - m_rotation(i) -= TWO_PI; - } - } - m_world_matrix_dirty = true; - m_transformed_bounding_box_dirty = true; - m_transformed_convex_hull_bounding_box_dirty = true; - } -} - -const Vec3d& GLVolume::get_offset() const -{ - return m_offset; -} - -void GLVolume::set_offset(const Vec3d& offset) -{ - if (m_offset != offset) - { - m_offset = offset; - m_world_matrix_dirty = true; - m_transformed_bounding_box_dirty = true; - m_transformed_convex_hull_bounding_box_dirty = true; - } -} - -const Vec3d& GLVolume::get_scaling_factor() const -{ - return m_scaling_factor; -} - -void GLVolume::set_scaling_factor(const Vec3d& scaling_factor) -{ - if (m_scaling_factor != scaling_factor) - { - m_scaling_factor = scaling_factor; - m_world_matrix_dirty = true; - m_transformed_bounding_box_dirty = true; - m_transformed_convex_hull_bounding_box_dirty = true; - } -} - -const Vec3d& GLVolume::get_mirror() const -{ - return m_mirror; -} - -double GLVolume::get_mirror(Axis axis) const -{ - return m_mirror(axis); -} - -void GLVolume::set_mirror(const Vec3d& mirror) -{ - if (m_mirror != mirror) - { - m_mirror = mirror; - m_world_matrix_dirty = true; - m_transformed_bounding_box_dirty = true; - m_transformed_convex_hull_bounding_box_dirty = true; - } -} - -void GLVolume::set_mirror(Axis axis, double mirror) -{ - if (m_mirror(axis) != mirror) - { - m_mirror(axis) = mirror; - m_world_matrix_dirty = true; - m_transformed_bounding_box_dirty = true; - m_transformed_convex_hull_bounding_box_dirty = true; - } -} -#endif // !ENABLE_MODELVOLUME_TRANSFORM - void GLVolume::set_convex_hull(const TriangleMesh *convex_hull, bool owned) { m_convex_hull = convex_hull; m_convex_hull_owned = owned; } -#if ENABLE_MODELVOLUME_TRANSFORM Transform3d GLVolume::world_matrix() const { Transform3d m = m_instance_transformation.get_matrix() * m_volume_transformation.get_matrix(); m.translation()(2) += m_sla_shift_z; return m; } -#else -const Transform3f& GLVolume::world_matrix() const -{ - if (m_world_matrix_dirty) - { - m_world_matrix = Geometry::assemble_transform(m_offset, m_rotation, m_scaling_factor, m_mirror).cast(); - m_world_matrix_dirty = false; - } - return m_world_matrix; -} -#endif // ENABLE_MODELVOLUME_TRANSFORM const BoundingBoxf3& GLVolume::transformed_bounding_box() const { @@ -426,11 +309,7 @@ const BoundingBoxf3& GLVolume::transformed_bounding_box() const if (m_transformed_bounding_box_dirty) { -#if ENABLE_MODELVOLUME_TRANSFORM m_transformed_bounding_box = bounding_box.transformed(world_matrix()); -#else - m_transformed_bounding_box = bounding_box.transformed(world_matrix().cast()); -#endif // ENABLE_MODELVOLUME_TRANSFORM m_transformed_bounding_box_dirty = false; } @@ -441,17 +320,10 @@ const BoundingBoxf3& GLVolume::transformed_convex_hull_bounding_box() const { if (m_transformed_convex_hull_bounding_box_dirty) { -#if ENABLE_MODELVOLUME_TRANSFORM if ((m_convex_hull != nullptr) && (m_convex_hull->stl.stats.number_of_facets > 0)) m_transformed_convex_hull_bounding_box = m_convex_hull->transformed_bounding_box(world_matrix()); else m_transformed_convex_hull_bounding_box = bounding_box.transformed(world_matrix()); -#else - if ((m_convex_hull != nullptr) && (m_convex_hull->stl.stats.number_of_facets > 0)) - m_transformed_convex_hull_bounding_box = m_convex_hull->transformed_bounding_box(world_matrix().cast()); - else - m_transformed_convex_hull_bounding_box = bounding_box.transformed(world_matrix().cast()); -#endif // ENABLE_MODELVOLUME_TRANSFORM m_transformed_convex_hull_bounding_box_dirty = false; } @@ -502,11 +374,7 @@ void GLVolume::render() const ::glCullFace(GL_BACK); ::glPushMatrix(); -#if ENABLE_MODELVOLUME_TRANSFORM ::glMultMatrixd(world_matrix().data()); -#else - ::glMultMatrixf(world_matrix().data()); -#endif // ENABLE_MODELVOLUME_TRANSFORM if (this->indexed_vertex_array.indexed()) this->indexed_vertex_array.render(this->tverts_range, this->qverts_range); else @@ -544,11 +412,7 @@ void GLVolume::render_using_layer_height() const glUniform1f(z_cursor_band_width_id, (GLfloat)layer_height_texture_data.edit_band_width); if (world_matrix_id >= 0) -#if ENABLE_MODELVOLUME_TRANSFORM ::glUniformMatrix4fv(world_matrix_id, 1, GL_FALSE, (const GLfloat*)world_matrix().cast().data()); -#else - ::glUniformMatrix4fv(world_matrix_id, 1, GL_FALSE, (const GLfloat*)world_matrix().data()); -#endif // ENABLE_MODELVOLUME_TRANSFORM GLsizei w = (GLsizei)layer_height_texture_width(); GLsizei h = (GLsizei)layer_height_texture_height(); @@ -608,11 +472,7 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c ::glUniform1i(detection_id, shader_outside_printer_detection_enabled ? 1 : 0); if (worldmatrix_id != -1) -#if ENABLE_MODELVOLUME_TRANSFORM ::glUniformMatrix4fv(worldmatrix_id, 1, GL_FALSE, (const GLfloat*)world_matrix().cast().data()); -#else - ::glUniformMatrix4fv(worldmatrix_id, 1, GL_FALSE, (const GLfloat*)world_matrix().data()); -#endif // ENABLE_MODELVOLUME_TRANSFORM render(); @@ -631,11 +491,7 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c ::glUniform1i(detection_id, shader_outside_printer_detection_enabled ? 1 : 0); if (worldmatrix_id != -1) -#if ENABLE_MODELVOLUME_TRANSFORM ::glUniformMatrix4fv(worldmatrix_id, 1, GL_FALSE, (const GLfloat*)world_matrix().cast().data()); -#else - ::glUniformMatrix4fv(worldmatrix_id, 1, GL_FALSE, (const GLfloat*)world_matrix().data()); -#endif // ENABLE_MODELVOLUME_TRANSFORM ::glBindBuffer(GL_ARRAY_BUFFER, indexed_vertex_array.vertices_and_normals_interleaved_VBO_id); ::glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), (const void*)(3 * sizeof(float))); @@ -643,11 +499,7 @@ void GLVolume::render_VBOs(int color_id, int detection_id, int worldmatrix_id) c ::glPushMatrix(); -#if ENABLE_MODELVOLUME_TRANSFORM ::glMultMatrixd(world_matrix().data()); -#else - ::glMultMatrixf(world_matrix().data()); -#endif // ENABLE_MODELVOLUME_TRANSFORM if (n_triangles > 0) { @@ -691,11 +543,7 @@ void GLVolume::render_legacy() const ::glPushMatrix(); -#if ENABLE_MODELVOLUME_TRANSFORM ::glMultMatrixd(world_matrix().data()); -#else - ::glMultMatrixf(world_matrix().data()); -#endif // ENABLE_MODELVOLUME_TRANSFORM if (n_triangles > 0) ::glDrawElements(GL_TRIANGLES, n_triangles, GL_UNSIGNED_INT, indexed_vertex_array.triangle_indices.data() + tverts_range.first); @@ -780,11 +628,7 @@ int GLVolumeCollection::load_object_volume( const ModelVolume *model_volume = model_object->volumes[volume_idx]; const int extruder_id = model_volume->extruder_id(); const ModelInstance *instance = model_object->instances[instance_idx]; -#if ENABLE_MODELVOLUME_TRANSFORM const TriangleMesh& mesh = model_volume->mesh; -#else - TriangleMesh mesh = model_volume->mesh; -#endif // ENABLE_MODELVOLUME_TRANSFORM float color[4]; memcpy(color, colors[((color_by == "volume") ? volume_idx : obj_idx) % 4], sizeof(float) * 3); /* if (model_volume->is_support_blocker()) { @@ -822,15 +666,8 @@ int GLVolumeCollection::load_object_volume( } v.is_modifier = ! model_volume->is_model_part(); v.shader_outside_printer_detection_enabled = model_volume->is_model_part(); -#if ENABLE_MODELVOLUME_TRANSFORM v.set_instance_transformation(instance->get_transformation()); v.set_volume_transformation(model_volume->get_transformation()); -#else - v.set_offset(instance->get_offset()); - v.set_rotation(instance->get_rotation()); - v.set_scaling_factor(instance->get_scaling_factor()); - v.set_mirror(instance->get_mirror()); -#endif // ENABLE_MODELVOLUME_TRANSFORM return int(this->volumes.size() - 1); } @@ -941,11 +778,7 @@ int GLVolumeCollection::load_wipe_tower_preview( else v.indexed_vertex_array.load_mesh_flat_shading(mesh); -#if ENABLE_MODELVOLUME_TRANSFORM v.set_volume_offset(Vec3d(pos_x, pos_y, 0.0)); -#else - v.set_offset(Vec3d(pos_x, pos_y, 0.0)); -#endif // ENABLE_MODELVOLUME_TRANSFORM // finalize_geometry() clears the vertex arrays, therefore the bounding box has to be computed before finalize_geometry(). v.bounding_box = v.indexed_vertex_array.bounding_box(); diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index b5ae5b965..38996dc04 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -257,23 +257,9 @@ public: ~GLVolume(); private: -#if ENABLE_MODELVOLUME_TRANSFORM Geometry::Transformation m_instance_transformation; Geometry::Transformation m_volume_transformation; -#else - // Offset of the volume to be rendered. - Vec3d m_offset; - // Rotation around three axes of the volume to be rendered. - Vec3d m_rotation; - // Scale factor along the three axes of the volume to be rendered. - Vec3d m_scaling_factor; - // Mirroring along the three axes of the volume to be rendered. - Vec3d m_mirror; - // World matrix of the volume to be rendered. - mutable Transform3f m_world_matrix; - // Whether or not is needed to recalculate the world matrix. - mutable bool m_world_matrix_dirty; -#endif // ENABLE_MODELVOLUME_TRANSFORM + // Shift in z required by sla supports+pad double m_sla_shift_z; // Bounding box of this volume, in unscaled coordinates. @@ -357,7 +343,6 @@ public: // set color according to model volume void set_color_from_model_volume(const ModelVolume *model_volume); -#if ENABLE_MODELVOLUME_TRANSFORM const Geometry::Transformation& get_instance_transformation() const { return m_instance_transformation; } void set_instance_transformation(const Geometry::Transformation& transformation) { m_instance_transformation = transformation; set_bounding_boxes_as_dirty(); } @@ -411,21 +396,6 @@ public: void set_volume_mirror(const Vec3d& mirror) { m_volume_transformation.set_mirror(mirror); set_bounding_boxes_as_dirty(); } void set_volume_mirror(Axis axis, double mirror) { m_volume_transformation.set_mirror(axis, mirror); set_bounding_boxes_as_dirty(); } -#else - const Vec3d& get_rotation() const; - void set_rotation(const Vec3d& rotation); - - const Vec3d& get_scaling_factor() const; - void set_scaling_factor(const Vec3d& scaling_factor); - - const Vec3d& get_mirror() const; - double get_mirror(Axis axis) const; - void set_mirror(const Vec3d& mirror); - void set_mirror(Axis axis, double mirror); - - const Vec3d& get_offset() const; - void set_offset(const Vec3d& offset); -#endif // ENABLE_MODELVOLUME_TRANSFORM double get_sla_shift_z() const { return m_sla_shift_z; } void set_sla_shift_z(double z) { m_sla_shift_z = z; } @@ -436,11 +406,8 @@ public: int volume_idx() const { return this->composite_id.volume_id; } int instance_idx() const { return this->composite_id.instance_id; } -#if ENABLE_MODELVOLUME_TRANSFORM Transform3d world_matrix() const; -#else - const Transform3f& world_matrix() const; -#endif // ENABLE_MODELVOLUME_TRANSFORM + const BoundingBoxf3& transformed_bounding_box() const; const BoundingBoxf3& transformed_convex_hull_bounding_box() const; @@ -491,9 +458,7 @@ public: void reset_layer_height_texture_data() { layer_height_texture_data.reset(); } -#if ENABLE_MODELVOLUME_TRANSFORM void set_bounding_boxes_as_dirty() { m_transformed_bounding_box_dirty = true; m_transformed_convex_hull_bounding_box_dirty = true; } -#endif // ENABLE_MODELVOLUME_TRANSFORM }; typedef std::vector GLVolumePtrs; diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0529eeb72..f5615f0d6 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1104,7 +1104,6 @@ bool GLCanvas3D::Mouse::is_start_position_3D_defined() const return (drag.start_position_3D != Drag::Invalid_3D_Point); } -#if ENABLE_MODELVOLUME_TRANSFORM GLCanvas3D::Selection::VolumeCache::TransformCache::TransformCache() : position(Vec3d::Zero()) , rotation(Vec3d::Zero()) @@ -1132,25 +1131,6 @@ GLCanvas3D::Selection::VolumeCache::VolumeCache(const Geometry::Transformation& , m_instance(instance_transform) { } -#else -GLCanvas3D::Selection::VolumeCache::VolumeCache() - : m_position(Vec3d::Zero()) - , m_rotation(Vec3d::Zero()) - , m_scaling_factor(Vec3d::Ones()) -{ - m_rotation_matrix = Transform3d::Identity(); - m_scale_matrix = Transform3d::Identity(); -} - -GLCanvas3D::Selection::VolumeCache::VolumeCache(const Vec3d& position, const Vec3d& rotation, const Vec3d& scaling_factor) - : m_position(position) - , m_rotation(rotation) - , m_scaling_factor(scaling_factor) -{ - m_rotation_matrix = Geometry::assemble_transform(Vec3d::Zero(), m_rotation); - m_scale_matrix = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), m_scaling_factor); -} -#endif // ENABLE_MODELVOLUME_TRANSFORM GLCanvas3D::Selection::Selection() : m_volumes(nullptr) @@ -1241,13 +1221,6 @@ void GLCanvas3D::Selection::add(unsigned int volume_idx, bool as_single_selectio _add_instance(volume->object_idx(), volume->instance_idx()); break; } -#if !ENABLE_MODELVOLUME_TRANSFORM - case Object: - { - _add_object(volume->object_idx()); - break; - } -#endif // !ENABLE_MODELVOLUME_TRANSFORM } _update_type(); @@ -1273,13 +1246,6 @@ void GLCanvas3D::Selection::remove(unsigned int volume_idx) _remove_instance(volume->object_idx(), volume->instance_idx()); break; } -#if !ENABLE_MODELVOLUME_TRANSFORM - case Object: - { - _remove_object(volume->object_idx()); - break; - } -#endif // !ENABLE_MODELVOLUME_TRANSFORM } _update_type(); @@ -1552,7 +1518,6 @@ void GLCanvas3D::Selection::translate(const Vec3d& displacement, bool local) for (unsigned int i : m_list) { -#if ENABLE_MODELVOLUME_TRANSFORM if ((m_mode == Volume) || (*m_volumes)[i]->is_wipe_tower) { if (local) @@ -1565,9 +1530,6 @@ void GLCanvas3D::Selection::translate(const Vec3d& displacement, bool local) } else if (m_mode == Instance) (*m_volumes)[i]->set_instance_offset(m_cache.volumes_data[i].get_instance_position() + displacement); -#else - (*m_volumes)[i]->set_offset(m_cache.volumes_data[i].get_position() + displacement); -#endif // ENABLE_MODELVOLUME_TRANSFORM } #if !DISABLE_INSTANCES_SYNCH @@ -1600,13 +1562,8 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation, bool local) } } #else -#if ENABLE_MODELVOLUME_TRANSFORM (*m_volumes)[i]->set_instance_rotation(rotation); -#else - (*m_volumes)[i]->set_rotation(rotation); -#endif // ENABLE_MODELVOLUME_TRANSFORM #endif // ENABLE_WORLD_ROTATIONS -#if ENABLE_MODELVOLUME_TRANSFORM else if (is_single_volume() || is_single_modifier()) #if ENABLE_WORLD_ROTATIONS { @@ -1623,11 +1580,9 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation, bool local) #else (*m_volumes)[i]->set_volume_rotation(rotation); #endif // ENABLE_WORLD_ROTATIONS -#endif // ENABLE_MODELVOLUME_TRANSFORM else { Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), rotation); -#if ENABLE_MODELVOLUME_TRANSFORM if (m_mode == Instance) { // extracts rotations from the composed transformation @@ -1648,12 +1603,6 @@ void GLCanvas3D::Selection::rotate(const Vec3d& rotation, bool local) } (*m_volumes)[i]->set_volume_rotation(new_rotation); } -#else - // extracts rotations from the composed transformation - Vec3d new_rotation = Geometry::extract_euler_angles(m * m_cache.volumes_data[i].get_rotation_matrix()); - (*m_volumes)[i]->set_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_position() - m_cache.dragging_center)); - (*m_volumes)[i]->set_rotation(new_rotation); -#endif // ENABLE_MODELVOLUME_TRANSFORM } } @@ -1678,7 +1627,6 @@ void GLCanvas3D::Selection::flattening_rotate(const Vec3d& normal) for (unsigned int i : m_list) { -#if ENABLE_MODELVOLUME_TRANSFORM Transform3d wst = m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_volume_scale_matrix(); Vec3d scaling_factor = Vec3d(1./wst(0,0), 1./wst(1,1), 1./wst(2,2)); @@ -1694,23 +1642,6 @@ void GLCanvas3D::Selection::flattening_rotate(const Vec3d& normal) Vec3d new_rotation = Geometry::extract_euler_angles(extra_rotation * m_cache.volumes_data[i].get_instance_rotation_matrix() ); (*m_volumes)[i]->set_instance_rotation(new_rotation); -#else - Transform3d wst = m_cache.volumes_data[i].get_scale_matrix() * m_cache.volumes_data[i].get_scale_matrix(); - Vec3d scaling_factor = Vec3d(1. / wst(0, 0), 1. / wst(1, 1), 1. / wst(2, 2)); - - Vec3d rotation = Geometry::extract_euler_angles(m_cache.volumes_data[i].get_rotation_matrix() * m_cache.volumes_data[i].get_rotation_matrix()); - Vec3d transformed_normal = Geometry::assemble_transform(Vec3d::Zero(), rotation, scaling_factor) * normal; - transformed_normal.normalize(); - - Vec3d axis = transformed_normal(2) > 0.999f ? Vec3d(1., 0., 0.) : Vec3d(transformed_normal.cross(Vec3d(0., 0., -1.))); - axis.normalize(); - - Transform3d extra_rotation = Transform3d::Identity(); - extra_rotation.rotate(Eigen::AngleAxisd(acos(-transformed_normal(2)), axis)); - - Vec3d new_rotation = Geometry::extract_euler_angles(extra_rotation * m_cache.volumes_data[i].get_rotation_matrix()); - (*m_volumes)[i]->set_rotation(new_rotation); -#endif // ENABLE_MODELVOLUME_TRANSFORM } #if !DISABLE_INSTANCES_SYNCH @@ -1729,19 +1660,12 @@ void GLCanvas3D::Selection::scale(const Vec3d& scale, bool local) for (unsigned int i : m_list) { if (is_single_full_instance()) -#if ENABLE_MODELVOLUME_TRANSFORM (*m_volumes)[i]->set_instance_scaling_factor(scale); -#else - (*m_volumes)[i]->set_scaling_factor(scale); -#endif // ENABLE_MODELVOLUME_TRANSFORM -#if ENABLE_MODELVOLUME_TRANSFORM else if (is_single_volume() || is_single_modifier()) (*m_volumes)[i]->set_volume_scaling_factor(scale); -#endif // ENABLE_MODELVOLUME_TRANSFORM else { Transform3d m = Geometry::assemble_transform(Vec3d::Zero(), Vec3d::Zero(), scale); -#if ENABLE_MODELVOLUME_TRANSFORM if (m_mode == Instance) { Eigen::Matrix new_matrix = (m * m_cache.volumes_data[i].get_instance_scale_matrix()).matrix().block(0, 0, 3, 3); @@ -1764,13 +1688,6 @@ void GLCanvas3D::Selection::scale(const Vec3d& scale, bool local) } (*m_volumes)[i]->set_volume_scaling_factor(new_scale); } -#else - Eigen::Matrix new_matrix = (m * m_cache.volumes_data[i].get_scale_matrix()).matrix().block(0, 0, 3, 3); - // extracts scaling factors from the composed transformation - Vec3d new_scale(new_matrix.col(0).norm(), new_matrix.col(1).norm(), new_matrix.col(2).norm()); - (*m_volumes)[i]->set_offset(m_cache.dragging_center + m * (m_cache.volumes_data[i].get_position() - m_cache.dragging_center)); - (*m_volumes)[i]->set_scaling_factor(new_scale); -#endif // ENABLE_MODELVOLUME_TRANSFORM } } @@ -1798,13 +1715,9 @@ void GLCanvas3D::Selection::mirror(Axis axis) for (unsigned int i : m_list) { if (single_full_instance) -#if ENABLE_MODELVOLUME_TRANSFORM (*m_volumes)[i]->set_instance_mirror(axis, -(*m_volumes)[i]->get_instance_mirror(axis)); else if (m_mode == Volume) (*m_volumes)[i]->set_volume_mirror(axis, -(*m_volumes)[i]->get_volume_mirror(axis)); -#else - (*m_volumes)[i]->set_mirror(axis, -(*m_volumes)[i]->get_mirror(axis)); -#endif // ENABLE_MODELVOLUME_TRANSFORM } #if !DISABLE_INSTANCES_SYNCH @@ -1826,11 +1739,7 @@ void GLCanvas3D::Selection::translate(unsigned int object_idx, const Vec3d& disp { GLVolume* v = (*m_volumes)[i]; if (v->object_idx() == object_idx) -#if ENABLE_MODELVOLUME_TRANSFORM v->set_instance_offset(v->get_instance_offset() + displacement); -#else - v->set_offset(v->get_offset() + displacement); -#endif // ENABLE_MODELVOLUME_TRANSFORM } std::set done; // prevent processing volumes twice @@ -1858,11 +1767,7 @@ void GLCanvas3D::Selection::translate(unsigned int object_idx, const Vec3d& disp if (v->object_idx() != object_idx) continue; -#if ENABLE_MODELVOLUME_TRANSFORM v->set_instance_offset(v->get_instance_offset() + displacement); -#else - v->set_offset(v->get_offset() + displacement); -#endif // ENABLE_MODELVOLUME_TRANSFORM done.insert(j); } } @@ -1879,11 +1784,7 @@ void GLCanvas3D::Selection::translate(unsigned int object_idx, unsigned int inst { GLVolume* v = (*m_volumes)[i]; if ((v->object_idx() == object_idx) && (v->instance_idx() == instance_idx)) -#if ENABLE_MODELVOLUME_TRANSFORM v->set_instance_offset(v->get_instance_offset() + displacement); -#else - v->set_offset(v->get_offset() + displacement); -#endif // ENABLE_MODELVOLUME_TRANSFORM } std::set done; // prevent processing volumes twice @@ -1911,11 +1812,7 @@ void GLCanvas3D::Selection::translate(unsigned int object_idx, unsigned int inst if ((v->object_idx() != object_idx) || (v->instance_idx() != instance_idx)) continue; -#if ENABLE_MODELVOLUME_TRANSFORM v->set_instance_offset(v->get_instance_offset() + displacement); -#else - v->set_offset(v->get_offset() + displacement); -#endif // ENABLE_MODELVOLUME_TRANSFORM done.insert(j); } } @@ -2366,11 +2263,7 @@ void GLCanvas3D::Selection::_set_caches() for (unsigned int i : m_list) { const GLVolume* v = (*m_volumes)[i]; -#if ENABLE_MODELVOLUME_TRANSFORM m_cache.volumes_data.emplace(i, VolumeCache(v->get_volume_transformation(), v->get_instance_transformation())); -#else - m_cache.volumes_data.emplace(i, VolumeCache(v->get_offset(), v->get_rotation(), v->get_scaling_factor())); -#endif // ENABLE_MODELVOLUME_TRANSFORM } m_cache.dragging_center = get_bounding_box().center(); } @@ -2641,15 +2534,9 @@ void GLCanvas3D::Selection::_synchronize_unselected_instances() continue; int instance_idx = volume->instance_idx(); -#if ENABLE_MODELVOLUME_TRANSFORM const Vec3d& rotation = volume->get_instance_rotation(); const Vec3d& scaling_factor = volume->get_instance_scaling_factor(); const Vec3d& mirror = volume->get_instance_mirror(); -#else - const Vec3d& rotation = volume->get_rotation(); - const Vec3d& scaling_factor = volume->get_scaling_factor(); - const Vec3d& mirror = volume->get_mirror(); -#endif // ENABLE_MODELVOLUME_TRANSFORM // Process unselected instances. for (unsigned int j = 0; j < (unsigned int)m_volumes->size(); ++j) @@ -2664,15 +2551,9 @@ void GLCanvas3D::Selection::_synchronize_unselected_instances() if ((v->object_idx() != object_idx) || (v->instance_idx() == instance_idx)) continue; -#if ENABLE_MODELVOLUME_TRANSFORM v->set_instance_rotation(Vec3d(rotation(0), rotation(1), v->get_instance_rotation()(2))); v->set_instance_scaling_factor(scaling_factor); v->set_instance_mirror(mirror); -#else - v->set_rotation(Vec3d(rotation(0), rotation(1), v->get_rotation()(2))); - v->set_scaling_factor(scaling_factor); - v->set_mirror(mirror); -#endif // ENABLE_MODELVOLUME_TRANSFORM done.insert(j); } @@ -2689,17 +2570,10 @@ void GLCanvas3D::Selection::_synchronize_unselected_volumes() continue; int volume_idx = volume->volume_idx(); -#if ENABLE_MODELVOLUME_TRANSFORM const Vec3d& offset = volume->get_volume_offset(); const Vec3d& rotation = volume->get_volume_rotation(); const Vec3d& scaling_factor = volume->get_volume_scaling_factor(); const Vec3d& mirror = volume->get_volume_mirror(); -#else - const Vec3d& offset = volume->get_offset(); - const Vec3d& rotation = volume->get_rotation(); - const Vec3d& scaling_factor = volume->get_scaling_factor(); - const Vec3d& mirror = volume->get_mirror(); -#endif // ENABLE_MODELVOLUME_TRANSFORM // Process unselected volumes. for (unsigned int j = 0; j < (unsigned int)m_volumes->size(); ++j) @@ -2711,17 +2585,10 @@ void GLCanvas3D::Selection::_synchronize_unselected_volumes() if ((v->object_idx() != object_idx) || (v->volume_idx() != volume_idx)) continue; -#if ENABLE_MODELVOLUME_TRANSFORM v->set_volume_offset(offset); v->set_volume_rotation(rotation); v->set_volume_scaling_factor(scaling_factor); v->set_volume_mirror(mirror); -#else - v->set_offset(offset); - v->set_rotation(Vec3d(rotation)); - v->set_scaling_factor(scaling_factor); - v->set_mirror(mirror); -#endif // ENABLE_MODELVOLUME_TRANSFORM } } } @@ -5571,7 +5438,6 @@ void GLCanvas3D::do_move() ModelObject* model_object = m_model->objects[object_idx]; if (model_object != nullptr) { -#if ENABLE_MODELVOLUME_TRANSFORM if (selection_mode == Selection::Instance) { model_object->instances[instance_idx]->set_offset(v->get_instance_offset()); @@ -5583,20 +5449,12 @@ void GLCanvas3D::do_move() object_moved = true; } if (object_moved) -#else - model_object->instances[instance_idx]->set_offset(v->get_offset()); - object_moved = true; -#endif // ENABLE_MODELVOLUME_TRANSFORM model_object->invalidate_bounding_box(); } } else if (object_idx == 1000) // Move a wipe tower proxy. -#if ENABLE_MODELVOLUME_TRANSFORM wipe_tower_origin = v->get_volume_offset(); -#else - wipe_tower_origin = v->get_offset(); -#endif // ENABLE_MODELVOLUME_TRANSFORM } // Fixes sinking/flying instances @@ -5639,7 +5497,6 @@ void GLCanvas3D::do_rotate() ModelObject* model_object = m_model->objects[object_idx]; if (model_object != nullptr) { -#if ENABLE_MODELVOLUME_TRANSFORM if (selection_mode == Selection::Instance) { model_object->instances[instance_idx]->set_rotation(v->get_instance_rotation()); @@ -5650,10 +5507,6 @@ void GLCanvas3D::do_rotate() model_object->volumes[volume_idx]->set_rotation(v->get_volume_rotation()); model_object->volumes[volume_idx]->set_offset(v->get_volume_offset()); } -#else - model_object->instances[instance_idx]->set_rotation(v->get_rotation()); - model_object->instances[instance_idx]->set_offset(v->get_offset()); -#endif // ENABLE_MODELVOLUME_TRANSFORM model_object->invalidate_bounding_box(); } } @@ -5694,7 +5547,6 @@ void GLCanvas3D::do_scale() ModelObject* model_object = m_model->objects[object_idx]; if (model_object != nullptr) { -#if ENABLE_MODELVOLUME_TRANSFORM if (selection_mode == Selection::Instance) { model_object->instances[instance_idx]->set_scaling_factor(v->get_instance_scaling_factor()); @@ -5706,10 +5558,6 @@ void GLCanvas3D::do_scale() model_object->volumes[volume_idx]->set_scaling_factor(v->get_volume_scaling_factor()); model_object->volumes[volume_idx]->set_offset(v->get_volume_offset()); } -#else - model_object->instances[instance_idx]->set_scaling_factor(v->get_scaling_factor()); - model_object->instances[instance_idx]->set_offset(v->get_offset()); -#endif // ENABLE_MODELVOLUME_TRANSFORM model_object->invalidate_bounding_box(); } } @@ -5755,14 +5603,11 @@ void GLCanvas3D::do_mirror() ModelObject* model_object = m_model->objects[object_idx]; if (model_object != nullptr) { -#if ENABLE_MODELVOLUME_TRANSFORM if (selection_mode == Selection::Instance) model_object->instances[instance_idx]->set_mirror(v->get_instance_mirror()); else if (selection_mode == Selection::Volume) model_object->volumes[volume_idx]->set_mirror(v->get_volume_mirror()); -#else - model_object->instances[instance_idx]->set_mirror(v->get_mirror()); -#endif // ENABLE_MODELVOLUME_TRANSFORM + model_object->invalidate_bounding_box(); } } @@ -6801,7 +6646,6 @@ void GLCanvas3D::_update_gizmos_data() if (m_selection.is_single_full_instance()) { -#if ENABLE_MODELVOLUME_TRANSFORM // all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first const GLVolume* volume = m_volumes.volumes[*m_selection.get_volume_idxs().begin()]; m_gizmos.set_scale(volume->get_instance_scaling_factor()); @@ -6817,24 +6661,7 @@ void GLCanvas3D::_update_gizmos_data() #else m_gizmos.set_model_object_ptr(model_object); #endif // ENABLE_SLA_SUPPORT_GIZMO_MOD -#else - ModelObject* model_object = m_model->objects[m_selection.get_object_idx()]; - ModelInstance* model_instance = model_object->instances[m_selection.get_instance_idx()]; - m_gizmos.set_scale(model_instance->get_scaling_factor()); -#if ENABLE_WORLD_ROTATIONS - m_gizmos.set_rotation(Vec3d::Zero()); -#else - m_gizmos.set_rotation(model_instance->get_rotation()); -#endif // ENABLE_WORLD_ROTATIONS - m_gizmos.set_flattening_data(model_object); -#if ENABLE_SLA_SUPPORT_GIZMO_MOD - m_gizmos.set_sla_support_data(model_object, m_selection); -#else - m_gizmos.set_model_object_ptr(model_object); -#endif // ENABLE_SLA_SUPPORT_GIZMO_MOD -#endif // ENABLE_MODELVOLUME_TRANSFORM } -#if ENABLE_MODELVOLUME_TRANSFORM else if (m_selection.is_single_volume() || m_selection.is_single_modifier()) { const GLVolume* volume = m_volumes.volumes[*m_selection.get_volume_idxs().begin()]; @@ -6851,7 +6678,6 @@ void GLCanvas3D::_update_gizmos_data() m_gizmos.set_model_object_ptr(nullptr); #endif // ENABLE_SLA_SUPPORT_GIZMO_MOD } -#endif // ENABLE_MODELVOLUME_TRANSFORM else { m_gizmos.set_scale(Vec3d::Ones()); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 63296dac3..d7c60f990 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -367,14 +367,8 @@ public: enum EMode : unsigned char { -#if ENABLE_MODELVOLUME_TRANSFORM Volume, Instance -#else - Volume, - Instance, - Object -#endif // ENABLE_MODELVOLUME_TRANSFORM }; enum EType : unsigned char @@ -397,7 +391,6 @@ public: struct VolumeCache { private: -#if ENABLE_MODELVOLUME_TRANSFORM struct TransformCache { Vec3d position; @@ -414,24 +407,11 @@ public: TransformCache m_volume; TransformCache m_instance; -#else - Vec3d m_position; - Vec3d m_rotation; - Vec3d m_scaling_factor; - Transform3d m_rotation_matrix; - Transform3d m_scale_matrix; -#endif // ENABLE_MODELVOLUME_TRANSFORM public: -#if ENABLE_MODELVOLUME_TRANSFORM VolumeCache() {} VolumeCache(const Geometry::Transformation& volume_transform, const Geometry::Transformation& instance_transform); -#else - VolumeCache(); - VolumeCache(const Vec3d& position, const Vec3d& rotation, const Vec3d& scaling_factor); -#endif // ENABLE_MODELVOLUME_TRANSFORM -#if ENABLE_MODELVOLUME_TRANSFORM const Vec3d& get_volume_position() const { return m_volume.position; } const Vec3d& get_volume_rotation() const { return m_volume.rotation; } const Vec3d& get_volume_scaling_factor() const { return m_volume.scaling_factor; } @@ -447,13 +427,6 @@ public: const Transform3d& get_instance_rotation_matrix() const { return m_instance.rotation_matrix; } const Transform3d& get_instance_scale_matrix() const { return m_instance.scale_matrix; } const Transform3d& get_instance_mirror_matrix() const { return m_instance.mirror_matrix; } -#else - const Vec3d& get_position() const { return m_position; } - const Vec3d& get_rotation() const { return m_rotation; } - const Vec3d& get_scaling_factor() const { return m_scaling_factor; } - const Transform3d& get_rotation_matrix() const { return m_rotation_matrix; } - const Transform3d& get_scale_matrix() const { return m_scale_matrix; } -#endif // ENABLE_MODELVOLUME_TRANSFORM }; typedef std::map VolumesCache; diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index 0a61e7900..7de065065 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -860,14 +860,10 @@ void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const bool single_selection = single_instance || single_volume; Vec3f scale = 100.0f * Vec3f::Ones(); -#if ENABLE_MODELVOLUME_TRANSFORM if (single_instance) scale = 100.0f * selection.get_volume(*selection.get_volume_idxs().begin())->get_instance_scaling_factor().cast(); else if (single_volume) scale = 100.0f * selection.get_volume(*selection.get_volume_idxs().begin())->get_volume_scaling_factor().cast(); -#else - Vec3f scale = single_instance ? 100.0f * selection.get_volume(*selection.get_volume_idxs().begin())->get_scaling_factor().cast() : 100.0f * m_scale.cast(); -#endif // ENABLE_MODELVOLUME_TRANSFORM if ((single_selection && ((m_hover_id == 0) || (m_hover_id == 1))) || m_grabbers[0].dragging || m_grabbers[1].dragging) set_tooltip("X: " + format(scale(0), 4) + "%"); @@ -915,37 +911,22 @@ void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const // gets transform from first selected volume const GLVolume* v = selection.get_volume(*idxs.begin()); -#if ENABLE_MODELVOLUME_TRANSFORM transform = v->get_instance_transformation().get_matrix(); // gets angles from first selected volume angles = v->get_instance_rotation(); // consider rotation+mirror only components of the transform for offsets offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror()); grabber_size = v->get_instance_transformation().get_matrix(true, true, false, true) * box.size(); -#else - transform = v->world_matrix().cast(); - // gets angles from first selected volume - angles = v->get_rotation(); - // consider rotation+mirror only components of the transform for offsets - offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_mirror()); -#endif // ENABLE_MODELVOLUME_TRANSFORM } else if (single_volume) { const GLVolume* v = selection.get_volume(*selection.get_volume_idxs().begin()); box = v->bounding_box; -#if ENABLE_MODELVOLUME_TRANSFORM transform = v->world_matrix(); angles = Geometry::extract_euler_angles(transform); // consider rotation+mirror only components of the transform for offsets offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror()); grabber_size = v->get_volume_transformation().get_matrix(true, true, false, true) * box.size(); -#else - transform = v->world_matrix().cast(); - angles = Geometry::extract_euler_angles(transform); - // consider rotation+mirror only components of the transform for offsets - offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_mirror()); -#endif // ENABLE_MODELVOLUME_TRANSFORM } else { @@ -1529,7 +1510,6 @@ void GLGizmoFlatten::update_planes() { TriangleMesh ch; for (const ModelVolume* vol : m_model_object->volumes) -#if ENABLE_MODELVOLUME_TRANSFORM { if (vol->type() != ModelVolume::Type::MODEL_PART) continue; @@ -1537,9 +1517,6 @@ void GLGizmoFlatten::update_planes() vol_ch.transform(vol->get_matrix()); ch.merge(vol_ch); } -#else - ch.merge(vol->get_convex_hull()); -#endif // ENABLE_MODELVOLUME_TRANSFORM ch = ch.convex_hull_3d(); diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index 5e20ceaab..afeaca327 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -840,27 +840,17 @@ void ObjectList::load_part( ModelObject* model_object, if (model_object->origin_translation != Vec3d::Zero()) { object->center_around_origin(); -#if !ENABLE_MODELVOLUME_TRANSFORM - object->ensure_on_bed(); -#endif // !ENABLE_MODELVOLUME_TRANSFORM delta = model_object->origin_translation - object->origin_translation; } for (auto volume : object->volumes) { -#if ENABLE_MODELVOLUME_TRANSFORM volume->center_geometry(); volume->translate(delta); -#endif // ENABLE_MODELVOLUME_TRANSFORM auto new_volume = model_object->add_volume(*volume); new_volume->set_type(static_cast(type)); new_volume->name = boost::filesystem::path(input_file).filename().string(); part_names.Add(new_volume->name); -#if !ENABLE_MODELVOLUME_TRANSFORM - if (delta != Vec3d::Zero()) - new_volume->translate(delta); -#endif // !ENABLE_MODELVOLUME_TRANSFORM - // set a default extruder value, since user can't add it manually new_volume->config.set_key_value("extruder", new ConfigOptionInt(0)); @@ -903,10 +893,8 @@ void ObjectList::load_generic_subobject(const std::string& type_name, const int auto new_volume = (*m_objects)[obj_idx]->add_volume(mesh); new_volume->set_type(static_cast(type)); -#if ENABLE_MODELVOLUME_TRANSFORM new_volume->set_offset(Vec3d(0.0, 0.0, (*m_objects)[obj_idx]->origin_translation(2) - mesh.stl.stats.min(2))); new_volume->center_geometry(); -#endif // ENABLE_MODELVOLUME_TRANSFORM new_volume->name = name; // set a default extruder value, since user can't add it manually diff --git a/src/slic3r/GUI/GUI_ObjectManipulation.cpp b/src/slic3r/GUI/GUI_ObjectManipulation.cpp index b2ffb1801..e14373441 100644 --- a/src/slic3r/GUI/GUI_ObjectManipulation.cpp +++ b/src/slic3r/GUI/GUI_ObjectManipulation.cpp @@ -195,30 +195,10 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele m_new_move_label_string = L("Position:"); m_new_rotate_label_string = L("Rotation:"); m_new_scale_label_string = L("Scale factors:"); -#if ENABLE_MODELVOLUME_TRANSFORM if (selection.is_single_full_instance()) -#else - if (selection.is_single_full_object()) - { - auto obj_idx = selection.get_object_idx(); - if (obj_idx >=0 && !wxGetApp().model_objects()->empty() && (*wxGetApp().model_objects())[obj_idx]->instances.size() == 1) - { - // all volumes in the selection belongs to the same instance, any of them contains the needed data, so we take the first - const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); - m_new_position = volume->get_offset(); - m_new_rotation = volume->get_rotation(); - m_new_scale = volume->get_scaling_factor(); - m_new_enabled = true; - } - else - reset_settings_value(); - } - else if (selection.is_single_full_instance()) -#endif // ENABLE_MODELVOLUME_TRANSFORM { // all volumes in the selection belongs to the same instance, any of them contains the needed instance data, so we take the first one const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); -#if ENABLE_MODELVOLUME_TRANSFORM m_new_position = volume->get_instance_offset(); m_new_rotation = volume->get_instance_rotation(); m_new_scale = volume->get_instance_scaling_factor(); @@ -228,11 +208,7 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele else // this should never happen m_new_size = Vec3d::Zero(); -#else - m_new_position = volume->get_offset(); - m_new_rotation = volume->get_rotation(); - m_new_scale = volume->get_scaling_factor(); -#endif // ENABLE_MODELVOLUME_TRANSFORM + m_new_enabled = true; } else if (selection.is_single_full_object()) @@ -250,16 +226,10 @@ void ObjectManipulation::update_settings_value(const GLCanvas3D::Selection& sele { // the selection contains a single volume const GLVolume* volume = selection.get_volume(*selection.get_volume_idxs().begin()); -#if ENABLE_MODELVOLUME_TRANSFORM m_new_position = volume->get_volume_offset(); m_new_rotation = volume->get_volume_rotation(); m_new_scale = volume->get_volume_scaling_factor(); m_new_size = volume->get_instance_transformation().get_matrix(true, true) * volume->get_volume_transformation().get_matrix(true, true) * volume->bounding_box.size(); -#else - m_new_position = volume->get_offset(); - m_new_rotation = volume->get_rotation(); - m_new_scale = volume->get_scaling_factor(); -#endif // ENABLE_MODELVOLUME_TRANSFORM m_new_enabled = true; } else if (wxGetApp().obj_list()->multiple_selection()) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6d5053bfa..db052c6f1 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1514,9 +1514,6 @@ std::vector Plater::priv::load_files(const std::vector& input_ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &model_objects) { const BoundingBoxf bed_shape = bed_shape_bb(); -#if !ENABLE_MODELVOLUME_TRANSFORM - const Vec3d bed_center = Slic3r::to_3d(bed_shape.center().cast(), 0.0); -#endif // !ENABLE_MODELVOLUME_TRANSFORM const Vec3d bed_size = Slic3r::to_3d(bed_shape.size().cast(), 1.0) - 2.0 * Vec3d::Ones(); bool need_arrange = false; @@ -1536,11 +1533,7 @@ std::vector Plater::priv::load_model_objects(const ModelObjectPtrs &mode // add a default instance and center object around origin object->center_around_origin(); // also aligns object to Z = 0 ModelInstance* instance = object->add_instance(); -#if ENABLE_MODELVOLUME_TRANSFORM instance->set_offset(Slic3r::to_3d(bed_shape.center().cast(), -object->origin_translation(2))); -#else - instance->set_offset(bed_center); -#endif // ENABLE_MODELVOLUME_TRANSFORM } const Vec3d size = object->bounding_box().size(); @@ -3340,9 +3333,6 @@ void Plater::changed_object(int obj_idx) if (list->is_parts_changed()) { // recenter and re - align to Z = 0 auto model_object = p->model.objects[obj_idx]; -#if !ENABLE_MODELVOLUME_TRANSFORM - model_object->center_around_origin(); -#endif // !ENABLE_MODELVOLUME_TRANSFORM model_object->ensure_on_bed(); if (this->p->printer_technology == ptSLA) { // Update the SLAPrint from the current Model, so that the reload_scene()