Skip to content

Commit

Permalink
Merge pull request BabylonJS#916 from jbousquie/fix.TmpVarsInsertion
Browse files Browse the repository at this point in the history
Fix.tmp vars insertion
  • Loading branch information
deltakosh committed Jan 18, 2016
2 parents 62102d9 + cb17f05 commit 2ec9a09
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/Math/babylon.math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1111,13 +1111,13 @@
var t = 0.0;
var sign = -1.0;
var nbRevert = 0;
var cross: Vector3 = Vector3.Zero();
var cross: Vector3 = Tmp.Vector3[0];
var dot = 0.0;

// step 1 : rotation around w
// Rv3(u) = u1, and u1 belongs to plane xOz
// Rv3(w) = w1 = w invariant
var u1: Vector3;
var u1: Vector3 = Tmp.Vector3[1];
if (Tools.WithinEpsilon(w.z, 0, Engine.Epsilon)) {
z = 1.0;
}
Expand All @@ -1130,7 +1130,9 @@
z = Math.sqrt(1 / (1 + t * t));
}

u1 = new Vector3(x, y, z);
u1.x = x;
u1.y = y;
u1.z = z;
u1.normalize();
Vector3.CrossToRef(u, u1, cross); // returns same direction as w (=local z) if positive angle : cross(source, image)
cross.normalize();
Expand All @@ -1151,8 +1153,8 @@
// step 2 : rotate around u1
// Ru1(w1) = Ru1(w) = w2, and w2 belongs to plane xOz
// u1 is yet in xOz and invariant by Ru1, so after this step u1 and w2 will be in xOz
var w2: Vector3;
var v2: Vector3;
var w2: Vector3 = Tmp.Vector3[2];
var v2: Vector3 = Tmp.Vector3[3];
x = 0.0;
y = 0.0;
z = 0.0;
Expand All @@ -1166,9 +1168,11 @@
z = Math.sqrt(1 / (1 + t * t));
}

w2 = new Vector3(x, y, z);
w2.x = x;
w2.y = y;
w2.z = z;
w2.normalize();
v2 = Vector3.Cross(w2, u1); // v2 image of v1 through rotation around u1
Vector3.CrossToRef(w2, u1, v2); // v2 image of v1 through rotation around u1
v2.normalize();
Vector3.CrossToRef(w, w2, cross); // returns same direction as u1 (=local x) if positive angle : cross(source, image)
cross.normalize();
Expand Down Expand Up @@ -3621,7 +3625,8 @@
public static Int: number[] = [0, 0, 0, 0, 0, 0]; // 6 temp integers at once should be enough
public static Float: number[] = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; // 6 temp floats at once should be enough
public static Vector2: Vector2[] = [Vector2.Zero(), Vector2.Zero(), Vector2.Zero()]; // 3 temp Vector2 at once should be enough
public static Vector3: Vector3[] = [Vector3.Zero(), Vector3.Zero(), Vector3.Zero()]; // 3 temp Vector3 at once should be enough
public static Vector3: Vector3[] = [Vector3.Zero(), Vector3.Zero(), Vector3.Zero()
, Vector3.Zero(), Vector3.Zero(), Vector3.Zero()]; // 6 temp Vector3 at once should be enough
public static Vector4: Vector4[] = [Vector4.Zero(), Vector4.Zero(), Vector4.Zero()]; // 3 temp Vector4 at once should be enough
public static Quaternion: Quaternion[] = [new Quaternion(0, 0, 0, 0)]; // 1 temp Quaternion at once should be enough
public static Matrix: Matrix[] = [Matrix.Zero(), Matrix.Zero(),
Expand All @@ -3630,4 +3635,3 @@
Matrix.Zero(), Matrix.Zero()]; // 6 temp Matrices at once should be enough
}
}

0 comments on commit 2ec9a09

Please sign in to comment.