Keeps objects on bed while scaling them using the scale gizmo
This commit is contained in:
parent
4de0f574fb
commit
d45739fa15
3 changed files with 22 additions and 0 deletions
|
@ -23,6 +23,8 @@
|
|||
#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)
|
||||
// Gizmos always rendered on top of objects
|
||||
#define ENABLE_GIZMOS_ON_TOP (1 && ENABLE_1_42_0)
|
||||
// New menu layout (open/save/save as project + import/export)
|
||||
|
|
|
@ -1639,6 +1639,10 @@ void GLCanvas3D::Selection::scale(const Vec3d& scale)
|
|||
_synchronize_unselected_volumes();
|
||||
#endif // !DISABLE_INSTANCES_SYNCH
|
||||
|
||||
#if ENABLE_ENSURE_ON_BED_WHILE_SCALING
|
||||
_ensure_on_bed();
|
||||
#endif // ENABLE_ENSURE_ON_BED_WHILE_SCALING
|
||||
|
||||
m_bounding_box_dirty = true;
|
||||
}
|
||||
|
||||
|
@ -2302,6 +2306,19 @@ void GLCanvas3D::Selection::_synchronize_unselected_volumes()
|
|||
}
|
||||
}
|
||||
|
||||
#if ENABLE_ENSURE_ON_BED_WHILE_SCALING
|
||||
void GLCanvas3D::Selection::_ensure_on_bed()
|
||||
{
|
||||
for (unsigned int i : m_list)
|
||||
{
|
||||
GLVolume* volume = (*m_volumes)[i];
|
||||
double min_z = volume->transformed_convex_hull_bounding_box().min(2);
|
||||
if (min_z != 0.0)
|
||||
volume->set_instance_offset(Z, volume->get_instance_offset(Z) - min_z);
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_ENSURE_ON_BED_WHILE_SCALING
|
||||
|
||||
const float GLCanvas3D::Gizmos::OverlayTexturesScale = 0.75f;
|
||||
const float GLCanvas3D::Gizmos::OverlayOffsetX = 10.0f * OverlayTexturesScale;
|
||||
const float GLCanvas3D::Gizmos::OverlayGapY = 5.0f * OverlayTexturesScale;
|
||||
|
|
|
@ -559,6 +559,9 @@ public:
|
|||
void _render_bounding_box(const BoundingBoxf3& box, float* color) const;
|
||||
void _synchronize_unselected_instances();
|
||||
void _synchronize_unselected_volumes();
|
||||
#if ENABLE_ENSURE_ON_BED_WHILE_SCALING
|
||||
void _ensure_on_bed();
|
||||
#endif // ENABLE_ENSURE_ON_BED_WHILE_SCALING
|
||||
};
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue