From 8be5172df5f826cfe3ffaa0685409df9fcaec159 Mon Sep 17 00:00:00 2001 From: "erwin.coumans" Date: Mon, 17 Sep 2012 16:03:47 +0000 Subject: [PATCH] fix issue in the recent SSE implementation of setInterpolate3 align class --- .../Character/btKinematicCharacterController.h | 5 ++++- src/LinearMath/btVector3.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/BulletDynamics/Character/btKinematicCharacterController.h b/src/BulletDynamics/Character/btKinematicCharacterController.h index ef01f8a3e..8ec63735c 100644 --- a/src/BulletDynamics/Character/btKinematicCharacterController.h +++ b/src/BulletDynamics/Character/btKinematicCharacterController.h @@ -34,7 +34,7 @@ class btPairCachingGhostObject; ///btKinematicCharacterController is an object that supports a sliding motion in a world. ///It uses a ghost object and convex sweep test to test for upcoming collisions. This is combined with discrete collision detection to recover from penetrations. ///Interaction between btKinematicCharacterController and dynamic rigid bodies needs to be explicity implemented by the user. -class btKinematicCharacterController : public btCharacterControllerInterface +ATTRIBUTE_ALIGNED16(class) btKinematicCharacterController : public btCharacterControllerInterface { protected: @@ -92,6 +92,9 @@ protected: void stepForwardAndStrafe (btCollisionWorld* collisionWorld, const btVector3& walkMove); void stepDown (btCollisionWorld* collisionWorld, btScalar dt); public: + + BT_DECLARE_ALIGNED_ALLOCATOR(); + btKinematicCharacterController (btPairCachingGhostObject* ghostObject,btConvexShape* convexShape,btScalar stepHeight, int upAxis = 1); ~btKinematicCharacterController (); diff --git a/src/LinearMath/btVector3.h b/src/LinearMath/btVector3.h index b2448ca31..5001dfa9f 100644 --- a/src/LinearMath/btVector3.h +++ b/src/LinearMath/btVector3.h @@ -472,15 +472,19 @@ public: return absolute().maxAxis(); } + SIMD_FORCE_INLINE void setInterpolate3(const btVector3& v0, const btVector3& v1, btScalar rt) { #if defined(BT_USE_SSE_IN_API) && defined (BT_USE_SSE) __m128 vrt = _mm_load_ss(&rt); // (rt 0 0 0) + btScalar s = btScalar(1.0) - rt; + __m128 vs = _mm_load_ss(&s); // (S 0 0 0) + vs = bt_pshufd_ps(vs, 0x80); // (S S S 0.0) + __m128 r0 = _mm_mul_ps(v0.mVec128, vs); vrt = bt_pshufd_ps(vrt, 0x80); // (rt rt rt 0.0) - - mVec128 = _mm_sub_ps(v1.mVec128, v0.mVec128); - mVec128 = _mm_mul_ps(mVec128, vrt); - mVec128 = _mm_add_ps(mVec128, v0.mVec128); + __m128 r1 = _mm_mul_ps(v1.mVec128, vrt); + __m128 tmp3 = _mm_add_ps(r0,r1); + mVec128 = tmp3; #elif defined(BT_USE_NEON) mVec128 = vsubq_f32(v1.mVec128, v0.mVec128); mVec128 = vmulq_n_f32(mVec128, rt);