mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-18 20:28:08 -06:00
Raycaster wrapper
The raycaster manages a MeshRaycaster object that the gizmo can ask to perform raycasts If the hollowed mesh tracker is enabled and the hollowed mesh is newly calculated/invalidated, the raycaster automatically updates.
This commit is contained in:
parent
81dba7677b
commit
bf734c8f68
2 changed files with 71 additions and 23 deletions
|
@ -17,9 +17,10 @@ CommonGizmosDataPool::CommonGizmosDataPool(GLCanvas3D* canvas)
|
|||
m_data[c::SelectionInfo].reset( new SelectionInfo(this));
|
||||
m_data[c::InstancesHider].reset( new InstancesHider(this));
|
||||
m_data[c::HollowedMesh].reset( new HollowedMesh(this));
|
||||
//m_data[c::ClippingPlaneWrapper].reset(new ClippingPlaneWrapper(this));
|
||||
m_data[c::Raycaster].reset( new Raycaster(this));
|
||||
//m_data[c::ObjectClipper].reset(new ClippingPlaneWrapper(this));
|
||||
//m_data[c::SupportsClipper].reset( new SupportsClipper(this));
|
||||
//m_data[c::MeshRaycaster].reset( new Raycaster(this));
|
||||
|
||||
}
|
||||
|
||||
void CommonGizmosDataPool::update(CommonGizmosDataID required)
|
||||
|
@ -50,6 +51,13 @@ HollowedMesh* CommonGizmosDataPool::hollowed_mesh()
|
|||
return hol_mesh->is_valid() ? hol_mesh : nullptr;
|
||||
}
|
||||
|
||||
Raycaster* CommonGizmosDataPool::raycaster()
|
||||
{
|
||||
Raycaster* rc = dynamic_cast<Raycaster*>(m_data[CommonGizmosDataID::Raycaster].get());
|
||||
assert(rc);
|
||||
return rc->is_valid() ? rc : nullptr;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Check the required resources one by one and return true if all
|
||||
// dependencies are met.
|
||||
|
@ -180,5 +188,36 @@ const TriangleMesh* HollowedMesh::get_hollowed_mesh() const
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Raycaster::on_update()
|
||||
{
|
||||
const ModelObject* mo = get_pool()->selection_info()->model_object();
|
||||
|
||||
if (! mo)
|
||||
return;
|
||||
|
||||
const TriangleMesh* mesh = &mo->volumes.front()->mesh();
|
||||
const HollowedMesh* hollowed_mesh_tracker = get_pool()->hollowed_mesh();
|
||||
if (hollowed_mesh_tracker && hollowed_mesh_tracker->get_hollowed_mesh())
|
||||
mesh = hollowed_mesh_tracker->get_hollowed_mesh();
|
||||
|
||||
if (mesh != m_old_mesh) {
|
||||
m_raycaster.reset(new MeshRaycaster(*mesh));
|
||||
m_old_mesh = mesh;
|
||||
}
|
||||
}
|
||||
|
||||
void Raycaster::on_release()
|
||||
{
|
||||
m_raycaster.reset();
|
||||
m_old_mesh = nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} // namespace GUI
|
||||
} // namespace Slic3r
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue