reset transformation components to their default value by double clicking on gizmos' grabbers
This commit is contained in:
parent
3f0968fb02
commit
c9acd1252a
5 changed files with 83 additions and 0 deletions
|
@ -6,6 +6,8 @@
|
|||
|
||||
// Add z coordinate to model instances' offset
|
||||
#define ENABLE_MODELINSTANCE_3D_OFFSET (1 && ENABLE_1_42_0)
|
||||
// Add double click on gizmo grabbers to reset transformation components to their default value
|
||||
#define ENABLE_GIZMOS_RESET (1 && ENABLE_1_42_0)
|
||||
|
||||
#endif // _technologies_h_
|
||||
|
||||
|
|
|
@ -1349,6 +1349,18 @@ void GLCanvas3D::Gizmos::update(const Linef3& mouse_ray)
|
|||
curr->update(mouse_ray);
|
||||
}
|
||||
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
void GLCanvas3D::Gizmos::process_double_click()
|
||||
{
|
||||
if (!m_enabled)
|
||||
return;
|
||||
|
||||
GLGizmoBase* curr = _get_current();
|
||||
if (curr != nullptr)
|
||||
curr->process_double_click();
|
||||
}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
|
||||
GLCanvas3D::Gizmos::EType GLCanvas3D::Gizmos::get_current_type() const
|
||||
{
|
||||
return m_current;
|
||||
|
@ -3043,6 +3055,38 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
m_toolbar_action_running = true;
|
||||
m_toolbar.do_action((unsigned int)toolbar_contains_mouse);
|
||||
}
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
else if (evt.LeftDClick() && m_gizmos.grabber_contains_mouse())
|
||||
{
|
||||
m_gizmos.process_double_click();
|
||||
switch (m_gizmos.get_current_type())
|
||||
{
|
||||
case Gizmos::Scale:
|
||||
{
|
||||
m_on_gizmo_scale_uniformly_callback.call((double)m_gizmos.get_scale());
|
||||
update_scale_values();
|
||||
m_dirty = true;
|
||||
break;
|
||||
}
|
||||
case Gizmos::Rotate:
|
||||
{
|
||||
#if ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
const Vec3d& rotation = m_gizmos.get_rotation();
|
||||
m_on_gizmo_rotate_3D_callback.call(rotation(0), rotation(1), rotation(2));
|
||||
#else
|
||||
m_on_gizmo_rotate_callback.call((double)m_gizmos.get_angle_z());
|
||||
#endif //ENABLE_MODELINSTANCE_3D_ROTATION
|
||||
update_rotation_values();
|
||||
m_dirty = true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
else if (evt.LeftDown() || evt.RightDown())
|
||||
{
|
||||
// If user pressed left or right button we first check whether this happened
|
||||
|
|
|
@ -366,6 +366,9 @@ class GLCanvas3D
|
|||
bool overlay_contains_mouse(const GLCanvas3D& canvas, const Vec2d& mouse_pos) const;
|
||||
bool grabber_contains_mouse() const;
|
||||
void update(const Linef3& mouse_ray);
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
void process_double_click();
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
|
||||
EType get_current_type() const;
|
||||
|
||||
|
|
|
@ -759,6 +759,20 @@ void GLGizmoScale3D::on_update(const Linef3& mouse_ray)
|
|||
do_scale_uniform(mouse_ray);
|
||||
}
|
||||
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
void GLGizmoScale3D::on_process_double_click()
|
||||
{
|
||||
if ((m_hover_id == 0) || (m_hover_id == 1))
|
||||
m_scale(0) = 1.0;
|
||||
else if ((m_hover_id == 2) || (m_hover_id == 3))
|
||||
m_scale(1) = 1.0;
|
||||
else if ((m_hover_id == 4) || (m_hover_id == 5))
|
||||
m_scale(2) = 1.0;
|
||||
else if (m_hover_id >= 6)
|
||||
m_scale = Vec3d::Ones();
|
||||
}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
|
||||
void GLGizmoScale3D::on_render(const BoundingBoxf3& box) const
|
||||
{
|
||||
if (m_grabbers[0].dragging || m_grabbers[1].dragging)
|
||||
|
|
|
@ -94,6 +94,10 @@ public:
|
|||
|
||||
void update(const Linef3& mouse_ray);
|
||||
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
void process_double_click() { on_process_double_click(); }
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
|
||||
void render(const BoundingBoxf3& box) const { on_render(box); }
|
||||
void render_for_picking(const BoundingBoxf3& box) const { on_render_for_picking(box); }
|
||||
|
||||
|
@ -106,6 +110,9 @@ protected:
|
|||
virtual void on_start_dragging(const BoundingBoxf3& box) {}
|
||||
virtual void on_stop_dragging() {}
|
||||
virtual void on_update(const Linef3& mouse_ray) = 0;
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
virtual void on_process_double_click() {}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
virtual void on_render(const BoundingBoxf3& box) const = 0;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const = 0;
|
||||
|
||||
|
@ -155,6 +162,9 @@ protected:
|
|||
virtual bool on_init();
|
||||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_update(const Linef3& mouse_ray);
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
virtual void on_process_double_click() { m_angle = 0.0; }
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
|
||||
|
@ -222,6 +232,13 @@ protected:
|
|||
g.update(mouse_ray);
|
||||
}
|
||||
}
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
virtual void on_process_double_click()
|
||||
{
|
||||
if (m_hover_id != -1)
|
||||
m_gizmos[m_hover_id].process_double_click();
|
||||
}
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
|
@ -265,6 +282,9 @@ protected:
|
|||
virtual void on_start_dragging(const BoundingBoxf3& box);
|
||||
virtual void on_stop_dragging() { m_show_starting_box = false; }
|
||||
virtual void on_update(const Linef3& mouse_ray);
|
||||
#if ENABLE_GIZMOS_RESET
|
||||
virtual void on_process_double_click();
|
||||
#endif // ENABLE_GIZMOS_RESET
|
||||
virtual void on_render(const BoundingBoxf3& box) const;
|
||||
virtual void on_render_for_picking(const BoundingBoxf3& box) const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue