diff --git a/src/bounce/collision/gjk/gjk.cpp b/src/bounce/collision/gjk/gjk.cpp index d31dd27..4210c3a 100644 --- a/src/bounce/collision/gjk/gjk.cpp +++ b/src/bounce/collision/gjk/gjk.cpp @@ -249,11 +249,6 @@ void b3Simplex::Solve3(const b3Vec3& Q) b3Barycentric(wBC, B.point, C.point, Q); b3Barycentric(wCA, C.point, A.point, Q); - // Test edge regions - float32 wABC[4]; - b3Barycentric(wABC, A.point, B.point, C.point, Q); - - // Test vertex regions // R A if (wAB[1] <= 0.0f && wCA[0] <= 0.0f) { @@ -282,6 +277,9 @@ void b3Simplex::Solve3(const b3Vec3& Q) } // Test edge regions + float32 wABC[4]; + b3Barycentric(wABC, A.point, B.point, C.point, Q); + // This is used to help testing if the face degenerates // into an edge. float32 area = wABC[3]; @@ -363,19 +361,6 @@ void b3Simplex::Solve4(const b3Vec3& Q) b3Barycentric(wAD, A.point, D.point, Q); b3Barycentric(wCD, C.point, D.point, Q); b3Barycentric(wDB, D.point, B.point, Q); - - // Test edge regions - float32 wACB[4], wABD[4], wADC[4], wBCD[4]; - b3Barycentric(wACB, A.point, C.point, B.point, Q); - b3Barycentric(wABD, A.point, B.point, D.point, Q); - b3Barycentric(wADC, A.point, D.point, C.point, Q); - b3Barycentric(wBCD, B.point, C.point, D.point, Q); - - // Test face regions - float32 wABCD[5]; - b3Barycentric(wABCD, A.point, B.point, C.point, D.point, Q); - - // Test vertex regions // R A if (wAB[1] <= 0.0f && wAC[1] <= 0.0f && wAD[1] <= 0.0f) @@ -414,7 +399,12 @@ void b3Simplex::Solve4(const b3Vec3& Q) } // Test edge regions - + float32 wACB[4], wABD[4], wADC[4], wBCD[4]; + b3Barycentric(wACB, A.point, C.point, B.point, Q); + b3Barycentric(wABD, A.point, B.point, D.point, Q); + b3Barycentric(wADC, A.point, D.point, C.point, Q); + b3Barycentric(wBCD, B.point, C.point, D.point, Q); + // R AB if (wABD[2] <= 0.0f && wACB[1] <= 0.0f && wAB[0] > 0.0f && wAB[1] > 0.0f) { @@ -500,7 +490,9 @@ void b3Simplex::Solve4(const b3Vec3& Q) } // Test face regions - + float32 wABCD[5]; + b3Barycentric(wABCD, A.point, B.point, C.point, D.point, Q); + // R ACB if (wABCD[3] <= 0.0f && wACB[0] > 0.0f && wACB[1] > 0.0f && wACB[2] > 0.0f) { diff --git a/src/bounce/dynamics/joints/revolute_joint.cpp b/src/bounce/dynamics/joints/revolute_joint.cpp index 2c75321..d91d979 100644 --- a/src/bounce/dynamics/joints/revolute_joint.cpp +++ b/src/bounce/dynamics/joints/revolute_joint.cpp @@ -164,9 +164,9 @@ static B3_FORCE_INLINE b3Vec4 q_to_v(const b3Quat& q) return b3Vec4(q.w, q.x, q.y, q.z); } -static b3Mat34 P = P_mat(); -static b3Mat43 PT = b3Transpose(P); -static b3Mat24 P_hinge = P_hinge_mat(); +static const b3Mat34 P = P_mat(); +static const b3Mat43 PT = b3Transpose(P); +static const b3Mat24 P_hinge = P_hinge_mat(); void b3RevoluteJointDef::Initialize(b3Body* bA, b3Body* bB, const b3Vec3& axis, const b3Vec3& anchor, diff --git a/src/bounce/dynamics/joints/weld_joint.cpp b/src/bounce/dynamics/joints/weld_joint.cpp index 1df83c3..13e7d17 100644 --- a/src/bounce/dynamics/joints/weld_joint.cpp +++ b/src/bounce/dynamics/joints/weld_joint.cpp @@ -86,9 +86,9 @@ static b3Vec4 q_to_v(const b3Quat& q) return b3Vec4(q.w, q.x, q.y, q.z); } -static b3Mat34 P = P_mat(); -static b3Mat43 PT = b3Transpose(P); -static b3Mat34 P_lock = P_lock_mat(); +static const b3Mat34 P = P_mat(); +static const b3Mat43 PT = b3Transpose(P); +static const b3Mat34 P_lock = P_lock_mat(); void b3WeldJointDef::Initialize(b3Body* bA, b3Body* bB, const b3Vec3& anchor) {