From 925d5d36acfb6a51074383ae36ed8f900f712ca9 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Fri, 18 Mar 2016 12:20:45 -0700 Subject: [PATCH] clean up the recalculateMeshBoxes() calls in findRayIntersectionAgainstSubMeshes() --- libraries/render-utils/src/Model.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 8b6cc41f35..ab595ed879 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -252,25 +252,18 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g // If we hit the models box, then consider the submeshes... _mutex.lock(); - - if (!_calculatedMeshBoxesValid) { + if (!_calculatedMeshBoxesValid || (pickAgainstTriangles && !_calculatedMeshTrianglesValid)) { recalculateMeshBoxes(pickAgainstTriangles); } - foreach (const AABox& subMeshBox, _calculatedMeshBoxes) { + for (const auto& subMeshBox : _calculatedMeshBoxes) { if (subMeshBox.findRayIntersection(origin, direction, distanceToSubMesh, subMeshFace, subMeshSurfaceNormal)) { if (distanceToSubMesh < bestDistance) { if (pickAgainstTriangles) { - if (!_calculatedMeshTrianglesValid) { - recalculateMeshBoxes(pickAgainstTriangles); - } // check our triangles here.... const QVector& meshTriangles = _calculatedMeshTriangles[subMeshIndex]; - int t = 0; - foreach (const Triangle& triangle, meshTriangles) { - t++; - + for(const auto& triangle : meshTriangles) { float thisTriangleDistance; if (findRayTriangleIntersection(origin, direction, triangle, thisTriangleDistance)) { if (thisTriangleDistance < bestDistance) {