Просмотр исходного кода

Ray.intersectSegment returns -1 in case of no intersection

nockawa 9 лет назад
Родитель
Сommit
035d795760
2 измененных файлов с 3 добавлено и 3 удалено
  1. 2 2
      src/Culling/babylon.ray.ts
  2. 1 1
      src/Mesh/babylon.subMesh.ts

+ 2 - 2
src/Culling/babylon.ray.ts

@@ -201,7 +201,7 @@
          * @param sega the first point of the segment to test the intersection against
          * @param segb the second point of the segment to test the intersection against
          * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
-         * @return the distance from the ray origin to the intersection point if there's intersection, or undefined if there's no intersection
+         * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
          */
         intersectionSegment(sega: Vector3, segb: Vector3, threshold: number) : number
         {
@@ -275,7 +275,7 @@
             if (isIntersected) {
                 return tc;
             }
-            return undefined;
+            return -1;
         }
         
         // Statics

+ 1 - 1
src/Mesh/babylon.subMesh.ts

@@ -144,7 +144,7 @@
                     var p1 = positions[indices[index + 1]];
 
                     var length = ray.intersectionSegment(p0, p1, lineMesh.intersectionThreshold);
-                    if (!length) {
+                    if (length<0) {
                         continue;
                     }