diff --git a/cocos/math/Mat4.cpp b/cocos/math/Mat4.cpp index 1e3dc5a972..0062888a87 100644 --- a/cocos/math/Mat4.cpp +++ b/cocos/math/Mat4.cpp @@ -414,7 +414,7 @@ void Mat4::add(float scalar) void Mat4::add(float scalar, Mat4* dst) { GP_ASSERT(dst); -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::addMatrix(col, scalar, dst->col); #else MathUtil::addMatrix(m, scalar, dst->m); @@ -429,7 +429,7 @@ void Mat4::add(const Mat4& mat) void Mat4::add(const Mat4& m1, const Mat4& m2, Mat4* dst) { GP_ASSERT(dst); -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::addMatrix(m1.col, m2.col, dst->col); #else MathUtil::addMatrix(m1.m, m2.m, dst->m); @@ -706,7 +706,7 @@ void Mat4::multiply(float scalar, Mat4* dst) const void Mat4::multiply(const Mat4& m, float scalar, Mat4* dst) { GP_ASSERT(dst); -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::multiplyMatrix(m.col, scalar, dst->col); #else MathUtil::multiplyMatrix(m.m, scalar, dst->m); @@ -721,7 +721,7 @@ void Mat4::multiply(const Mat4& mat) void Mat4::multiply(const Mat4& m1, const Mat4& m2, Mat4* dst) { GP_ASSERT(dst); -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::multiplyMatrix(m1.col, m2.col, dst->col); #else MathUtil::multiplyMatrix(m1.m, m2.m, dst->m); @@ -730,7 +730,7 @@ void Mat4::multiply(const Mat4& m1, const Mat4& m2, Mat4* dst) void Mat4::negate() { -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::negateMatrix(col, col); #else MathUtil::negateMatrix(m, m); @@ -886,7 +886,7 @@ void Mat4::subtract(const Mat4& mat) void Mat4::subtract(const Mat4& m1, const Mat4& m2, Mat4* dst) { GP_ASSERT(dst); -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::subtractMatrix(m1.col, m2.col, dst->col); #else MathUtil::subtractMatrix(m1.m, m2.m, dst->m); @@ -931,7 +931,7 @@ void Mat4::transformVector(Vec4* vector) const void Mat4::transformVector(const Vec4& vector, Vec4* dst) const { GP_ASSERT(dst); -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::transformVec4(col, vector.v, dst->v); #else MathUtil::transformVec4(m, (const float*) &vector, (float*)dst); @@ -962,7 +962,7 @@ void Mat4::translate(const Vec3& t, Mat4* dst) const void Mat4::transpose() { -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) MathUtil::transposeMatrix(col, col); #else MathUtil::transposeMatrix(m, m); diff --git a/cocos/math/Mat4.h b/cocos/math/Mat4.h index 7616221943..3b6438dcd1 100644 --- a/cocos/math/Mat4.h +++ b/cocos/math/Mat4.h @@ -24,7 +24,7 @@ #include "math/Vec3.h" #include "math/Vec4.h" -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) #include #endif @@ -81,7 +81,7 @@ public: /** * Stores the columns of this 4x4 matrix. * */ -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) union { __m128 col[4]; float m[16]; diff --git a/cocos/math/MathUtil.h b/cocos/math/MathUtil.h index acf6ab0b42..ada14e70c0 100644 --- a/cocos/math/MathUtil.h +++ b/cocos/math/MathUtil.h @@ -21,7 +21,7 @@ #ifndef MATHUTIL_H_ #define MATHUTIL_H_ -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) #include #endif @@ -71,7 +71,7 @@ public: static void smooth(float* x, float target, float elapsedTime, float riseTime, float fallTime); private: -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) inline static void addMatrix(const __m128 m[4], float scalar, __m128 dst[4]); inline static void addMatrix(const __m128 m1[4], const __m128 m2[4], __m128 dst[4]); diff --git a/cocos/math/MathUtilSSE.inl b/cocos/math/MathUtilSSE.inl index b701bb51ca..e701d2cdbd 100644 --- a/cocos/math/MathUtilSSE.inl +++ b/cocos/math/MathUtilSSE.inl @@ -1,5 +1,5 @@ NS_CC_MATH_BEGIN - +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) inline void MathUtil::addMatrix(const __m128 m[4], float scalar, __m128 dst[4]) { __m128 s = _mm_set1_ps(scalar); @@ -148,5 +148,5 @@ inline void MathUtil::transformVec4(const __m128 m[4], const __m128& v, __m128& _mm_add_ps(_mm_mul_ps(m[2], col3), _mm_mul_ps(m[3], col4)) ); } - +#endif NS_CC_MATH_END diff --git a/cocos/math/Vec4.h b/cocos/math/Vec4.h index 712f60fd4f..cf5f2fe16b 100644 --- a/cocos/math/Vec4.h +++ b/cocos/math/Vec4.h @@ -21,7 +21,7 @@ #ifndef MATH_VEC4_H #define MATH_VEC4_H -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) #include #endif @@ -37,7 +37,7 @@ class Mat4; class CC_DLL Vec4 { public: -#ifdef __SSE__ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) && defined (__SSE__) union { struct { float x;