Fixed transformation of the hollowed mesh to be used at frontend
Common gizmos data update is called from GLGizmoManager
This commit is contained in:
parent
46fdce1169
commit
3f73261fdb
5 changed files with 26 additions and 10 deletions
|
@ -326,18 +326,24 @@ bool CommonGizmosData::update_from_backend(GLCanvas3D& canvas)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_print_object_idx < 0)
|
||||
return old_po_idx != m_print_object_idx;
|
||||
|
||||
m_mesh = nullptr;
|
||||
// Load either the model_object mesh, or one provided by the backend
|
||||
// This mesh does not account for the possible Z up SLA offset.
|
||||
const SLAPrintObject* po = canvas.sla_print()->objects()[m_print_object_idx];
|
||||
// The backend mesh needs to be transformed and because a pointer to it is
|
||||
// saved, a copy is stored as a member (FIXME)
|
||||
if (m_print_object_idx >=0) {
|
||||
const SLAPrintObject* po = canvas.sla_print()->objects()[m_print_object_idx];
|
||||
if (po->is_step_done(slaposHollowing)) {
|
||||
m_backend_mesh_transformed = po->get_mesh_to_print();
|
||||
m_backend_mesh_transformed.transform(canvas.sla_print()->sla_trafo(*m_model_object).inverse());
|
||||
m_mesh = &m_backend_mesh_transformed;
|
||||
}
|
||||
}
|
||||
|
||||
if (po->is_step_done(slaposHollowing))
|
||||
m_mesh = &po->get_mesh_to_print();
|
||||
else
|
||||
if (! m_mesh) {
|
||||
m_mesh = &m_model_object->volumes.front()->mesh();
|
||||
m_backend_mesh_transformed.clear();
|
||||
}
|
||||
|
||||
m_model_object_id = m_model_object->id();
|
||||
|
||||
|
@ -348,7 +354,8 @@ bool CommonGizmosData::update_from_backend(GLCanvas3D& canvas)
|
|||
m_old_mesh = m_mesh;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return m_print_object_idx < 0 ? old_po_idx >=0 : false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -215,6 +215,7 @@ public:
|
|||
|
||||
private:
|
||||
const TriangleMesh* m_old_mesh;
|
||||
TriangleMesh m_backend_mesh_transformed;
|
||||
};
|
||||
|
||||
} // namespace GUI
|
||||
|
|
|
@ -76,8 +76,10 @@ void GLGizmoHollow::set_sla_support_data(ModelObject* model_object, const Select
|
|||
|
||||
if (model_object
|
||||
&& selection.is_from_single_instance()
|
||||
&& (m_c->update_from_backend(m_parent) || something_changed))
|
||||
&& (something_changed))
|
||||
{
|
||||
m_c->update_from_backend(m_parent);
|
||||
|
||||
// Cache the bb - it's needed for dealing with the clipping plane quite often
|
||||
// It could be done inside update_mesh but one has to account for scaling of the instance.
|
||||
m_c->m_active_instance_bb_radius = m_c->m_model_object->instance_bounding_box(m_c->m_active_instance).radius();
|
||||
|
@ -580,7 +582,7 @@ void GLGizmoHollow::update_hollowed_mesh(std::unique_ptr<TriangleMesh> &&mesh)
|
|||
{
|
||||
// Called from Plater when the UI job finishes
|
||||
/*m_c->m_cavity_mesh = std::move(mesh);
|
||||
|
||||
|
||||
if(m_c->m_cavity_mesh) {
|
||||
// First subtract the holes:
|
||||
if (! m_c->m_model_object->sla_drain_holes.empty()) {
|
||||
|
|
|
@ -1246,6 +1246,9 @@ void GLGizmoSlaSupports::reload_cache()
|
|||
|
||||
bool GLGizmoSlaSupports::has_backend_supports() const
|
||||
{
|
||||
if (! m_c->m_model_object)
|
||||
return false;
|
||||
|
||||
// find SlaPrintObject with this ID
|
||||
for (const SLAPrintObject* po : m_parent.sla_print()->objects()) {
|
||||
if (po->model_object()->id() == m_c->m_model_object->id())
|
||||
|
|
|
@ -348,6 +348,9 @@ void GLGizmosManager::set_sla_support_data(ModelObject* model_object)
|
|||
if (!m_enabled || m_gizmos.empty())
|
||||
return;
|
||||
|
||||
// Update common data for hollowing and sla support gizmos.
|
||||
m_common_gizmos_data->update_from_backend(m_parent);
|
||||
|
||||
dynamic_cast<GLGizmoSlaSupports*>(m_gizmos[SlaSupports].get())->set_sla_support_data(model_object, m_parent.get_selection());
|
||||
dynamic_cast<GLGizmoHollow*>(m_gizmos[Hollow].get())->set_sla_support_data(model_object, m_parent.get_selection());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue