Forráskód Böngészése

fix : update() method now without memory re-allocation + vectors3 hard copy on constructor

jbousquie 10 éve
szülő
commit
6aa7eb44c8
1 módosított fájl, 8 hozzáadás és 8 törlés
  1. 8 8
      Babylon/Math/babylon.math.ts

+ 8 - 8
Babylon/Math/babylon.math.ts

@@ -3282,7 +3282,9 @@
         private _binormals = new Array<Vector3>();
 
         constructor(public path: Vector3[], firstNormal?: Vector3) {
-            this._copyPath(path);
+            for (var p = 0; p < path.length; p++) {
+                this._curve[p] = path[p].clone(); // hard copy
+            }  
             this._compute(firstNormal);
         }
 
@@ -3307,17 +3309,15 @@
         }
 
         public update(path: Vector3[], firstNormal?: Vector3): Path3D {
-            this._copyPath(path);
+            for (var p = 0; p < path.length; p++) {
+                this._curve[p].x = path[p].x;
+                this._curve[p].y = path[p].y;
+                this._curve[p].z = path[p].z;
+            }  
             this._compute(firstNormal);
             return this;
         }
 
-        private _copyPath(path: Vector3[]) {
-            for (var p = 0; p < path.length; p++) {
-                this._curve[p] = path[p].clone(); // hard copy
-            }            
-        }
-
         // private function compute() : computes tangents, normals and binormals
         private _compute(firstNormal) {
             var l = this._curve.length;