FIX:Do not create a new MeshRaycaster repeatedly

jira: STUDIO-10905
Change-Id: I0a666ab7f9167c1bbd60f4cd6a5d0c78c9143275
This commit is contained in:
zhou.xu 2025-03-17 20:02:42 +08:00 committed by lane.wei
parent 193caabdc7
commit 51b5777b60
1 changed files with 1 additions and 2 deletions

View File

@ -87,8 +87,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 // 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) { for (int mesh_id = 0; mesh_id < int(trafo_matrices.size()); ++mesh_id) {
MeshRaycaster mesh_raycaster = MeshRaycaster(mo->volumes[mesh_id]->mesh()); if (m_c->raycaster()->raycasters()[mesh_id] ->unproject_on_mesh(mouse_position, trafo_matrices[mesh_id], camera, hit, normal,
if (mesh_raycaster.unproject_on_mesh(mouse_position, trafo_matrices[mesh_id], camera, hit, normal,
m_c->object_clipper()->get_clipping_plane(), &facet)) { m_c->object_clipper()->get_clipping_plane(), &facet)) {
// Is this hit the closest to the camera so far? // 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(); double hit_squared_distance = (camera.get_position() - trafo_matrices[mesh_id] * hit.cast<double>()).squaredNorm();