소스 검색

Merge pull request #349 from raananw/master

Fix for wrong intersection result
David Catuhe 10 년 전
부모
커밋
0c3607ed1a
2개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      Babylon/Mesh/babylon.subMesh.js
  2. 2 1
      Babylon/Mesh/babylon.subMesh.ts

+ 1 - 0
Babylon/Mesh/babylon.subMesh.js

@@ -114,6 +114,7 @@
                 var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
 
                 if (currentIntersectInfo) {
+                    if(currentIntersectInfo.distance < 0 ) continue;
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
                         intersectInfo.faceId = index / 3;

+ 2 - 1
Babylon/Mesh/babylon.subMesh.ts

@@ -125,6 +125,7 @@
                 var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
 
                 if (currentIntersectInfo) {
+                    if(currentIntersectInfo.distance < 0 ) continue;
                     if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
                         intersectInfo = currentIntersectInfo;
                         intersectInfo.faceId = index / 3;
@@ -180,4 +181,4 @@
             return new BABYLON.SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
         }
     }
-}
+}