Browse Source

minor code polishing

Julien Barrois 6 years ago
parent
commit
a2349e3780
1 changed files with 6 additions and 5 deletions
  1. 6 5
      src/Culling/babylon.ray.ts

+ 6 - 5
src/Culling/babylon.ray.ts

@@ -311,16 +311,17 @@ module BABYLON {
          * @return the distance from the ray origin to the intersection point if there's intersection, or -1 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 {
         intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number {
+            const o = this.origin;
             const u =  Tmp.Vector3[0];
             const u =  Tmp.Vector3[0];
+            const rsegb  = Tmp.Vector3[1];
+            const v =  Tmp.Vector3[2];
+            const w =  Tmp.Vector3[3];
+
             segb.subtractToRef(sega, u);
             segb.subtractToRef(sega, u);
 
 
-            const o = this.origin;
-            const p = Tmp.Vector3[1];
-            const v =  Tmp.Vector3[2];
             this.direction.scaleToRef(Ray.rayl, v);
             this.direction.scaleToRef(Ray.rayl, v);
-            o.addToRef(v, p);
+            o.addToRef(v, rsegb);
 
 
-            const w =  Tmp.Vector3[3];
             sega.subtractToRef(o, w);
             sega.subtractToRef(o, w);
 
 
             var a = Vector3.Dot(u, u);                  // always >= 0
             var a = Vector3.Dot(u, u);                  // always >= 0