Added snap to scale to rotate gizmo

This commit is contained in:
Enrico Turri 2018-08-24 12:16:11 +02:00
parent 5f6a8adf7c
commit 8a9d0023a7

View File

@ -297,8 +297,9 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray)
if (cross2(orig_dir, new_dir) < 0.0) if (cross2(orig_dir, new_dir) < 0.0)
theta = 2.0 * (double)PI - theta; theta = 2.0 * (double)PI - theta;
// snap
double len = mouse_pos.norm(); double len = mouse_pos.norm();
// snap to snap region
double in_radius = (double)m_radius / 3.0; double in_radius = (double)m_radius / 3.0;
double out_radius = 2.0 * (double)in_radius; double out_radius = 2.0 * (double)in_radius;
if ((in_radius <= len) && (len <= out_radius)) if ((in_radius <= len) && (len <= out_radius))
@ -306,6 +307,17 @@ void GLGizmoRotate::on_update(const Linef3& mouse_ray)
double step = 2.0 * (double)PI / (double)SnapRegionsCount; double step = 2.0 * (double)PI / (double)SnapRegionsCount;
theta = step * (double)std::round(theta / step); theta = step * (double)std::round(theta / step);
} }
else
{
// snap to scale
in_radius = (double)m_radius;
out_radius = in_radius + (double)ScaleLongTooth;
if ((in_radius <= len) && (len <= out_radius))
{
double step = 2.0 * (double)PI / (double)ScaleStepsCount;
theta = step * (double)std::round(theta / step);
}
}
if (theta == 2.0 * (double)PI) if (theta == 2.0 * (double)PI)
theta = 0.0; theta = 0.0;