Merge remote-tracking branch 'remotes/origin/dev_native' into vb_3dscene_partial_update

This commit is contained in:
bubnikv 2018-11-16 18:31:39 +01:00
commit dafa4621aa
23 changed files with 804 additions and 273 deletions

View file

@ -1103,6 +1103,9 @@ GLCanvas3D::Mouse::Drag::Drag()
GLCanvas3D::Mouse::Mouse()
: dragging(false)
, position(DBL_MAX, DBL_MAX)
#if ENABLE_GIZMOS_ON_TOP
, scene_position(DBL_MAX, DBL_MAX, DBL_MAX)
#endif // ENABLE_GIZMOS_ON_TOP
#if ENABLE_GIZMOS_RESET
, ignore_up_event(false)
#endif // ENABLE_GIZMOS_RESET
@ -1677,6 +1680,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;
}
@ -2336,6 +2343,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;
@ -3638,6 +3658,13 @@ 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();
_render_cutting_plane();
#if ENABLE_SHOW_CAMERA_TARGET
@ -4389,19 +4416,29 @@ 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
}
}
else if (evt.RightDown())