FIX:Do not create a new MeshRaycaster repeatedly

jira: STUDIO-10905
Change-Id: I0a666ab7f9167c1bbd60f4cd6a5d0c78c9143275
(cherry picked from commit 51b5777b608bbf2a8bb8efa3c2d03bf548b17a6d)
This commit is contained in:
zhou.xu
2025-03-17 20:02:42 +08:00
committed by Noisyfox
parent 907573a158
commit 596c897c80

View File

@@ -50,8 +50,7 @@ bool GLGizmoMeshBoolean::gizmo_event(SLAGizmoEventType action, const Vec2d& mous
// Cast a ray on all meshes, pick the closest hit and save it for the respective mesh
for (int mesh_id = 0; mesh_id < int(trafo_matrices.size()); ++mesh_id) {
MeshRaycaster mesh_raycaster = MeshRaycaster(mo->volumes[mesh_id]->mesh_ptr());
if (mesh_raycaster.unproject_on_mesh(mouse_position, trafo_matrices[mesh_id], camera, hit, normal,
if (m_c->raycaster()->raycasters()[mesh_id] ->unproject_on_mesh(mouse_position, trafo_matrices[mesh_id], camera, hit, normal,
m_c->object_clipper()->get_clipping_plane(), &facet)) {
// Is this hit the closest to the camera so far?
double hit_squared_distance = (camera.get_position() - trafo_matrices[mesh_id] * hit.cast<double>()).squaredNorm();