Follow-up of 9c7a4a1e51 and 62ecc3a82a - Fixed gizmo scale rotating for parts having skew and its rendering for mirrored parts

This commit is contained in:
enricoturri1966 2023-02-13 14:53:21 +01:00
parent 8b5b662164
commit 745c55abc3
3 changed files with 15 additions and 18 deletions

View File

@ -198,16 +198,23 @@ void GLGizmoBase::render_grabbers(const BoundingBoxf3& box) const
}
void GLGizmoBase::render_grabbers(float size) const
{
render_grabbers(0, m_grabbers.size() - 1, size, false);
}
void GLGizmoBase::render_grabbers(size_t first, size_t last, float size, bool force_hover) const
{
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
if (shader == nullptr)
return;
shader->start_using();
shader->set_uniform("emission_factor", 0.1f);
for (int i = 0; i < (int)m_grabbers.size(); ++i) {
glsafe(::glDisable(GL_CULL_FACE));
for (size_t i = first; i <= last; ++i) {
if (m_grabbers[i].enabled)
m_grabbers[i].render(m_hover_id == i, size);
m_grabbers[i].render(force_hover ? true : m_hover_id == (int)i, size);
}
glsafe(::glEnable(GL_CULL_FACE));
shader->stop_using();
}

View File

@ -219,6 +219,7 @@ protected:
void render_grabbers(const BoundingBoxf3& box) const;
void render_grabbers(float size) const;
void render_grabbers(size_t first, size_t last, float size, bool force_hover) const;
std::string format(float value, unsigned int decimals) const;

View File

@ -217,13 +217,7 @@ void GLGizmoScale3D::on_render()
const auto& [box, box_trafo] = selection.get_bounding_box_in_current_reference_system();
m_bounding_box = box;
m_center = box_trafo.translation();
m_grabbers_transform = Geometry::translation_transform(m_center);
if (!wxGetApp().obj_manipul()->is_world_coordinates()) {
const GLVolume& v = *selection.get_first_volume();
m_grabbers_transform = m_grabbers_transform * v.get_instance_transformation().get_rotation_matrix();
if (selection.is_single_volume_or_modifier() && wxGetApp().obj_manipul()->is_local_coordinates())
m_grabbers_transform = m_grabbers_transform * v.get_volume_transformation().get_rotation_matrix();
}
m_grabbers_transform = box_trafo;
m_instance_center = (selection.is_single_full_instance() || selection.is_single_volume_or_modifier()) ? selection.get_first_volume()->get_instance_offset() : m_center;
// x axis
@ -329,8 +323,7 @@ void GLGizmoScale3D::on_render()
if (shader != nullptr) {
shader->start_using();
shader->set_uniform("emission_factor", 0.1f);
m_grabbers[0].render(true, grabber_mean_size);
m_grabbers[1].render(true, grabber_mean_size);
render_grabbers(0, 1, grabber_mean_size, true);
shader->stop_using();
}
}
@ -361,8 +354,7 @@ void GLGizmoScale3D::on_render()
if (shader != nullptr) {
shader->start_using();
shader->set_uniform("emission_factor", 0.1f);
m_grabbers[2].render(true, grabber_mean_size);
m_grabbers[3].render(true, grabber_mean_size);
render_grabbers(2, 3, grabber_mean_size, true);
shader->stop_using();
}
}
@ -393,8 +385,7 @@ void GLGizmoScale3D::on_render()
if (shader != nullptr) {
shader->start_using();
shader->set_uniform("emission_factor", 0.1f);
m_grabbers[4].render(true, grabber_mean_size);
m_grabbers[5].render(true, grabber_mean_size);
render_grabbers(4, 5, grabber_mean_size, true);
shader->stop_using();
}
}
@ -428,9 +419,7 @@ void GLGizmoScale3D::on_render()
if (shader != nullptr) {
shader->start_using();
shader->set_uniform("emission_factor", 0.1f);
for (int i = 6; i < 10; ++i) {
m_grabbers[i].render(true, grabber_mean_size);
}
render_grabbers(6, 9, grabber_mean_size, true);
shader->stop_using();
}
}