Ver código fonte

removed temp var in transformCoordinates computation in the render loop

jbousquie 9 anos atrás
pai
commit
a9e56ba780
1 arquivos alterados com 6 adições e 1 exclusões
  1. 6 1
      src/Particles/babylon.solidParticleSystem.ts

+ 6 - 1
src/Particles/babylon.solidParticleSystem.ts

@@ -57,6 +57,7 @@ module BABYLON {
         private _cosPitch: number = 0.0;
         private _sinYaw: number = 0.0;
         private _cosYaw: number = 0.0;
+        private _w: number = 0.0;
 
 
         constructor(name: string, scene: Scene, options?: { updatable?: boolean }) {
@@ -398,7 +399,11 @@ module BABYLON {
                     this._vertex.y *= this._particle.scale.y;
                     this._vertex.z *= this._particle.scale.z;
 
-                    Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
+                    //Vector3.TransformCoordinatesToRef(this._vertex, this._rotMatrix, this._rotated);
+                    this._w = (this._vertex.x * this._rotMatrix.m[3]) + (this._vertex.y * this._rotMatrix.m[7]) + (this._vertex.z * this._rotMatrix.m[11]) + this._rotMatrix.m[15];
+                    this._rotated.x = ( (this._vertex.x * this._rotMatrix.m[0]) + (this._vertex.y * this._rotMatrix.m[4]) + (this._vertex.z * this._rotMatrix.m[8]) + this._rotMatrix.m[12] ) / this._w;
+                    this._rotated.y = ( (this._vertex.x * this._rotMatrix.m[1]) + (this._vertex.y * this._rotMatrix.m[5]) + (this._vertex.z * this._rotMatrix.m[9]) + this._rotMatrix.m[13] ) / this._w;
+                    this._rotated.z = ( (this._vertex.x * this._rotMatrix.m[2]) + (this._vertex.y * this._rotMatrix.m[6]) + (this._vertex.z * this._rotMatrix.m[10]) + this._rotMatrix.m[14] ) / this._w;
 
                     this._positions32[idx] = this._particle.position.x + this._cam_axisX.x * this._rotated.x + this._cam_axisY.x * this._rotated.y + this._cam_axisZ.x * this._rotated.z;
                     this._positions32[idx + 1] = this._particle.position.y + this._cam_axisX.y * this._rotated.x + this._cam_axisY.y * this._rotated.y + this._cam_axisZ.y * this._rotated.z;