ソースを参照

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);
         }
     }
-}
+}