diff --git a/examples/example/scripts/rayPickExample.js b/examples/example/scripts/rayPickExample.js index b0b7c24fef..e573226f19 100644 --- a/examples/example/scripts/rayPickExample.js +++ b/examples/example/scripts/rayPickExample.js @@ -18,20 +18,22 @@ function mouseMoveEvent(event) { print("computePickRay origin=" + pickRay.origin.x + ", " + pickRay.origin.y + ", " + pickRay.origin.z); print("computePickRay direction=" + pickRay.direction.x + ", " + pickRay.direction.y + ", " + pickRay.direction.z); var pickRay = Camera.computePickRay(event.x, event.y); - intersection = Entities.findRayIntersection(pickRay); + intersection = Entities.findRayIntersection(pickRay, true); // to get precise picking if (!intersection.accurate) { print(">>> NOTE: intersection not accurate. will try calling Entities.findRayIntersectionBlocking()"); - intersection = Entities.findRayIntersectionBlocking(pickRay); + intersection = Entities.findRayIntersectionBlocking(pickRay, true); // to get precise picking print(">>> AFTER BLOCKING CALL intersection.accurate=" + intersection.accurate); } if (intersection.intersects) { - print("intersection entityID.id=" + intersection.entityID.id); + print("intersection entityID=" + intersection.entityID); print("intersection properties.modelURL=" + intersection.properties.modelURL); print("intersection face=" + intersection.face); print("intersection distance=" + intersection.distance); - print("intersection intersection.x/y/z=" + intersection.intersection.x + ", " + print("intersection intersection.x/y/z=" + intersection.intersection.x + ", " + intersection.intersection.y + ", " + intersection.intersection.z); + print("intersection surfaceNormal.x/y/z=" + intersection.surfaceNormal.x + ", " + + intersection.surfaceNormal.y + ", " + intersection.surfaceNormal.z); } } diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index 22d1a5a5e5..ee40dcb913 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -502,7 +502,7 @@ bool Model::findRayIntersectionAgainstSubMeshes(const glm::vec3& origin, const g recalculateMeshBoxes(pickAgainstTriangles); } - foreach(const AABox& subMeshBox, _calculatedMeshBoxes) { + foreach (const AABox& subMeshBox, _calculatedMeshBoxes) { if (subMeshBox.findRayIntersection(origin, direction, distanceToSubMesh, subMeshFace, subMeshSurfaceNormal)) { if (distanceToSubMesh < bestDistance) { diff --git a/libraries/shared/src/GeometryUtil.cpp b/libraries/shared/src/GeometryUtil.cpp index a5f499f3d5..9d109e5970 100644 --- a/libraries/shared/src/GeometryUtil.cpp +++ b/libraries/shared/src/GeometryUtil.cpp @@ -265,7 +265,7 @@ glm::vec3 Triangle::getNormal() const { result.x = (u.z * v.x) - (u.x * v.z); result.x = (u.x * v.y) - (u.y * v.x); - return result; + return glm::normalize(result); } bool findRayTriangleIntersection(const glm::vec3& origin, const glm::vec3& direction,