diff --git a/xs/src/libslic3r/Model.cpp b/xs/src/libslic3r/Model.cpp index 93f0152c8..19c474cad 100644 --- a/xs/src/libslic3r/Model.cpp +++ b/xs/src/libslic3r/Model.cpp @@ -1016,6 +1016,11 @@ BoundingBoxf3 ModelInstance::transform_bounding_box(const BoundingBoxf3 &bbox, b return bbox.transformed(world_matrix(dont_translate)); } +Vec3d ModelInstance::transform_vector(const Vec3d& v, bool dont_translate) const +{ + return world_matrix(dont_translate) * v; +} + void ModelInstance::transform_polygon(Polygon* polygon) const { polygon->rotate(this->rotation); // rotate around polygon origin diff --git a/xs/src/libslic3r/Model.hpp b/xs/src/libslic3r/Model.hpp index bbfd2bde2..8a8af481c 100644 --- a/xs/src/libslic3r/Model.hpp +++ b/xs/src/libslic3r/Model.hpp @@ -239,6 +239,8 @@ public: BoundingBoxf3 transform_mesh_bounding_box(const TriangleMesh* mesh, bool dont_translate = false) const; // Transform an external bounding box. BoundingBoxf3 transform_bounding_box(const BoundingBoxf3 &bbox, bool dont_translate = false) const; + // Transform an external vector. + Vec3d transform_vector(const Vec3d& v, bool dont_translate = false) const; // To be called on an external polygon. It does not translate the polygon, only rotates and scales. void transform_polygon(Polygon* polygon) const; diff --git a/xs/src/slic3r/GUI/GLCanvas3D.cpp b/xs/src/slic3r/GUI/GLCanvas3D.cpp index 063b96cbe..2bec6b66b 100644 --- a/xs/src/slic3r/GUI/GLCanvas3D.cpp +++ b/xs/src/slic3r/GUI/GLCanvas3D.cpp @@ -5241,11 +5241,14 @@ void GLCanvas3D::_on_move(const std::vector& volume_idxs) { // Move a regular object. ModelObject* model_object = m_model->objects[obj_idx]; - const Vec3d& offset = volume->get_offset(); - model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1)); - model_object->invalidate_bounding_box(); - update_position_values(); - object_moved = true; + if (model_object != nullptr) + { + const Vec3d& offset = volume->get_offset(); + model_object->instances[instance_idx]->offset = Vec2d(offset(0), offset(1)); + model_object->invalidate_bounding_box(); + update_position_values(); + object_moved = true; + } } else if (obj_idx == 1000) // Move a wipe tower proxy. diff --git a/xs/src/slic3r/GUI/GLGizmo.cpp b/xs/src/slic3r/GUI/GLGizmo.cpp index e46cfa925..1c0456fa8 100644 --- a/xs/src/slic3r/GUI/GLGizmo.cpp +++ b/xs/src/slic3r/GUI/GLGizmo.cpp @@ -1061,8 +1061,6 @@ void GLGizmoFlatten::on_render_for_picking(const BoundingBoxf3& box) const for (unsigned int i = 0; i < m_planes.size(); ++i) { - // FIXME: the color assignement will fail if the planes count is greater than 254 - // use the other color components in that case !! ::glColor3f(1.0f, 1.0f, picking_color_component(i)); for (const Vec2d& offset : m_instances_positions) { ::glPushMatrix(); @@ -1240,9 +1238,9 @@ void GLGizmoFlatten::update_planes() polygon = transform(polygon, m); } - // We'll sort the planes by area and only keep the 255 largest ones (because of the picking pass limitations): + // We'll sort the planes by area and only keep the 254 largest ones (because of the picking pass limitations): std::sort(m_planes.rbegin(), m_planes.rend(), [](const PlaneData& a, const PlaneData& b) { return a.area < b.area; }); - m_planes.resize(std::min((int)m_planes.size(), 255)); + m_planes.resize(std::min((int)m_planes.size(), 254)); // Planes are finished - let's save what we calculated it from: m_source_data.bounding_boxes.clear();