Lay flat gizmo is rendered before the bed, so the surfaces are visible from below, and a rotation-related bugfix
This commit is contained in:
parent
b0dd328fde
commit
3b86c57c8f
@ -1419,22 +1419,27 @@ void GLCanvas3D::Gizmos::set_flattening_data(const ModelObject* model_object)
|
|||||||
reinterpret_cast<GLGizmoFlatten*>(it->second)->set_flattening_data(model_object);
|
reinterpret_cast<GLGizmoFlatten*>(it->second)->set_flattening_data(model_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Gizmos::render(const GLCanvas3D& canvas, const BoundingBoxf3& box) const
|
void GLCanvas3D::Gizmos::render(const GLCanvas3D& canvas, const BoundingBoxf3& box, RenderOrder render_order) const
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
::glDisable(GL_DEPTH_TEST);
|
::glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
if (box.radius() > 0.0)
|
if ((render_order == BeforeBed && dynamic_cast<GLGizmoFlatten*>(_get_current()))
|
||||||
_render_current_gizmo(box);
|
|| (render_order == AfterBed && !dynamic_cast<GLGizmoFlatten*>(_get_current()))) {
|
||||||
|
if (box.radius() > 0.0)
|
||||||
|
_render_current_gizmo(box);
|
||||||
|
}
|
||||||
|
|
||||||
::glPushMatrix();
|
if (render_order == AfterBed) {
|
||||||
::glLoadIdentity();
|
::glPushMatrix();
|
||||||
|
::glLoadIdentity();
|
||||||
|
|
||||||
_render_overlay(canvas);
|
_render_overlay(canvas);
|
||||||
|
|
||||||
::glPopMatrix();
|
::glPopMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::Gizmos::render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const
|
void GLCanvas3D::Gizmos::render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const
|
||||||
@ -2249,6 +2254,7 @@ void GLCanvas3D::render()
|
|||||||
_render_axes(false);
|
_render_axes(false);
|
||||||
}
|
}
|
||||||
_render_objects();
|
_render_objects();
|
||||||
|
_render_gizmo(Gizmos::RenderOrder::BeforeBed);
|
||||||
// textured bed needs to be rendered after objects
|
// textured bed needs to be rendered after objects
|
||||||
if (!is_custom_bed)
|
if (!is_custom_bed)
|
||||||
{
|
{
|
||||||
@ -2258,7 +2264,7 @@ void GLCanvas3D::render()
|
|||||||
_render_cutting_plane();
|
_render_cutting_plane();
|
||||||
_render_warning_texture();
|
_render_warning_texture();
|
||||||
_render_legend_texture();
|
_render_legend_texture();
|
||||||
_render_gizmo();
|
_render_gizmo(Gizmos::RenderOrder::AfterBed);
|
||||||
_render_layer_editing_overlay();
|
_render_layer_editing_overlay();
|
||||||
|
|
||||||
m_canvas->SwapBuffers();
|
m_canvas->SwapBuffers();
|
||||||
@ -3756,9 +3762,9 @@ void GLCanvas3D::_render_volumes(bool fake_colors) const
|
|||||||
::glDisable(GL_LIGHTING);
|
::glDisable(GL_LIGHTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::_render_gizmo() const
|
void GLCanvas3D::_render_gizmo(Gizmos::RenderOrder render_order) const
|
||||||
{
|
{
|
||||||
m_gizmos.render(*this, _selected_volumes_bounding_box());
|
m_gizmos.render(*this, _selected_volumes_bounding_box(), render_order);
|
||||||
}
|
}
|
||||||
|
|
||||||
float GLCanvas3D::_get_layers_editing_cursor_z_relative() const
|
float GLCanvas3D::_get_layers_editing_cursor_z_relative() const
|
||||||
|
@ -341,6 +341,10 @@ public:
|
|||||||
Flatten,
|
Flatten,
|
||||||
Num_Types
|
Num_Types
|
||||||
};
|
};
|
||||||
|
enum RenderOrder : unsigned char {
|
||||||
|
BeforeBed,
|
||||||
|
AfterBed
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
@ -386,7 +390,7 @@ public:
|
|||||||
void set_flattening_data(const ModelObject* model_object);
|
void set_flattening_data(const ModelObject* model_object);
|
||||||
Pointf3 get_flattening_normal() const;
|
Pointf3 get_flattening_normal() const;
|
||||||
|
|
||||||
void render(const GLCanvas3D& canvas, const BoundingBoxf3& box) const;
|
void render(const GLCanvas3D& canvas, const BoundingBoxf3& box, RenderOrder render_order) const;
|
||||||
void render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const;
|
void render_current_gizmo_for_picking_pass(const BoundingBoxf3& box) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -633,7 +637,7 @@ private:
|
|||||||
void _render_legend_texture() const;
|
void _render_legend_texture() const;
|
||||||
void _render_layer_editing_overlay() const;
|
void _render_layer_editing_overlay() const;
|
||||||
void _render_volumes(bool fake_colors) const;
|
void _render_volumes(bool fake_colors) const;
|
||||||
void _render_gizmo() const;
|
void _render_gizmo(Gizmos::RenderOrder render_order) const;
|
||||||
|
|
||||||
float _get_layers_editing_cursor_z_relative() const;
|
float _get_layers_editing_cursor_z_relative() const;
|
||||||
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
void _perform_layer_editing_action(wxMouseEvent* evt = nullptr);
|
||||||
|
@ -775,7 +775,7 @@ void GLGizmoFlatten::update_planes()
|
|||||||
m_source_data.scaling_factor = m_model_object->instances.front()->scaling_factor;
|
m_source_data.scaling_factor = m_model_object->instances.front()->scaling_factor;
|
||||||
m_source_data.rotation = m_model_object->instances.front()->rotation;
|
m_source_data.rotation = m_model_object->instances.front()->rotation;
|
||||||
const float* first_vertex = m_model_object->volumes.front()->get_convex_hull().first_vertex();
|
const float* first_vertex = m_model_object->volumes.front()->get_convex_hull().first_vertex();
|
||||||
m_source_data.mesh_first_point = Pointf3(first_vertex[0], first_vertex[1], first_vertex[3]);
|
m_source_data.mesh_first_point = Pointf3(first_vertex[0], first_vertex[1], first_vertex[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the bounding boxes of each volume's convex hull is the same as before
|
// Check if the bounding boxes of each volume's convex hull is the same as before
|
||||||
@ -788,7 +788,7 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
|
|||||||
if (m_model_object->volumes.size() != m_source_data.bounding_boxes.size()
|
if (m_model_object->volumes.size() != m_source_data.bounding_boxes.size()
|
||||||
|| m_model_object->instances.front()->scaling_factor != m_source_data.scaling_factor
|
|| m_model_object->instances.front()->scaling_factor != m_source_data.scaling_factor
|
||||||
|| m_model_object->instances.front()->rotation != m_source_data.rotation)
|
|| m_model_object->instances.front()->rotation != m_source_data.rotation)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// now compare the bounding boxes:
|
// now compare the bounding boxes:
|
||||||
for (unsigned int i=0; i<m_model_object->volumes.size(); ++i)
|
for (unsigned int i=0; i<m_model_object->volumes.size(); ++i)
|
||||||
@ -805,6 +805,7 @@ bool GLGizmoFlatten::is_plane_update_necessary() const
|
|||||||
|
|
||||||
Pointf3 GLGizmoFlatten::get_flattening_normal() const {
|
Pointf3 GLGizmoFlatten::get_flattening_normal() const {
|
||||||
Pointf3 normal = m_normal;
|
Pointf3 normal = m_normal;
|
||||||
|
normal.rotate(-m_model_object->instances.front()->rotation);
|
||||||
m_normal = Pointf3(0.f, 0.f, 0.f);
|
m_normal = Pointf3(0.f, 0.f, 0.f);
|
||||||
return normal;
|
return normal;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user