Преглед изворни кода

Renove unnecessary Ray.Transform

David Catuhe пре 7 година
родитељ
комит
baa64d2c97
3 измењених фајлова са 2692 додато и 2676 уклоњено
  1. 1338 1337
      dist/preview release/babylon.d.ts
  2. 1338 1337
      dist/preview release/babylon.module.d.ts
  3. 16 2
      src/babylon.scene.ts

Разлика између датотеке није приказан због своје велике величине
+ 1338 - 1337
dist/preview release/babylon.d.ts


Разлика између датотеке није приказан због своје велике величине
+ 1338 - 1337
dist/preview release/babylon.module.d.ts


+ 16 - 2
src/babylon.scene.ts

@@ -4094,6 +4094,8 @@
             return this._internalPickSprites(ray, predicate, fastCheck, camera);
         }
 
+        private _cachedRayForTransform: Ray;
+
         /** Use the given ray to pick a mesh in the scene
          * @param ray The ray to use to pick meshes
          * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
@@ -4105,7 +4107,13 @@
                     this._pickWithRayInverseMatrix = Matrix.Identity();
                 }
                 world.invertToRef(this._pickWithRayInverseMatrix);
-                return Ray.Transform(ray, this._pickWithRayInverseMatrix);
+
+                if (!this._cachedRayForTransform) {
+                    this._cachedRayForTransform = new Ray(Vector3.Zero(), Vector3.Zero());
+                }
+                
+                Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);
+                return this._cachedRayForTransform;
             }, predicate, fastCheck);
         }
 
@@ -4131,7 +4139,13 @@
                     this._pickWithRayInverseMatrix = Matrix.Identity();
                 }
                 world.invertToRef(this._pickWithRayInverseMatrix);
-                return Ray.Transform(ray, this._pickWithRayInverseMatrix);
+
+                if (!this._cachedRayForTransform) {
+                    this._cachedRayForTransform = new Ray(Vector3.Zero(), Vector3.Zero());
+                }
+                
+                Ray.TransformToRef(ray, this._pickWithRayInverseMatrix, this._cachedRayForTransform);
+                return this._cachedRayForTransform;
             }, predicate);
         }