Procházet zdrojové kódy

Merge pull request #444 from blackberry-gaming/next-kcunney

General cleanup, and unit test fixes.
Sean Paul Taylor před 13 roky
rodič
revize
7c12641f34

+ 1 - 1
gameplay/src/MathUtil.h

@@ -19,7 +19,7 @@ private:
 	inline static void subtractMatrix(const float* m1, const float* m2, float* dst);
 	inline static void transformVectorMatrix(const float* m, float x, float y, float z, float w, float* dst);
 	inline static void transformVectorMatrix(const float* m, const float* v, float* dst);
-	inline static void transpose(const float* m, float* dst);
+	inline static void transposeMatrix(const float* m, float* dst);
 
 	/** Vector3 **/
 	inline static void crossVector3(const float* v1, const float* v2, float* dst);

+ 1 - 1
gameplay/src/MathUtil.inl

@@ -146,7 +146,7 @@ inline void MathUtil::transformVectorMatrix(const float* m, const float* v, floa
 	dst[3] = v[0] * m[3] + v[1] * m[7] + v[2] * m[11] + v[3] * m[15];
 }
 
-inline void MathUtil::transpose(const float* m, float* dst)
+inline void MathUtil::transposeMatrix(const float* m, float* dst)
 {
 	float t[16] = {
 		m[0], m[4], m[8], m[12],

+ 2 - 1
gameplay/src/MathUtilNeon.inl

@@ -185,7 +185,7 @@ inline void MathUtil::transformVectorMatrix(const float* m, const float* v, floa
 	);
 }
 
-inline void MathUtil::transpose(const float* m, float* dst)
+inline void MathUtil::transposeMatrix(const float* m, float* dst)
 {
 	asm volatile(
 		"vld4.32 {d0[0], d2[0], d4[0], d6[0]}, [%1]! 	\n\t" // DST->M[m0, m4, m8, m12] = M[m0-m3]
@@ -225,4 +225,5 @@ inline void MathUtil::crossVector3(const float* v1, const float* v2, float* dst)
 		: "q0", "q1", "q2", "memory"
 	);
 }
+
 }

+ 1 - 1
gameplay/src/Matrix.cpp

@@ -893,7 +893,7 @@ void Matrix::transpose(Matrix* dst) const
 {
     GP_ASSERT(dst);
 
-    MathUtil::transpose(m, dst->m);
+    MathUtil::transposeMatrix(m, dst->m);
 }
 
 }

+ 2 - 2
gameplay/src/Plane.cpp

@@ -63,7 +63,7 @@ void Plane::intersection(const Plane& p1, const Plane& p2, const Plane& p3, Vect
                 p1._normal.z * p3._normal.y) + p3._normal.x * (p1._normal.y * p2._normal.z - p1._normal.z * p2._normal.y);
 
     // If the determinant is zero, then the planes do not all intersect.
-    if (det == 0.0f)
+    if (fabs(det) <= MATH_EPSILON)
         return;
 
     // Create 3 points, one on each plane.
@@ -161,7 +161,7 @@ float Plane::intersects(const Frustum& frustum) const
 float Plane::intersects(const Plane& plane) const
 {
     // Check if the planes intersect.
-    if (!isParallel(plane))
+    if ((_normal.x == plane._normal.x && _normal.y == plane._normal.y && _normal.z == plane._normal.z) || !isParallel(plane))
     {
         return Plane::INTERSECTS_INTERSECTING;
     }

+ 1 - 36
gameplay/src/Vector3.cpp

@@ -172,42 +172,7 @@ void Vector3::cross(const Vector3& v)
 void Vector3::cross(const Vector3& v1, const Vector3& v2, Vector3* dst)
 {
     GP_ASSERT(dst);
-/*
-#ifdef USE_NEON
-
-    asm volatile(
-		"vld1.32 {d1[1]},  [%1] 		\n\t" //
-		"vld1.32 {d0},     [%2]         \n\t" //
-		"vmov.f32 s2, s1                \n\t" // q0 = (v1y, v1z, v1z, v1x)
-
-		"vld1.32 {d2[1]},  [%3]	    	\n\t" //
-		"vld1.32 {d3},     [%4]         \n\t" //
-		"vmov.f32 s4, s7          		\n\t" // q1 = (v2z, v2x, v2y, v2z)
-
-		"vmul.f32 d4, d0, d2  			\n\t" // x = v1y * v2z, y = v1z * v2x
-		"vmls.f32 d4, d1, d3  			\n\t" // x -= v1z * v2y, y-= v1x - v2z
-
-		"vmul.f32 d5, d3, d1[1]			\n\t" // z = v1x * v2y
-		"vmls.f32 d5, d0, d2[1]         \n\t" // z-= v1y * vx
-
-		"vst1.32 {d4}, 	  [%0]!    		\n\t" // V[x, y]
-		"vst1.32 {d5[0]}, [%0]     		\n\t" // V[z]
-		:
-		: "r"(dst), "r"(&v1), "r"(&(v1.y)), "r"(&v2), "r"(&(v2.y))
-		: "q0", "q1", "q2", "memory"
-	);
-
-#else
-
-    float x = (v1.y * v2.z) - (v1.z * v2.y);
-    float y = (v1.z * v2.x) - (v1.x * v2.z);
-    float z = (v1.x * v2.y) - (v1.y * v2.x);
-    dst->x = x;
-    dst->y = y;
-    dst->z = z;
-
-#endif
-*/
+
     MathUtil::crossVector3((const float*)&v1, (const float*)&v2, (float*)dst);
 }