Gizmos rendered on top set as default

This commit is contained in:
Enrico Turri 2018-12-04 15:53:40 +01:00
parent 8d25f3aaaf
commit 04d7154d40
4 changed files with 0 additions and 30 deletions

View file

@ -23,8 +23,6 @@
#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)
// 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)
// Enables shortcut keys for gizmos

View file

@ -1029,9 +1029,7 @@ GLCanvas3D::Mouse::Mouse()
: dragging(false)
, left_down(false)
, position(DBL_MAX, DBL_MAX)
#if ENABLE_GIZMOS_ON_TOP
, scene_position(DBL_MAX, DBL_MAX, DBL_MAX)
#endif // ENABLE_GIZMOS_ON_TOP
{
}
@ -3865,12 +3863,10 @@ void GLCanvas3D::render()
_render_bed(theta);
}
#if ENABLE_GIZMOS_ON_TOP
// we need to set the mouse's scene position here because the depth buffer
// could be invalidated by the following gizmo render methods
// this position is used later into on_mouse() to drag the objects
m_mouse.scene_position = _mouse_to_3d(m_mouse.position.cast<int>());
#endif // ENABLE_GIZMOS_ON_TOP
_render_current_gizmo();
#if ENABLE_SHOW_CAMERA_TARGET
@ -4692,29 +4688,15 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
{
if (evt.LeftDown() && m_moving_enabled && (m_mouse.drag.move_volume_idx == -1))
{
#if !ENABLE_GIZMOS_ON_TOP
// The mouse_to_3d gets the Z coordinate from the Z buffer at the screen coordinate pos x, y,
// an converts the screen space coordinate to unscaled object space.
Vec3d pos3d = _mouse_to_3d(pos);
#endif // !ENABLE_GIZMOS_ON_TOP
// Only accept the initial position, if it is inside the volume bounding box.
BoundingBoxf3 volume_bbox = m_volumes.volumes[m_hover_volume_id]->transformed_bounding_box();
volume_bbox.offset(1.0);
#if ENABLE_GIZMOS_ON_TOP
if (volume_bbox.contains(m_mouse.scene_position))
#else
if (volume_bbox.contains(pos3d))
#endif // ENABLE_GIZMOS_ON_TOP
{
// The dragging operation is initiated.
m_mouse.drag.move_volume_idx = m_hover_volume_id;
m_selection.start_dragging();
#if ENABLE_GIZMOS_ON_TOP
m_mouse.drag.start_position_3D = m_mouse.scene_position;
#else
m_mouse.drag.start_position_3D = pos3d;
#endif // ENABLE_GIZMOS_ON_TOP
m_moving = true;
}
}

View file

@ -324,9 +324,7 @@ class GLCanvas3D
bool dragging;
bool left_down;
Vec2d position;
#if ENABLE_GIZMOS_ON_TOP
Vec3d scene_position;
#endif // ENABLE_GIZMOS_ON_TOP
Drag drag;
Mouse();

View file

@ -760,9 +760,7 @@ void GLGizmoRotate3D::on_stop_dragging()
void GLGizmoRotate3D::on_render(const GLCanvas3D::Selection& selection) const
{
#if ENABLE_GIZMOS_ON_TOP
::glClear(GL_DEPTH_BUFFER_BIT);
#endif // ENABLE_GIZMOS_ON_TOP
if ((m_hover_id == -1) || (m_hover_id == 0))
m_gizmos[X].render(selection);
@ -899,9 +897,7 @@ void GLGizmoScale3D::on_render(const GLCanvas3D::Selection& selection) const
((m_hover_id == 6) || (m_hover_id == 7) || (m_hover_id == 8) || (m_hover_id == 9)))
set_tooltip("X/Y/Z");
#if ENABLE_GIZMOS_ON_TOP
::glClear(GL_DEPTH_BUFFER_BIT);
#endif // ENABLE_GIZMOS_ON_TOP
::glEnable(GL_DEPTH_TEST);
BoundingBoxf3 box;
@ -1264,9 +1260,7 @@ void GLGizmoMove3D::on_render(const GLCanvas3D::Selection& selection) const
else if (!m_grabbers[2].dragging && (m_hover_id == 2))
set_tooltip("Z");
#if ENABLE_GIZMOS_ON_TOP
::glClear(GL_DEPTH_BUFFER_BIT);
#endif // ENABLE_GIZMOS_ON_TOP
::glEnable(GL_DEPTH_TEST);
const BoundingBoxf3& box = selection.get_bounding_box();
@ -1464,9 +1458,7 @@ void GLGizmoFlatten::on_start_dragging(const GLCanvas3D::Selection& selection)
void GLGizmoFlatten::on_render(const GLCanvas3D::Selection& selection) const
{
#if ENABLE_GIZMOS_ON_TOP
::glClear(GL_DEPTH_BUFFER_BIT);
#endif // ENABLE_GIZMOS_ON_TOP
::glEnable(GL_DEPTH_TEST);
::glEnable(GL_BLEND);