SlaSupports gizmo - show holes position even when user did not Preview the drilled mesh

This commit is contained in:
Lukas Matena 2020-02-04 12:18:57 +01:00
parent 49c5822be4
commit 58b5e75a9c
3 changed files with 9 additions and 4 deletions

View File

@ -358,12 +358,14 @@ bool CommonGizmosData::update_from_backend(GLCanvas3D& canvas, ModelObject* mode
m_backend_mesh_transformed = po->get_mesh_to_print(); m_backend_mesh_transformed = po->get_mesh_to_print();
m_backend_mesh_transformed.transform(canvas.sla_print()->sla_trafo(*m_model_object).inverse()); m_backend_mesh_transformed.transform(canvas.sla_print()->sla_trafo(*m_model_object).inverse());
m_mesh = &m_backend_mesh_transformed; m_mesh = &m_backend_mesh_transformed;
m_has_drilled_mesh = true;
} }
} }
if (! m_mesh) { if (! m_mesh) {
m_mesh = &m_model_object->volumes.front()->mesh(); m_mesh = &m_model_object->volumes.front()->mesh();
m_backend_mesh_transformed.clear(); m_backend_mesh_transformed.clear();
m_has_drilled_mesh = false;
} }
m_model_object_id = m_model_object->id(); m_model_object_id = m_model_object->id();

View File

@ -227,10 +227,13 @@ public:
m_clipping_plane_distance = m_clipping_plane_distance_stash; m_clipping_plane_distance = m_clipping_plane_distance_stash;
} }
bool has_drilled_mesh() const { return m_has_drilled_mesh; }
private: private:
const TriangleMesh* m_old_mesh; const TriangleMesh* m_old_mesh;
TriangleMesh m_backend_mesh_transformed; TriangleMesh m_backend_mesh_transformed;
float m_clipping_plane_distance_stash = 0.f; float m_clipping_plane_distance_stash = 0.f;
bool m_has_drilled_mesh = false;
}; };
} // namespace GUI } // namespace GUI

View File

@ -335,7 +335,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
} }
// Now render the drain holes: // Now render the drain holes:
/*if (! m_c->m_cavity_mesh) { if (! m_c->has_drilled_mesh()) {
render_color[0] = 0.7f; render_color[0] = 0.7f;
render_color[1] = 0.7f; render_color[1] = 0.7f;
render_color[2] = 0.7f; render_color[2] = 0.7f;
@ -370,7 +370,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glFrontFace(GL_CCW); glFrontFace(GL_CCW);
glsafe(::glPopMatrix()); glsafe(::glPopMatrix());
} }
}*/ }
if (!picking) if (!picking)
glsafe(::glDisable(GL_LIGHTING)); glsafe(::glDisable(GL_LIGHTING));
@ -414,14 +414,14 @@ bool GLGizmoSlaSupports::unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec
// In case the hollowed and drilled mesh is available, we can allow // In case the hollowed and drilled mesh is available, we can allow
// placing points in holes, because they should never end up // placing points in holes, because they should never end up
// on surface that's been drilled away. // on surface that's been drilled away.
/*if (! m_c->m_cavity_mesh) { if (! m_c->has_drilled_mesh()) {
for (const sla::DrainHole& hole : m_c->m_model_object->sla_drain_holes) { for (const sla::DrainHole& hole : m_c->m_model_object->sla_drain_holes) {
if (hole.is_inside(hit)) { if (hole.is_inside(hit)) {
in_hole = true; in_hole = true;
break; break;
} }
} }
}*/ }
if (! in_hole) { if (! in_hole) {
// Return both the point and the facet normal. // Return both the point and the facet normal.
pos_and_normal = std::make_pair(hit, normal); pos_and_normal = std::make_pair(hit, normal);