ソースを参照

Fix for wrong intersection result

Preventing selection of a face that is behind the ray's origin position.
The problem is that if the origin point is INSIDE a mesh, the faces behind the point will be selected as well. The Distance received from the PickingInfo will still be positive, due to the new initialization in the scene pick function.
Raanan Weber 11 年 前
コミット
8494252f3f
1 ファイル変更2 行追加1 行削除
  1. 2 1
      Babylon/Mesh/babylon.subMesh.ts

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