From d78db60b156258826dcd7361d7bc2a5bc52609f5 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Wed, 20 Oct 2021 12:29:27 +0200 Subject: [PATCH] Partial revert of 7e5c214b91ae14740fc188413948818a1b49928a to restore code mistakenly removed and needed when tech ENABLE_WORLD_COORDINATE is disabled --- src/libslic3r/Technologies.hpp | 8 ++++---- src/slic3r/GUI/Gizmos/GLGizmoScale.cpp | 11 ++++++++--- src/slic3r/GUI/Gizmos/GLGizmoScale.hpp | 3 +++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index 6549ac8c97..4564d975d2 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -80,14 +80,14 @@ // Enable rendering modifiers and similar objects always as transparent #define ENABLE_MODIFIERS_ALWAYS_TRANSPARENT (1 && ENABLE_2_4_0_ALPHA4) +// Enable the fix for the detection of the out of bed state for sinking objects +// and detection of out of bed using the bed perimeter +#define ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS (1 && ENABLE_2_4_0_ALPHA4) + // Enable editing volumes transformation in world coordinates and instances in local coordinates #define ENABLE_WORLD_COORDINATE (1 && ENABLE_2_4_0_ALPHA4) // Enable showing world coordinates of volumes' offset relative to the instance containing them #define ENABLE_WORLD_COORDINATE_VOLUMES_LOCAL_OFFSET (1 && ENABLE_WORLD_COORDINATE) -// Enable the fix for the detection of the out of bed state for sinking objects -// and detection of out of bed using the bed perimeter -#define ENABLE_OUT_OF_BED_DETECTION_IMPROVEMENTS (1 && ENABLE_2_4_0_ALPHA4) - #endif // _prusaslicer_technologies_h_ diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp index 8fc2e852c6..dc0656c49d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.cpp @@ -145,6 +145,7 @@ void GLGizmoScale3D::on_render() #else // Transforms grabbers' offsets to world refefence system Transform3d offsets_transform = Transform3d::Identity(); + m_offsets_transform = Transform3d::Identity(); Vec3d angles = Vec3d::Zero(); if (selection.is_single_full_instance()) { @@ -171,6 +172,7 @@ void GLGizmoScale3D::on_render() 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()); + m_offsets_transform = offsets_transform; #endif // ENABLE_WORLD_COORDINATE } #if ENABLE_WORLD_COORDINATE @@ -191,6 +193,7 @@ void GLGizmoScale3D::on_render() angles = Geometry::extract_euler_angles(m_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()); + m_offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), v->get_volume_rotation(), Vec3d::Ones(), v->get_volume_mirror()); #endif // ENABLE_WORLD_COORDINATE } #if ENABLE_WORLD_COORDINATE @@ -421,9 +424,7 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data) const double inner_ratio = len_center_vec / len_starting_vec; double local_offset = inner_ratio * 0.5 * (ratio - 1.0) * m_starting.box.size()(axis); #else - double local_offset = 0.5 * (ratio - 1.0) * m_starting.box.size()(axis); - if (!m_parent.get_selection().is_single_full_instance()) - local_offset *= m_starting.scale(axis); + double local_offset = 0.5 * (m_scale(axis) - m_starting.scale(axis)) * m_starting.box.size()(axis); #endif // ENABLE_WORLD_COORDINATE if (m_hover_id == 2 * axis) @@ -438,7 +439,11 @@ void GLGizmoScale3D::do_scale_along_axis(Axis axis, const UpdateData& data) default: break; } +#if ENABLE_WORLD_COORDINATE m_offset = local_offset_vec; +#else + m_offset = m_offsets_transform * local_offset_vec; +#endif // ENABLE_WORLD_COORDINATE } else m_offset = Vec3d::Zero(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp b/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp index 639e4a6cb3..26badc5252 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoScale.hpp @@ -29,6 +29,9 @@ class GLGizmoScale3D : public GLGizmoBase #if ENABLE_WORLD_COORDINATE Transform3d m_grabbers_transform; Vec3d m_center{ Vec3d::Zero() }; +#else + // Transforms grabbers offsets to the proper reference system (world for instances, instance for volumes) + Transform3d m_offsets_transform; #endif // ENABLE_WORLD_COORDINATE Vec3d m_scale{ Vec3d::Ones() }; Vec3d m_offset{ Vec3d::Zero() };