Gizmos' grabbers size made uniform as the mean value of the selection's bounding box sides
This commit is contained in:
parent
0a3500b5ab
commit
1fbdf7bdaa
@ -231,13 +231,7 @@ std::array<float, 3> GLGizmoBase::picking_color_component(unsigned int id) const
|
||||
|
||||
void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
|
||||
{
|
||||
float size = (float)box.max_size();
|
||||
|
||||
for (int i = 0; i < (int)m_grabbers.size(); ++i)
|
||||
{
|
||||
if (m_grabbers[i].enabled)
|
||||
m_grabbers[i].render((m_hover_id == i), size);
|
||||
}
|
||||
render_grabbers((float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0));
|
||||
}
|
||||
|
||||
void GLGizmoBase::render_grabbers(float size) const
|
||||
@ -251,7 +245,7 @@ void GLGizmoBase::render_grabbers(float size) const
|
||||
|
||||
void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
||||
{
|
||||
float size = (float)box.max_size();
|
||||
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
|
||||
for (unsigned int i = 0; i < (unsigned int)m_grabbers.size(); ++i)
|
||||
{
|
||||
@ -261,7 +255,7 @@ void GLGizmoBase::render_grabbers_for_picking(const BoundingBoxf3& box) const
|
||||
m_grabbers[i].color[0] = color[0];
|
||||
m_grabbers[i].color[1] = color[1];
|
||||
m_grabbers[i].color[2] = color[2];
|
||||
m_grabbers[i].render_for_picking(size);
|
||||
m_grabbers[i].render_for_picking(mean_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ void GLGizmoCut::on_render(const Selection& selection) const
|
||||
::glEnd();
|
||||
|
||||
std::copy(std::begin(GrabberColor), std::end(GrabberColor), m_grabbers[0].color);
|
||||
m_grabbers[0].render(m_hover_id == 0, box.max_size());
|
||||
m_grabbers[0].render(m_hover_id == 0, (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0));
|
||||
}
|
||||
|
||||
void GLGizmoCut::on_render_for_picking(const Selection& selection) const
|
||||
|
@ -216,7 +216,8 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
|
||||
if (m_quadric == nullptr)
|
||||
return;
|
||||
|
||||
double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[axis].get_half_size((float)box.max_size());
|
||||
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size(mean_size) : (double)m_grabbers[axis].get_half_size(mean_size);
|
||||
|
||||
float color[3];
|
||||
::memcpy((void*)color, (const void*)m_grabbers[axis].color, 3 * sizeof(float));
|
||||
|
@ -307,7 +307,8 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
|
||||
if (m_quadric == nullptr)
|
||||
return;
|
||||
|
||||
double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size((float)box.max_size()) : (double)m_grabbers[0].get_half_size((float)box.max_size());
|
||||
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
|
||||
double size = m_dragging ? (double)m_grabbers[0].get_dragging_half_size(mean_size) : (double)m_grabbers[0].get_half_size(mean_size);
|
||||
|
||||
float color[3];
|
||||
::memcpy((void*)color, (const void*)m_grabbers[0].color, 3 * sizeof(float));
|
||||
|
@ -116,8 +116,6 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
||||
Vec3d angles = Vec3d::Zero();
|
||||
Transform3d offsets_transform = Transform3d::Identity();
|
||||
|
||||
Vec3d grabber_size = Vec3d::Zero();
|
||||
|
||||
if (single_instance)
|
||||
{
|
||||
// calculate bounding box in instance local reference system
|
||||
@ -135,7 +133,6 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
||||
angles = v->get_instance_rotation();
|
||||
// consider rotation+mirror only components of the transform for offsets
|
||||
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror());
|
||||
grabber_size = v->get_instance_transformation().get_matrix(true, true, false, true) * box.size();
|
||||
}
|
||||
else if (single_volume)
|
||||
{
|
||||
@ -145,13 +142,9 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
||||
angles = Geometry::extract_euler_angles(transform);
|
||||
// consider rotation+mirror only components of the transform for offsets
|
||||
offsets_transform = Geometry::assemble_transform(Vec3d::Zero(), angles, Vec3d::Ones(), v->get_instance_mirror());
|
||||
grabber_size = v->get_volume_transformation().get_matrix(true, true, false, true) * box.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
box = selection.get_bounding_box();
|
||||
grabber_size = box.size();
|
||||
}
|
||||
|
||||
m_box = box;
|
||||
|
||||
@ -196,7 +189,9 @@ void GLGizmoScale3D::on_render(const Selection& selection) const
|
||||
|
||||
::glLineWidth((m_hover_id != -1) ? 2.0f : 1.5f);
|
||||
|
||||
float grabber_mean_size = (float)(grabber_size(0) + grabber_size(1) + grabber_size(2)) / 3.0f;
|
||||
const BoundingBoxf3& selection_box = selection.get_bounding_box();
|
||||
|
||||
float grabber_mean_size = (float)((selection_box.size()(0) + selection_box.size()(1) + selection_box.size()(2)) / 3.0);
|
||||
|
||||
if (m_hover_id == -1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user