| ColladaConverter.h | | ColladaConverter.h | |
| | | | |
| skipping to change at line 131 | | skipping to change at line 131 | |
| | | | |
| /* Currently we assume that there is only a single physics and visua
l scene */ | | /* Currently we assume that there is only a single physics and visua
l scene */ | |
| class domPhysics_scene* getDefaultPhysicsScene (); | | class domPhysics_scene* getDefaultPhysicsScene (); | |
| class domVisual_scene* getDefaultVisualScene (); | | class domVisual_scene* getDefaultVisualScene (); | |
| | | | |
| void buildShapeNew(btCollisionShape* shape, void* domTechniqueCommon
, const char* shapeName, bool isChild=false,const btTransform& childTrans=b
tTransform::getIdentity()); | | void buildShapeNew(btCollisionShape* shape, void* domTechniqueCommon
, const char* shapeName, bool isChild=false,const btTransform& childTrans=b
tTransform::getIdentity()); | |
| | | | |
| void addConvexHull (btCollisionShape* shape, const char* nodeName); | | void addConvexHull (btCollisionShape* shape, const char* nodeName); | |
| void addConvexMesh (btCollisionShape* shape, const char* nodeName); | | void addConvexMesh (btCollisionShape* shape, const char* nodeName); | |
| void addConcaveMesh(btCollisionShape* shape, const char* nodeName); | | void addConcaveMesh(btCollisionShape* shape, const char* nodeName); | |
|
| | | void addScaledConcaveMesh(btCollisionShape* shape, const char* nodeN | |
| | | ame); | |
| | | void addGimpactMesh(btCollisionShape* shape, const char* nodeName); | |
| | | | |
| | | void addConcaveMeshInternal(class btStridingMeshInterface* meshIn | |
| | | terface , const char* nodeName); | |
| | | | |
| class domNode* addNode (btRigidBody* body, const char* nodeNam
e, const char* shapeName); | | class domNode* addNode (btRigidBody* body, const char* nodeNam
e, const char* shapeName); | |
| class domRigid_constraint* addConstraint (btTypedConstraint* co
nstraint, const char* constraintName); | | class domRigid_constraint* addConstraint (btTypedConstraint* co
nstraint, const char* constraintName); | |
| class domInstance_rigid_constraint* addConstraintInstance (btTypedCo
nstraint* constraint, const char* constraintName); | | class domInstance_rigid_constraint* addConstraintInstance (btTypedCo
nstraint* constraint, const char* constraintName); | |
| void addMaterial (btRigidBody* body, const char* nodeName); | | void addMaterial (btRigidBody* body, const char* nodeName); | |
| class domRigid_body* addRigidBody (btRigidBody* body, const char* n
odeName, const char* shapeName); | | class domRigid_body* addRigidBody (btRigidBody* body, const char* n
odeName, const char* shapeName); | |
| class domInstance_rigid_body* addRigidBodyInstance (btRigidBody* bo
dy, const char* nodeName); | | class domInstance_rigid_body* addRigidBodyInstance (btRigidBody* bo
dy, const char* nodeName); | |
| | | | |
| void updateRigidBodyPosition (btRigidBody* body, class domNode* node
); | | void updateRigidBodyPosition (btRigidBody* body, class domNode* node
); | |
| void updateRigidBodyVelocity (btRigidBody* body); | | void updateRigidBodyVelocity (btRigidBody* body); | |
| void updateConstraint (btTypedConstraint* constraint, class domRigid
_constraint* rigidConstraint); | | void updateConstraint (btTypedConstraint* constraint, class domRigid
_constraint* rigidConstraint); | |
| | | | |
| skipping to change at line 206 | | skipping to change at line 211 | |
| virtual btRigidBody* createRigidBody(bool isDynamic, | | virtual btRigidBody* createRigidBody(bool isDynamic, | |
| float mass, | | float mass, | |
| const btTransform& startTransform, | | const btTransform& startTransform, | |
| btCollisionShape* shape); | | btCollisionShape* shape); | |
| virtual int getNumRigidBodies (); | | virtual int getNumRigidBodies (); | |
| virtual btRigidBody* getRigidBody (int i); | | virtual btRigidBody* getRigidBody (int i); | |
| virtual int getNumConstraints (); | | virtual int getNumConstraints (); | |
| virtual btTypedConstraint* getConstraint (int i); | | virtual btTypedConstraint* getConstraint (int i); | |
| virtual void setGravity(const btVector3& gravity); | | virtual void setGravity(const btVector3& gravity); | |
| virtual btVector3 getGravity (); | | virtual btVector3 getGravity (); | |
|
| virtual void setCameraInfo(const btVector3& up, int forwardAxis) | | virtual void setCameraInfo(const btVector3& up, int forwardAxis); | |
| { | | | |
| }; | | | |
| | | | |
| virtual btCollisionShape* createPlaneShape(const btVector3& planeNor
mal,btScalar planeConstant); | | virtual btCollisionShape* createPlaneShape(const btVector3& planeNor
mal,btScalar planeConstant); | |
| virtual btCollisionShape* createBoxShape(const btVector3& halfExtent
s); | | virtual btCollisionShape* createBoxShape(const btVector3& halfExtent
s); | |
| virtual btCollisionShape* createSphereShape(btScalar radius); | | virtual btCollisionShape* createSphereShape(btScalar radius); | |
| virtual btCollisionShape* createCylinderShapeY(btScalar radius,btSca
lar height); | | virtual btCollisionShape* createCylinderShapeY(btScalar radius,btSca
lar height); | |
| virtual class btTriangleMesh* createTriangleMeshContainer(); | | virtual class btTriangleMesh* createTriangleMeshContainer(); | |
| virtual btCollisionShape* createBvhTriangleMeshShape(btTriangleMesh*
trimesh); | | virtual btCollisionShape* createBvhTriangleMeshShape(btTriangleMesh*
trimesh); | |
| virtual btCollisionShape* createConvexTriangleMeshShape(btTriangleMe
sh* trimesh); | | virtual btCollisionShape* createConvexTriangleMeshShape(btTriangleMe
sh* trimesh); | |
|
| | | virtual btCollisionShape* createGimpactShape(btTriangleMesh* trimesh
); | |
| virtual class btConvexHullShape* createConvexHullShape(); | | virtual class btConvexHullShape* createConvexHullShape(); | |
| virtual class btCompoundShape* createCompoundShape(); | | virtual class btCompoundShape* createCompoundShape(); | |
| | | | |
| int getNumCollisionShapes() const; | | int getNumCollisionShapes() const; | |
| btCollisionShape* getCollisionShape(int shapeIndex); | | btCollisionShape* getCollisionShape(int shapeIndex); | |
| void deleteAllocatedCollisionShapes(); | | void deleteAllocatedCollisionShapes(); | |
| void deleteShape(btCollisionShape* shape); | | void deleteShape(btCollisionShape* shape); | |
| | | | |
| char* getLastFileName(); | | char* getLastFileName(); | |
| | | | |
| | | | |
End of changes. 3 change blocks. |
| 3 lines changed or deleted | | 9 lines changed or added | |
|
| btAxisSweep3.h | | btAxisSweep3.h | |
| | | | |
| skipping to change at line 45 | | skipping to change at line 45 | |
| template <typename BP_FP_INT_TYPE> | | template <typename BP_FP_INT_TYPE> | |
| class btAxisSweep3Internal : public btBroadphaseInterface | | class btAxisSweep3Internal : public btBroadphaseInterface | |
| { | | { | |
| protected: | | protected: | |
| | | | |
| BP_FP_INT_TYPE m_bpHandleMask; | | BP_FP_INT_TYPE m_bpHandleMask; | |
| BP_FP_INT_TYPE m_handleSentinel; | | BP_FP_INT_TYPE m_handleSentinel; | |
| | | | |
| public: | | public: | |
| | | | |
|
| | | BT_DECLARE_ALIGNED_ALLOCATOR(); | |
| | | | |
| class Edge | | class Edge | |
| { | | { | |
| public: | | public: | |
| BP_FP_INT_TYPE m_pos; // low bit is min/ma
x | | BP_FP_INT_TYPE m_pos; // low bit is min/ma
x | |
| BP_FP_INT_TYPE m_handle; | | BP_FP_INT_TYPE m_handle; | |
| | | | |
| BP_FP_INT_TYPE IsMax() const {return static_cast<BP_FP_INT_T
YPE>(m_pos & 1);} | | BP_FP_INT_TYPE IsMax() const {return static_cast<BP_FP_INT_T
YPE>(m_pos & 1);} | |
| }; | | }; | |
| | | | |
| public: | | public: | |
| | | | |
| skipping to change at line 135 | | skipping to change at line 137 | |
| return m_numHandles; | | return m_numHandles; | |
| } | | } | |
| | | | |
| virtual void calculateOverlappingPairs(btDispatcher* dispatcher); | | virtual void calculateOverlappingPairs(btDispatcher* dispatcher); | |
| | | | |
| BP_FP_INT_TYPE addHandle(const btVector3& aabbMin,const btVector3& a
abbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilt
erMask,btDispatcher* dispatcher,void* multiSapProxy); | | BP_FP_INT_TYPE addHandle(const btVector3& aabbMin,const btVector3& a
abbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilt
erMask,btDispatcher* dispatcher,void* multiSapProxy); | |
| void removeHandle(BP_FP_INT_TYPE handle,btDispatcher* dispatcher); | | void removeHandle(BP_FP_INT_TYPE handle,btDispatcher* dispatcher); | |
| void updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,co
nst btVector3& aabbMax,btDispatcher* dispatcher); | | void updateHandle(BP_FP_INT_TYPE handle, const btVector3& aabbMin,co
nst btVector3& aabbMax,btDispatcher* dispatcher); | |
| SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {ret
urn m_pHandles + index;} | | SIMD_FORCE_INLINE Handle* getHandle(BP_FP_INT_TYPE index) const {ret
urn m_pHandles + index;} | |
| | | | |
|
| void resetPool(); | | virtual void resetPool(btDispatcher* dispatcher); | |
| | | | |
| void processAllOverlappingPairs(btOverlapCallback* callback); | | void processAllOverlappingPairs(btOverlapCallback* callback); | |
| | | | |
| //Broadphase Interface | | //Broadphase Interface | |
| virtual btBroadphaseProxy* createProxy( const btVector3& aabbM
in, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collis
ionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void*
multiSapProxy); | | virtual btBroadphaseProxy* createProxy( const btVector3& aabbM
in, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collis
ionFilterGroup,short int collisionFilterMask,btDispatcher* dispatcher,void*
multiSapProxy); | |
| virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher*
dispatcher); | | virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher*
dispatcher); | |
| virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aa
bbMin,const btVector3& aabbMax,btDispatcher* dispatcher); | | virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aa
bbMin,const btVector3& aabbMax,btDispatcher* dispatcher); | |
| virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, b
tVector3& aabbMax ) const; | | virtual void getAabb(btBroadphaseProxy* proxy,btVector3& aabbMin, b
tVector3& aabbMax ) const; | |
| | | | |
| virtual void rayTest(const btVector3& rayFrom,const btVector3& ra
yTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVecto
r3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)); | | virtual void rayTest(const btVector3& rayFrom,const btVector3& ra
yTo, btBroadphaseRayCallback& rayCallback, const btVector3& aabbMin=btVecto
r3(0,0,0), const btVector3& aabbMax = btVector3(0,0,0)); | |
| | | | |
| skipping to change at line 214 | | skipping to change at line 216 | |
| { | | { | |
| Edge* pEdge = m_pEdges[axis] + i; | | Edge* pEdge = m_pEdges[axis] + i; | |
| Handle* pHandlePrev = getHandle(pEdge->m_handle); | | Handle* pHandlePrev = getHandle(pEdge->m_handle); | |
| int handleIndex = pEdge->IsMax()? pHandlePrev->m_maxEdges[ax
is] : pHandlePrev->m_minEdges[axis]; | | int handleIndex = pEdge->IsMax()? pHandlePrev->m_maxEdges[ax
is] : pHandlePrev->m_minEdges[axis]; | |
| char beginOrEnd; | | char beginOrEnd; | |
| beginOrEnd=pEdge->IsMax()?'E':'B'; | | beginOrEnd=pEdge->IsMax()?'E':'B'; | |
| printf(" [%c,h=%d,p=%x,i=%d]\n",beginOrEnd,pEdge->m_h
andle,pEdge->m_pos,handleIndex); | | printf(" [%c,h=%d,p=%x,i=%d]\n",beginOrEnd,pEdge->m_h
andle,pEdge->m_pos,handleIndex); | |
| } | | } | |
| | | | |
| if (checkCardinality) | | if (checkCardinality) | |
|
| assert(numEdges == m_numHandles*2+1); | | btAssert(numEdges == m_numHandles*2+1); | |
| } | | } | |
| #endif //DEBUG_BROADPHASE | | #endif //DEBUG_BROADPHASE | |
| | | | |
| template <typename BP_FP_INT_TYPE> | | template <typename BP_FP_INT_TYPE> | |
| btBroadphaseProxy* btAxisSweep3Internal<BP_FP_INT_TYPE>::createProxy(
const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* use
rPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatc
her* dispatcher,void* multiSapProxy) | | btBroadphaseProxy* btAxisSweep3Internal<BP_FP_INT_TYPE>::createProxy(
const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* use
rPtr,short int collisionFilterGroup,short int collisionFilterMask,btDispatc
her* dispatcher,void* multiSapProxy) | |
| { | | { | |
| (void)shapeType; | | (void)shapeType; | |
| BP_FP_INT_TYPE handleId = addHandle(aabbMin,aabbMax, userPtr
,collisionFilterGroup,collisionFilterMask,dispatcher,multiSapProxy); | | BP_FP_INT_TYPE handleId = addHandle(aabbMin,aabbMax, userPtr
,collisionFilterGroup,collisionFilterMask,dispatcher,multiSapProxy); | |
| | | | |
| Handle* handle = getHandle(handleId); | | Handle* handle = getHandle(handleId); | |
| | | | |
| skipping to change at line 332 | | skipping to change at line 334 | |
| m_ownsPairCache = true; | | m_ownsPairCache = true; | |
| } | | } | |
| | | | |
| if (!disableRaycastAccelerator) | | if (!disableRaycastAccelerator) | |
| { | | { | |
| m_nullPairCache = new (btAlignedAlloc(sizeof(btNullPairCache
),16)) btNullPairCache(); | | m_nullPairCache = new (btAlignedAlloc(sizeof(btNullPairCache
),16)) btNullPairCache(); | |
| m_raycastAccelerator = new (btAlignedAlloc(sizeof(btDbvtBroa
dphase),16)) btDbvtBroadphase(m_nullPairCache);//m_pairCache); | | m_raycastAccelerator = new (btAlignedAlloc(sizeof(btDbvtBroa
dphase),16)) btDbvtBroadphase(m_nullPairCache);//m_pairCache); | |
| m_raycastAccelerator->m_deferedcollide = true;//don't add/re
move pairs | | m_raycastAccelerator->m_deferedcollide = true;//don't add/re
move pairs | |
| } | | } | |
| | | | |
|
| //assert(bounds.HasVolume()); | | //btAssert(bounds.HasVolume()); | |
| | | | |
| // init bounds | | // init bounds | |
| m_worldAabbMin = worldAabbMin; | | m_worldAabbMin = worldAabbMin; | |
| m_worldAabbMax = worldAabbMax; | | m_worldAabbMax = worldAabbMax; | |
| | | | |
| btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin; | | btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin; | |
| | | | |
| BP_FP_INT_TYPE maxInt = m_handleSentinel; | | BP_FP_INT_TYPE maxInt = m_handleSentinel; | |
| | | | |
| m_quantize = btVector3(btScalar(maxInt),btScalar(maxInt),btScalar(ma
xInt)) / aabbSize; | | m_quantize = btVector3(btScalar(maxInt),btScalar(maxInt),btScalar(ma
xInt)) / aabbSize; | |
| | | | |
| skipping to change at line 437 | | skipping to change at line 439 | |
| btVector3 v = (point - m_worldAabbMin) * m_quantize; | | btVector3 v = (point - m_worldAabbMin) * m_quantize; | |
| out[0]=(v[0]<=0)?(BP_FP_INT_TYPE)isMax:(v[0]>=m_handleSentinel)?(BP_
FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP
_FP_INT_TYPE)v[0]&m_bpHandleMask)|isMax); | | out[0]=(v[0]<=0)?(BP_FP_INT_TYPE)isMax:(v[0]>=m_handleSentinel)?(BP_
FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP
_FP_INT_TYPE)v[0]&m_bpHandleMask)|isMax); | |
| out[1]=(v[1]<=0)?(BP_FP_INT_TYPE)isMax:(v[1]>=m_handleSentinel)?(BP_
FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP
_FP_INT_TYPE)v[1]&m_bpHandleMask)|isMax); | | out[1]=(v[1]<=0)?(BP_FP_INT_TYPE)isMax:(v[1]>=m_handleSentinel)?(BP_
FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP
_FP_INT_TYPE)v[1]&m_bpHandleMask)|isMax); | |
| out[2]=(v[2]<=0)?(BP_FP_INT_TYPE)isMax:(v[2]>=m_handleSentinel)?(BP_
FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP
_FP_INT_TYPE)v[2]&m_bpHandleMask)|isMax); | | out[2]=(v[2]<=0)?(BP_FP_INT_TYPE)isMax:(v[2]>=m_handleSentinel)?(BP_
FP_INT_TYPE)((m_handleSentinel&m_bpHandleMask)|isMax):(BP_FP_INT_TYPE)(((BP
_FP_INT_TYPE)v[2]&m_bpHandleMask)|isMax); | |
| #endif //OLD_CLAMPING_METHOD | | #endif //OLD_CLAMPING_METHOD | |
| } | | } | |
| | | | |
| template <typename BP_FP_INT_TYPE> | | template <typename BP_FP_INT_TYPE> | |
| BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle() | | BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::allocHandle() | |
| { | | { | |
|
| assert(m_firstFreeHandle); | | btAssert(m_firstFreeHandle); | |
| | | | |
| BP_FP_INT_TYPE handle = m_firstFreeHandle; | | BP_FP_INT_TYPE handle = m_firstFreeHandle; | |
| m_firstFreeHandle = getHandle(handle)->GetNextFree(); | | m_firstFreeHandle = getHandle(handle)->GetNextFree(); | |
| m_numHandles++; | | m_numHandles++; | |
| | | | |
| return handle; | | return handle; | |
| } | | } | |
| | | | |
| template <typename BP_FP_INT_TYPE> | | template <typename BP_FP_INT_TYPE> | |
| void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle
) | | void btAxisSweep3Internal<BP_FP_INT_TYPE>::freeHandle(BP_FP_INT_TYPE handle
) | |
| { | | { | |
|
| assert(handle > 0 && handle < m_maxHandles); | | btAssert(handle > 0 && handle < m_maxHandles); | |
| | | | |
| getHandle(handle)->SetNextFree(m_firstFreeHandle); | | getHandle(handle)->SetNextFree(m_firstFreeHandle); | |
| m_firstFreeHandle = handle; | | m_firstFreeHandle = handle; | |
| | | | |
| m_numHandles--; | | m_numHandles--; | |
| } | | } | |
| | | | |
| template <typename BP_FP_INT_TYPE> | | template <typename BP_FP_INT_TYPE> | |
| BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::addHandle(const btVect
or3& aabbMin,const btVector3& aabbMax, void* pOwner,short int collisionFilt
erGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiS
apProxy) | | BP_FP_INT_TYPE btAxisSweep3Internal<BP_FP_INT_TYPE>::addHandle(const btVect
or3& aabbMin,const btVector3& aabbMax, void* pOwner,short int collisionFilt
erGroup,short int collisionFilterMask,btDispatcher* dispatcher,void* multiS
apProxy) | |
| { | | { | |
| | | | |
| skipping to change at line 562 | | skipping to change at line 564 | |
| #endif //DEBUG_BROADPHASE | | #endif //DEBUG_BROADPHASE | |
| | | | |
| } | | } | |
| | | | |
| // free the handle | | // free the handle | |
| freeHandle(handle); | | freeHandle(handle); | |
| | | | |
| } | | } | |
| | | | |
| template <typename BP_FP_INT_TYPE> | | template <typename BP_FP_INT_TYPE> | |
|
| void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool() | | void btAxisSweep3Internal<BP_FP_INT_TYPE>::resetPool(btDispatcher* dispatch
er) | |
| { | | { | |
| if (m_numHandles == 0) | | if (m_numHandles == 0) | |
| { | | { | |
| m_firstFreeHandle = 1; | | m_firstFreeHandle = 1; | |
| { | | { | |
| for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < m_max
Handles; i++) | | for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < m_max
Handles; i++) | |
| m_pHandles[i].SetNextFree(static_cast<BP_FP_
INT_TYPE>(i + 1)); | | m_pHandles[i].SetNextFree(static_cast<BP_FP_
INT_TYPE>(i + 1)); | |
| m_pHandles[m_maxHandles - 1].SetNextFree(0); | | m_pHandles[m_maxHandles - 1].SetNextFree(0); | |
| } | | } | |
| } | | } | |
| | | | |
| skipping to change at line 613 | | skipping to change at line 615 | |
| btBroadphasePair& pair = overlappingPairArray[i]; | | btBroadphasePair& pair = overlappingPairArray[i]; | |
| | | | |
| bool isDuplicate = (pair == previousPair); | | bool isDuplicate = (pair == previousPair); | |
| | | | |
| previousPair = pair; | | previousPair = pair; | |
| | | | |
| bool needsRemoval = false; | | bool needsRemoval = false; | |
| | | | |
| if (!isDuplicate) | | if (!isDuplicate) | |
| { | | { | |
|
| | | ///important to use an AABB test that is con
sistent with the broadphase | |
| bool hasOverlap = testAabbOverlap(pair.m_pPr
oxy0,pair.m_pProxy1); | | bool hasOverlap = testAabbOverlap(pair.m_pPr
oxy0,pair.m_pProxy1); | |
| | | | |
| if (hasOverlap) | | if (hasOverlap) | |
| { | | { | |
| needsRemoval = false;//callback->pro
cessOverlap(pair); | | needsRemoval = false;//callback->pro
cessOverlap(pair); | |
| } else | | } else | |
| { | | { | |
| needsRemoval = true; | | needsRemoval = true; | |
| } | | } | |
| } else | | } else | |
| | | | |
| skipping to change at line 697 | | skipping to change at line 700 | |
| pHandleB->m_maxEdges[axis1] < pHandleA->m_minEdges[axis1]) | | pHandleB->m_maxEdges[axis1] < pHandleA->m_minEdges[axis1]) | |
| { | | { | |
| return false; | | return false; | |
| } | | } | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| template <typename BP_FP_INT_TYPE> | | template <typename BP_FP_INT_TYPE> | |
| void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE hand
le, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatc
her) | | void btAxisSweep3Internal<BP_FP_INT_TYPE>::updateHandle(BP_FP_INT_TYPE hand
le, const btVector3& aabbMin,const btVector3& aabbMax,btDispatcher* dispatc
her) | |
| { | | { | |
|
| // assert(bounds.IsFinite()); | | // btAssert(bounds.IsFinite()); | |
| //assert(bounds.HasVolume()); | | //btAssert(bounds.HasVolume()); | |
| | | | |
| Handle* pHandle = getHandle(handle); | | Handle* pHandle = getHandle(handle); | |
| | | | |
| // quantize the new bounds | | // quantize the new bounds | |
| BP_FP_INT_TYPE min[3], max[3]; | | BP_FP_INT_TYPE min[3], max[3]; | |
| quantize(min, aabbMin, 0); | | quantize(min, aabbMin, 0); | |
| quantize(max, aabbMax, 1); | | quantize(max, aabbMax, 1); | |
| | | | |
| // update changed edges | | // update changed edges | |
| for (int axis = 0; axis < 3; axis++) | | for (int axis = 0; axis < 3; axis++) | |
| | | | |
End of changes. 9 change blocks. |
| 8 lines changed or deleted | | 11 lines changed or added | |
|
| btCollisionObject.h | | btCollisionObject.h | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 53 | |
| | | | |
| btTransform m_worldTransform; | | btTransform m_worldTransform; | |
| | | | |
| ///m_interpolationWorldTransform is used for CCD and interpolation | | ///m_interpolationWorldTransform is used for CCD and interpolation | |
| ///it can be either previous or future (predicted) transform | | ///it can be either previous or future (predicted) transform | |
| btTransform m_interpolationWorldTransform; | | btTransform m_interpolationWorldTransform; | |
| //those two are experimental: just added for bullet time effect, so
you can still apply impulses (directly modifying velocities) | | //those two are experimental: just added for bullet time effect, so
you can still apply impulses (directly modifying velocities) | |
| //without destroying the continuous interpolated motion (which uses
this interpolation velocities) | | //without destroying the continuous interpolated motion (which uses
this interpolation velocities) | |
| btVector3 m_interpolationLinearVelocity; | | btVector3 m_interpolationLinearVelocity; | |
| btVector3 m_interpolationAngularVelocity; | | btVector3 m_interpolationAngularVelocity; | |
|
| | | | |
| | | btVector3 m_anisotropicFriction; | |
| | | bool m_hasAnisotropicFriction; | |
| | | btScalar m_contactProcessingThreshold; | |
| | | | |
| btBroadphaseProxy* m_broadphaseHandle; | | btBroadphaseProxy* m_broadphaseHandle; | |
| btCollisionShape* m_collisionShape; | | btCollisionShape* m_collisionShape; | |
| | | | |
| ///m_rootCollisionShape is temporarily used to store the original co
llision shape | | ///m_rootCollisionShape is temporarily used to store the original co
llision shape | |
| ///The m_collisionShape might be temporarily replaced by a child col
lision shape during collision detection purposes | | ///The m_collisionShape might be temporarily replaced by a child col
lision shape during collision detection purposes | |
| ///If it is NULL, the m_collisionShape is not temporarily replaced. | | ///If it is NULL, the m_collisionShape is not temporarily replaced. | |
| btCollisionShape* m_rootCollisionShape; | | btCollisionShape* m_rootCollisionShape; | |
| | | | |
| int m_collisionFlags; | | int m_collisionFlags; | |
| | | | |
| | | | |
| skipping to change at line 115 | | skipping to change at line 120 | |
| CF_KINEMATIC_OBJECT= 2, | | CF_KINEMATIC_OBJECT= 2, | |
| CF_NO_CONTACT_RESPONSE = 4, | | CF_NO_CONTACT_RESPONSE = 4, | |
| CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle m
aterial (friction/restitution) | | CF_CUSTOM_MATERIAL_CALLBACK = 8,//this allows per-triangle m
aterial (friction/restitution) | |
| CF_CHARACTER_OBJECT = 16 | | CF_CHARACTER_OBJECT = 16 | |
| }; | | }; | |
| | | | |
| enum CollisionObjectTypes | | enum CollisionObjectTypes | |
| { | | { | |
| CO_COLLISION_OBJECT =1, | | CO_COLLISION_OBJECT =1, | |
| CO_RIGID_BODY, | | CO_RIGID_BODY, | |
|
| CO_SOFT_BODY, | | | |
| ///CO_GHOST_OBJECT keeps track of all objects overlapping it
s AABB and that pass its collision filter | | ///CO_GHOST_OBJECT keeps track of all objects overlapping it
s AABB and that pass its collision filter | |
| ///It is useful for collision sensors, explosion objects, ch
aracter controller etc. | | ///It is useful for collision sensors, explosion objects, ch
aracter controller etc. | |
|
| CO_GHOST_OBJECT | | CO_GHOST_OBJECT, | |
| | | CO_SOFT_BODY, | |
| | | CO_HF_FLUID | |
| }; | | }; | |
| | | | |
| SIMD_FORCE_INLINE bool mergesSimulationIslands() const | | SIMD_FORCE_INLINE bool mergesSimulationIslands() const | |
| { | | { | |
| ///static objects, kinematic and object without contact resp
onse don't merge islands | | ///static objects, kinematic and object without contact resp
onse don't merge islands | |
| return ((m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATI
C_OBJECT | CF_NO_CONTACT_RESPONSE) )==0); | | return ((m_collisionFlags & (CF_STATIC_OBJECT | CF_KINEMATI
C_OBJECT | CF_NO_CONTACT_RESPONSE) )==0); | |
| } | | } | |
| | | | |
|
| | | const btVector3& getAnisotropicFriction() const | |
| | | { | |
| | | return m_anisotropicFriction; | |
| | | } | |
| | | void setAnisotropicFriction(const btVector3& anisotropicFriction) | |
| | | { | |
| | | m_anisotropicFriction = anisotropicFriction; | |
| | | m_hasAnisotropicFriction = (anisotropicFriction[0]!=1.f) || | |
| | | (anisotropicFriction[1]!=1.f) || (anisotropicFriction[2]!=1.f); | |
| | | } | |
| | | bool hasAnisotropicFriction() const | |
| | | { | |
| | | return m_hasAnisotropicFriction; | |
| | | } | |
| | | | |
| | | ///the constraint solver can discard solving contacts, if the distan | |
| | | ce is above this threshold. 0 by default. | |
| | | ///Note that using contacts with positive distance can improve stabi | |
| | | lity. It increases, however, the chance of colliding with degerate contacts | |
| | | , such as 'interior' triangle edges | |
| | | void setContactProcessingThreshold( btScalar contactProcessingThr | |
| | | eshold) | |
| | | { | |
| | | m_contactProcessingThreshold = contactProcessingThreshold; | |
| | | } | |
| | | btScalar getContactProcessingThreshold() const | |
| | | { | |
| | | return m_contactProcessingThreshold; | |
| | | } | |
| | | | |
| SIMD_FORCE_INLINE bool isStaticObject() const { | | SIMD_FORCE_INLINE bool isStaticObject() const { | |
| return (m_collisionFlags & CF_STATIC_OBJECT) != 0; | | return (m_collisionFlags & CF_STATIC_OBJECT) != 0; | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE bool isKinematicObject() const | | SIMD_FORCE_INLINE bool isKinematicObject() const | |
| { | | { | |
| return (m_collisionFlags & CF_KINEMATIC_OBJECT) != 0; | | return (m_collisionFlags & CF_KINEMATIC_OBJECT) != 0; | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE bool isStaticOrKinematicObject() const | | SIMD_FORCE_INLINE bool isStaticOrKinematicObject() const | |
| | | | |
End of changes. 4 change blocks. |
| 2 lines changed or deleted | | 38 lines changed or added | |
|
| btConeTwistConstraint.h | | btConeTwistConstraint.h | |
| | | | |
| skipping to change at line 42 | | skipping to change at line 42 | |
| #endif | | #endif | |
| btJacobianEntry m_jac[3]; //3 orthogonal linear constraints | | btJacobianEntry m_jac[3]; //3 orthogonal linear constraints | |
| | | | |
| btTransform m_rbAFrame; | | btTransform m_rbAFrame; | |
| btTransform m_rbBFrame; | | btTransform m_rbBFrame; | |
| | | | |
| btScalar m_limitSoftness; | | btScalar m_limitSoftness; | |
| btScalar m_biasFactor; | | btScalar m_biasFactor; | |
| btScalar m_relaxationFactor; | | btScalar m_relaxationFactor; | |
| | | | |
|
| | | btScalar m_damping; | |
| | | | |
| btScalar m_swingSpan1; | | btScalar m_swingSpan1; | |
| btScalar m_swingSpan2; | | btScalar m_swingSpan2; | |
| btScalar m_twistSpan; | | btScalar m_twistSpan; | |
| | | | |
|
| | | btScalar m_fixThresh; | |
| | | | |
| btVector3 m_swingAxis; | | btVector3 m_swingAxis; | |
| btVector3 m_twistAxis; | | btVector3 m_twistAxis; | |
| | | | |
| btScalar m_kSwing; | | btScalar m_kSwing; | |
| btScalar m_kTwist; | | btScalar m_kTwist; | |
| | | | |
| btScalar m_twistLimitSign; | | btScalar m_twistLimitSign; | |
| btScalar m_swingCorrection; | | btScalar m_swingCorrection; | |
| btScalar m_twistCorrection; | | btScalar m_twistCorrection; | |
| | | | |
|
| | | btScalar m_twistAngle; | |
| | | | |
| btScalar m_accSwingLimitImpulse; | | btScalar m_accSwingLimitImpulse; | |
| btScalar m_accTwistLimitImpulse; | | btScalar m_accTwistLimitImpulse; | |
| | | | |
| bool m_angularOnly; | | bool m_angularOnly; | |
| bool m_solveTwistLimit; | | bool m_solveTwistLimit; | |
| bool m_solveSwingLimit; | | bool m_solveSwingLimit; | |
| | | | |
|
| | | bool m_useSolveConstraintObsolete; | |
| | | | |
| | | // not yet used... | |
| | | btScalar m_swingLimitRatio; | |
| | | btScalar m_twistLimitRatio; | |
| | | btVector3 m_twistAxisA; | |
| | | | |
| | | // motor | |
| | | bool m_bMotorEnabled; | |
| | | bool m_bNormalizedMotorStrength; | |
| | | btQuaternion m_qTarget; | |
| | | btScalar m_maxMotorImpulse; | |
| | | btVector3 m_accMotorImpulse; | |
| | | | |
| public: | | public: | |
| | | | |
| btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB,const btTran
sform& rbAFrame, const btTransform& rbBFrame); | | btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB,const btTran
sform& rbAFrame, const btTransform& rbBFrame); | |
| | | | |
| btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame); | | btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame); | |
| | | | |
| btConeTwistConstraint(); | | btConeTwistConstraint(); | |
| | | | |
| virtual void buildJacobian(); | | virtual void buildJacobian(); | |
| | | | |
|
| virtual void solveConstraint(btScalar timeStep); | | virtual void getInfo1 (btConstraintInfo1* info); | |
| | | | |
| | | virtual void getInfo2 (btConstraintInfo2* info); | |
| | | | |
| | | virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolver | |
| | | Body& bodyB,btScalar timeStep); | |
| | | | |
| void updateRHS(btScalar timeStep); | | void updateRHS(btScalar timeStep); | |
| | | | |
| const btRigidBody& getRigidBodyA() const | | const btRigidBody& getRigidBodyA() const | |
| { | | { | |
| return m_rbA; | | return m_rbA; | |
| } | | } | |
| const btRigidBody& getRigidBodyB() const | | const btRigidBody& getRigidBodyB() const | |
| { | | { | |
| return m_rbB; | | return m_rbB; | |
| } | | } | |
| | | | |
| void setAngularOnly(bool angularOnly) | | void setAngularOnly(bool angularOnly) | |
| { | | { | |
| m_angularOnly = angularOnly; | | m_angularOnly = angularOnly; | |
| } | | } | |
| | | | |
|
| void setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar | | void setLimit(int limitIndex,btScalar limitValue) | |
| _twistSpan, btScalar _softness = 0.8f, btScalar _biasFactor = 0.3f, btScal | | { | |
| ar _relaxationFactor = 1.0f) | | switch (limitIndex) | |
| | | { | |
| | | case 3: | |
| | | { | |
| | | m_twistSpan = limitValue; | |
| | | break; | |
| | | } | |
| | | case 4: | |
| | | { | |
| | | m_swingSpan2 = limitValue; | |
| | | break; | |
| | | } | |
| | | case 5: | |
| | | { | |
| | | m_swingSpan1 = limitValue; | |
| | | break; | |
| | | } | |
| | | default: | |
| | | { | |
| | | } | |
| | | }; | |
| | | } | |
| | | | |
| | | void setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar | |
| | | _twistSpan, btScalar _softness = 1.f, btScalar _biasFactor = 0.3f, btScala | |
| | | r _relaxationFactor = 1.0f) | |
| { | | { | |
| m_swingSpan1 = _swingSpan1; | | m_swingSpan1 = _swingSpan1; | |
| m_swingSpan2 = _swingSpan2; | | m_swingSpan2 = _swingSpan2; | |
| m_twistSpan = _twistSpan; | | m_twistSpan = _twistSpan; | |
| | | | |
| m_limitSoftness = _softness; | | m_limitSoftness = _softness; | |
| m_biasFactor = _biasFactor; | | m_biasFactor = _biasFactor; | |
| m_relaxationFactor = _relaxationFactor; | | m_relaxationFactor = _relaxationFactor; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 120 | | skipping to change at line 169 | |
| inline int getSolveSwingLimit() | | inline int getSolveSwingLimit() | |
| { | | { | |
| return m_solveTwistLimit; | | return m_solveTwistLimit; | |
| } | | } | |
| | | | |
| inline btScalar getTwistLimitSign() | | inline btScalar getTwistLimitSign() | |
| { | | { | |
| return m_twistLimitSign; | | return m_twistLimitSign; | |
| } | | } | |
| | | | |
|
| | | void calcAngleInfo(); | |
| | | void calcAngleInfo2(); | |
| | | | |
| | | inline btScalar getSwingSpan1() | |
| | | { | |
| | | return m_swingSpan1; | |
| | | } | |
| | | inline btScalar getSwingSpan2() | |
| | | { | |
| | | return m_swingSpan2; | |
| | | } | |
| | | inline btScalar getTwistSpan() | |
| | | { | |
| | | return m_twistSpan; | |
| | | } | |
| | | inline btScalar getTwistAngle() | |
| | | { | |
| | | return m_twistAngle; | |
| | | } | |
| | | bool isPastSwingLimit() { return m_solveSwingLimit; } | |
| | | | |
| | | void setDamping(btScalar damping) { m_damping = damping; } | |
| | | | |
| | | void enableMotor(bool b) { m_bMotorEnabled = b; } | |
| | | void setMaxMotorImpulse(btScalar maxMotorImpulse) { m_maxMotorImpuls | |
| | | e = maxMotorImpulse; m_bNormalizedMotorStrength = false; } | |
| | | void setMaxMotorImpulseNormalized(btScalar maxMotorImpulse) { m_maxM | |
| | | otorImpulse = maxMotorImpulse; m_bNormalizedMotorStrength = true; } | |
| | | | |
| | | btScalar getFixThresh() { return m_fixThresh; } | |
| | | void setFixThresh(btScalar fixThresh) { m_fixThresh = fixThresh; } | |
| | | | |
| | | // setMotorTarget: | |
| | | // q: the desired rotation of bodyA wrt bodyB. | |
| | | // note: if q violates the joint limits, the internal target is clam | |
| | | ped to avoid conflicting impulses (very bad for stability) | |
| | | // note: don't forget to enableMotor() | |
| | | void setMotorTarget(const btQuaternion &q); | |
| | | | |
| | | // same as above, but q is the desired rotation of frameA wrt frameB | |
| | | in constraint space | |
| | | void setMotorTargetInConstraintSpace(const btQuaternion &q); | |
| | | | |
| | | btVector3 GetPointForAngle(btScalar fAngleInRadians, btScalar fLengt | |
| | | h) const; | |
| | | | |
| | | protected: | |
| | | void init(); | |
| | | | |
| | | void computeConeLimitInfo(const btQuaternion& qCone, // in | |
| | | btScalar& swingAngle, btVector3& vSwingAxis, btScalar& swing | |
| | | Limit); // all outs | |
| | | | |
| | | void computeTwistLimitInfo(const btQuaternion& qTwist, // in | |
| | | btScalar& twistAngle, btVector3& vTwistAxis); // all outs | |
| | | | |
| | | void adjustSwingAxisToUseEllipseNormal(btVector3& vSwingAxis) const; | |
| }; | | }; | |
| | | | |
| #endif //CONETWISTCONSTRAINT_H | | #endif //CONETWISTCONSTRAINT_H | |
| | | | |
End of changes. 7 change blocks. |
| 4 lines changed or deleted | | 111 lines changed or added | |
|
| btConvexConvexAlgorithm.h | | btConvexConvexAlgorithm.h | |
| | | | |
| skipping to change at line 36 | | skipping to change at line 36 | |
| #include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUti
l | | #include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUti
l | |
| | | | |
| class btConvexPenetrationDepthSolver; | | class btConvexPenetrationDepthSolver; | |
| | | | |
| ///Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computati
on. However, when using large size ratios GJK can be imprecise | | ///Enabling USE_SEPDISTANCE_UTIL2 requires 100% reliable distance computati
on. However, when using large size ratios GJK can be imprecise | |
| ///so the distance is not conservative. In that case, enabling this USE_SEP
DISTANCE_UTIL2 would result in failing/missing collisions. | | ///so the distance is not conservative. In that case, enabling this USE_SEP
DISTANCE_UTIL2 would result in failing/missing collisions. | |
| ///Either improve GJK for large size ratios (testing a 100 units versus a 0
.1 unit object) or only enable the util | | ///Either improve GJK for large size ratios (testing a 100 units versus a 0
.1 unit object) or only enable the util | |
| ///for certain pairs that have a small size ratio | | ///for certain pairs that have a small size ratio | |
| ///#define USE_SEPDISTANCE_UTIL2 1 | | ///#define USE_SEPDISTANCE_UTIL2 1 | |
| | | | |
|
| ///ConvexConvexAlgorithm collision algorithm implements time of impact, con | | ///The convexConvexAlgorithm collision algorithm implements time of impact, | |
| vex closest points and penetration depth calculations. | | convex closest points and penetration depth calculations between two conve | |
| | | x objects. | |
| | | ///Multiple contact points are calculated by perturbing the orientation of | |
| | | the smallest object orthogonal to the separating normal. | |
| | | ///This idea was described by Gino van den Bergen in this forum topic http: | |
| | | //www.bulletphysics.com/Bullet/phpBB3/viewtopic.php?f=4&t=288&p=888#p888 | |
| class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm | | class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm | |
| { | | { | |
| #ifdef USE_SEPDISTANCE_UTIL2 | | #ifdef USE_SEPDISTANCE_UTIL2 | |
| btConvexSeparatingDistanceUtil m_sepDistance; | | btConvexSeparatingDistanceUtil m_sepDistance; | |
| #endif | | #endif | |
| btSimplexSolverInterface* m_simplexSolver; | | btSimplexSolverInterface* m_simplexSolver; | |
| btConvexPenetrationDepthSolver* m_pdSolver; | | btConvexPenetrationDepthSolver* m_pdSolver; | |
| | | | |
| bool m_ownManifold; | | bool m_ownManifold; | |
| btPersistentManifold* m_manifoldPtr; | | btPersistentManifold* m_manifoldPtr; | |
| bool m_lowLevelOfDetail; | | bool m_lowLevelOfDetail; | |
| | | | |
|
| | | int m_numPerturbationIterations; | |
| | | int m_minimumPointsPerturbationThreshold; | |
| | | | |
| ///cache separating vector to speedup collision detection | | ///cache separating vector to speedup collision detection | |
| | | | |
| public: | | public: | |
| | | | |
|
| btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAl
gorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* bod
y1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver
* pdSolver); | | btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAl
gorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* bod
y1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver
* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThr
eshold); | |
| | | | |
| virtual ~btConvexConvexAlgorithm(); | | virtual ~btConvexConvexAlgorithm(); | |
| | | | |
| virtual void processCollision (btCollisionObject* body0,btCollisionO
bject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultO
ut); | | virtual void processCollision (btCollisionObject* body0,btCollisionO
bject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultO
ut); | |
| | | | |
| virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCo
llisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult*
resultOut); | | virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCo
llisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult*
resultOut); | |
| | | | |
| virtual void getAllContactManifolds(btManifoldArray& manifoldArra
y) | | virtual void getAllContactManifolds(btManifoldArray& manifoldArra
y) | |
| { | | { | |
| ///should we use m_ownManifold to avoid adding duplicates? | | ///should we use m_ownManifold to avoid adding duplicates? | |
| | | | |
| skipping to change at line 77 | | skipping to change at line 82 | |
| | | | |
| void setLowLevelOfDetail(bool useLowLevel); | | void setLowLevelOfDetail(bool useLowLevel); | |
| | | | |
| const btPersistentManifold* getManifold() | | const btPersistentManifold* getManifold() | |
| { | | { | |
| return m_manifoldPtr; | | return m_manifoldPtr; | |
| } | | } | |
| | | | |
| struct CreateFunc :public btCollisionAlgorithmCreateFunc | | struct CreateFunc :public btCollisionAlgorithmCreateFunc | |
| { | | { | |
|
| | | | |
| btConvexPenetrationDepthSolver* m_pdSolver; | | btConvexPenetrationDepthSolver* m_pdSolver; | |
| btSimplexSolverInterface* m_simplexSol
ver; | | btSimplexSolverInterface* m_simplexSol
ver; | |
|
| | | int m_numPerturbationIterations; | |
| | | int m_minimumPointsPerturbationThreshold; | |
| | | | |
| CreateFunc(btSimplexSolverInterface* simp
lexSolver, btConvexPenetrationDepthSolver* pdSolver); | | CreateFunc(btSimplexSolverInterface* simp
lexSolver, btConvexPenetrationDepthSolver* pdSolver); | |
| | | | |
| virtual ~CreateFunc(); | | virtual ~CreateFunc(); | |
| | | | |
| virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCol
lisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionOb
ject* body1) | | virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCol
lisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionOb
ject* body1) | |
| { | | { | |
| void* mem = ci.m_dispatcher1->allocateCollisionAlgor
ithm(sizeof(btConvexConvexAlgorithm)); | | void* mem = ci.m_dispatcher1->allocateCollisionAlgor
ithm(sizeof(btConvexConvexAlgorithm)); | |
|
| return new(mem) btConvexConvexAlgorithm(ci.m_manifol
d,ci,body0,body1,m_simplexSolver,m_pdSolver); | | return new(mem) btConvexConvexAlgorithm(ci.m_manifol
d,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_m
inimumPointsPerturbationThreshold); | |
| } | | } | |
| }; | | }; | |
| | | | |
| }; | | }; | |
| | | | |
| #endif //CONVEX_CONVEX_ALGORITHM_H | | #endif //CONVEX_CONVEX_ALGORITHM_H | |
| | | | |
End of changes. 6 change blocks. |
| 4 lines changed or deleted | | 15 lines changed or added | |
|
| btCudaBroadphase.h | | btCudaBroadphase.h | |
| | | | |
| skipping to change at line 23 | | skipping to change at line 23 | |
| 3. This notice may not be removed or altered from any source distribution. | | 3. This notice may not be removed or altered from any source distribution. | |
| */ | | */ | |
| | | | |
| #ifndef CUDA_BROADPHASE_H | | #ifndef CUDA_BROADPHASE_H | |
| #define CUDA_BROADPHASE_H | | #define CUDA_BROADPHASE_H | |
| | | | |
| #include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" | | #include "BulletCollision/BroadphaseCollision/btSimpleBroadphase.h" | |
| | | | |
| #include "btCudaBroadphaseKernel.h" | | #include "btCudaBroadphaseKernel.h" | |
| | | | |
|
| ///The btCudaBroadphase uses CUDA to compute overlapping pairs using a GPU. | | ///The bt3DGridBroadphase uses CUDA to compute overlapping pairs using a GP | |
| class btCudaBroadphase : public btSimpleBroadphase | | U. | |
| | | class bt3DGridBroadphase : public btSimpleBroadphase | |
| { | | { | |
|
| | | protected: | |
| bool m_bInitialized; | | bool m_bInitialized; | |
| unsigned int m_numBodies; | | unsigned int m_numBodies; | |
| unsigned int m_numCells; | | unsigned int m_numCells; | |
| unsigned int m_maxPairsPerBody; | | unsigned int m_maxPairsPerBody; | |
| btScalar m_cellFactorAABB; | | btScalar m_cellFactorAABB; | |
|
| | | unsigned int m_maxBodiesPerCell; | |
| | | btCudaBroadphaseParams m_params; | |
| | | btScalar m_maxRadius; | |
| // CPU data | | // CPU data | |
| unsigned int* m_hBodiesHash; | | unsigned int* m_hBodiesHash; | |
| unsigned int* m_hCellStart; | | unsigned int* m_hCellStart; | |
| unsigned int* m_hPairBuffStartCurr; | | unsigned int* m_hPairBuffStartCurr; | |
| btCuda3F1U* m_hAABB; | | btCuda3F1U* m_hAABB; | |
| unsigned int* m_hPairBuff; | | unsigned int* m_hPairBuff; | |
| unsigned int* m_hPairScan; | | unsigned int* m_hPairScan; | |
| unsigned int* m_hPairOut; | | unsigned int* m_hPairOut; | |
|
| // GPU data | | | |
| unsigned int* m_dBodiesHash[2]; | | | |
| unsigned int* m_dCellStart; | | | |
| unsigned int* m_dPairBuff; | | | |
| unsigned int* m_dPairBuffStartCurr; | | | |
| btCuda3F1U* m_dAABB; | | | |
| unsigned int* m_dPairScan; | | | |
| unsigned int* m_dPairOut; | | | |
| unsigned int m_maxBodiesPerCell; | | | |
| btCudaBroadphaseParams m_params; | | | |
| btScalar m_maxRadius; | | | |
| // large proxies | | // large proxies | |
| int m_numLargeHandles; | | int m_numLargeHandles; | |
| int m_maxLargeHandles; | | int m_maxLargeHandles; | |
| int m_LastLargeHandleIndex; | | int m_LastLargeHandleIndex; | |
| btSimpleBroadphaseProxy* m_pLargeHandles; | | btSimpleBroadphaseProxy* m_pLargeHandles; | |
| void* m_pLargeHandlesRawPtr; | | void* m_pLargeHandlesRawPtr; | |
| int m_firstFreeLargeHandle; | | int m_firstFreeLargeHandle; | |
| int allocLargeHandle() | | int allocLargeHandle() | |
| { | | { | |
| btAssert(m_numLargeHandles < m_maxLargeHandles); | | btAssert(m_numLargeHandles < m_maxLargeHandles); | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 77 | |
| { | | { | |
| m_LastLargeHandleIndex--; | | m_LastLargeHandleIndex--; | |
| } | | } | |
| proxy->SetNextFree(m_firstFreeLargeHandle); | | proxy->SetNextFree(m_firstFreeLargeHandle); | |
| m_firstFreeLargeHandle = handle; | | m_firstFreeLargeHandle = handle; | |
| proxy->m_clientObject = 0; | | proxy->m_clientObject = 0; | |
| m_numLargeHandles--; | | m_numLargeHandles--; | |
| } | | } | |
| bool isLargeProxy(const btVector3& aabbMin, const btVector3& aabbMa
x); | | bool isLargeProxy(const btVector3& aabbMin, const btVector3& aabbMa
x); | |
| bool isLargeProxy(btBroadphaseProxy* proxy); | | bool isLargeProxy(btBroadphaseProxy* proxy); | |
|
| | | | |
| // debug | | // debug | |
| unsigned int m_numPairsAdded; | | unsigned int m_numPairsAdded; | |
| unsigned int m_numPairsRemoved; | | unsigned int m_numPairsRemoved; | |
| unsigned int m_numOverflows; | | unsigned int m_numOverflows; | |
| // | | // | |
| public: | | public: | |
|
| btCudaBroadphase(const btVector3& worldAabbMin,const btVector3& worl | | bt3DGridBroadphase(const btVector3& worldAabbMin,const btVector3& wo | |
| dAabbMax, | | rldAabbMax, | |
| int gridS | | int gridSizeX, int gridSizeY, int | |
| izeX, int gridSizeY, int gridSizeZ, | | gridSizeZ, | |
| int maxSm | | int maxSmallProxies, int maxLarge | |
| allProxies, int maxLargeProxies, int maxPairsPerBody, | | Proxies, int maxPairsPerBody, | |
| int maxBo | | int maxBodiesPerCell = 8, | |
| diesPerCell = 8, | | btScalar cellFactorAABB = btScala | |
| btScalar | | r(1.0f)); | |
| cellFactorAABB = btScalar(1.0f)); | | virtual ~bt3DGridBroadphase(); | |
| virtual ~btCudaBroadphase(); | | | |
| virtual void calculateOverlappingPairs(btDispatcher* dispatcher); | | virtual void calculateOverlappingPairs(btDispatcher* dispatcher); | |
| | | | |
| virtual btBroadphaseProxy* createProxy(const btVector3& aabbMin
, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisio
nFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void*
multiSapProxy); | | virtual btBroadphaseProxy* createProxy(const btVector3& aabbMin
, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisio
nFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void*
multiSapProxy); | |
| virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher*
dispatcher); | | virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher*
dispatcher); | |
| virtual void rayTest(const btVector3& rayFrom,const btVector3& ra
yTo, btBroadphaseRayCallback& rayCallback); | | virtual void rayTest(const btVector3& rayFrom,const btVector3& ra
yTo, btBroadphaseRayCallback& rayCallback); | |
|
| | | | |
| protected: | | protected: | |
| void _initialize(); | | void _initialize(); | |
| void _finalize(); | | void _finalize(); | |
|
| void scanOverlappingPairBuffCPU(); | | void addPairsToCache(btDispatcher* dispatcher); | |
| void addPairsToCacheCPU(btDispatcher* dispatcher); | | | |
| void addLarge2LargePairsToCache(btDispatcher* dispatcher); | | void addLarge2LargePairsToCache(btDispatcher* dispatcher); | |
|
| | | | |
| | | // overrides for CPU version | |
| | | virtual void setParameters(btCudaBroadphaseParams* hostParams); | |
| | | virtual void prepareAABB(); | |
| | | virtual void calcHashAABB(); | |
| | | virtual void sortHash(); | |
| | | virtual void findCellStart(); | |
| | | virtual void findOverlappingPairs(); | |
| | | virtual void findPairsLarge(); | |
| | | virtual void computePairCacheChanges(); | |
| | | virtual void scanOverlappingPairBuff(); | |
| | | virtual void squeezeOverlappingPairBuff(); | |
| | | }; | |
| | | | |
| | | ///The btCudaBroadphase uses CUDA to compute overlapping pairs using a GPU. | |
| | | class btCudaBroadphase : public bt3DGridBroadphase | |
| | | { | |
| | | protected: | |
| | | // GPU data | |
| | | unsigned int* m_dBodiesHash[2]; | |
| | | unsigned int* m_dCellStart; | |
| | | unsigned int* m_dPairBuff; | |
| | | unsigned int* m_dPairBuffStartCurr; | |
| | | btCuda3F1U* m_dAABB; | |
| | | unsigned int* m_dPairScan; | |
| | | unsigned int* m_dPairOut; | |
| | | public: | |
| | | btCudaBroadphase(const btVector3& worldAabbMin,const btVector3& worl | |
| | | dAabbMax, | |
| | | int gridS | |
| | | izeX, int gridSizeY, int gridSizeZ, | |
| | | int maxSm | |
| | | allProxies, int maxLargeProxies, int maxPairsPerBody, | |
| | | int maxBo | |
| | | diesPerCell = 8, | |
| | | btScalar | |
| | | cellFactorAABB = btScalar(1.0f)); | |
| | | virtual ~btCudaBroadphase(); | |
| | | protected: | |
| | | void _initialize(); | |
| | | void _finalize(); | |
| | | void allocateArray(void** devPtr, unsigned int size); | |
| | | void freeArray(void* devPtr); | |
| | | // overrides for CUDA version | |
| | | virtual void setParameters(btCudaBroadphaseParams* hostParams); | |
| | | virtual void prepareAABB(); | |
| | | virtual void calcHashAABB(); | |
| | | virtual void sortHash(); | |
| | | virtual void findCellStart(); | |
| | | virtual void findOverlappingPairs(); | |
| | | virtual void findPairsLarge(); | |
| | | virtual void computePairCacheChanges(); | |
| | | virtual void scanOverlappingPairBuff(); | |
| | | virtual void squeezeOverlappingPairBuff(); | |
| }; | | }; | |
| #endif //CUDA_BROADPHASE_H | | #endif //CUDA_BROADPHASE_H | |
| | | | |
End of changes. 9 change blocks. |
| 28 lines changed or deleted | | 72 lines changed or added | |
|
| btDbvt.h | | btDbvt.h | |
| | | | |
| skipping to change at line 59 | | skipping to change at line 59 | |
| | | | |
| // Enable benchmarking code | | // Enable benchmarking code | |
| #define DBVT_ENABLE_BENCHMARK 0 | | #define DBVT_ENABLE_BENCHMARK 0 | |
| | | | |
| // Inlining | | // Inlining | |
| #define DBVT_INLINE SIMD_FORCE_INLINE | | #define DBVT_INLINE SIMD_FORCE_INLINE | |
| | | | |
| // Specific methods implementation | | // Specific methods implementation | |
| | | | |
| //SSE gives errors on a MSVC 7.1 | | //SSE gives errors on a MSVC 7.1 | |
|
| #if (defined (WIN32) && (_MSC_VER) && _MSC_VER >= 1400) && (!defined (BT_US
E_DOUBLE_PRECISION)) | | #ifdef BT_USE_SSE | |
| #define DBVT_SELECT_IMPL DBVT_IMPL_SSE | | #define DBVT_SELECT_IMPL DBVT_IMPL_SSE | |
| #define DBVT_MERGE_IMPL DBVT_IMPL_SSE | | #define DBVT_MERGE_IMPL DBVT_IMPL_SSE | |
| #define DBVT_INT0_IMPL DBVT_IMPL_SSE | | #define DBVT_INT0_IMPL DBVT_IMPL_SSE | |
| #else | | #else | |
| #define DBVT_SELECT_IMPL DBVT_IMPL_GENERIC | | #define DBVT_SELECT_IMPL DBVT_IMPL_GENERIC | |
| #define DBVT_MERGE_IMPL DBVT_IMPL_GENERIC | | #define DBVT_MERGE_IMPL DBVT_IMPL_GENERIC | |
| #define DBVT_INT0_IMPL DBVT_IMPL_GENERIC | | #define DBVT_INT0_IMPL DBVT_IMPL_GENERIC | |
| #endif | | #endif | |
| | | | |
| #if (DBVT_SELECT_IMPL==DBVT_IMPL_SSE)|| \ | | #if (DBVT_SELECT_IMPL==DBVT_IMPL_SSE)|| \ | |
| | | | |
| skipping to change at line 84 | | skipping to change at line 84 | |
| | | | |
| // | | // | |
| // Auto config and checks | | // Auto config and checks | |
| // | | // | |
| | | | |
| #if DBVT_USE_TEMPLATE | | #if DBVT_USE_TEMPLATE | |
| #define DBVT_VIRTUAL | | #define DBVT_VIRTUAL | |
| #define DBVT_VIRTUAL_DTOR(a) | | #define DBVT_VIRTUAL_DTOR(a) | |
| #define DBVT_PREFIX template <typename T
> | | #define DBVT_PREFIX template <typename T
> | |
| #define DBVT_IPOLICY T& policy | | #define DBVT_IPOLICY T& policy | |
|
| #define DBVT_CHECKTYPE static const ICollide& type
checker=*(T*)0; | | #define DBVT_CHECKTYPE static const ICollide& type
checker=*(T*)1;(void)typechecker; | |
| #else | | #else | |
| #define DBVT_VIRTUAL_DTOR(a) virtual ~a() {} | | #define DBVT_VIRTUAL_DTOR(a) virtual ~a() {} | |
| #define DBVT_VIRTUAL virtual | | #define DBVT_VIRTUAL virtual | |
| #define DBVT_PREFIX | | #define DBVT_PREFIX | |
| #define DBVT_IPOLICY ICollide& policy | | #define DBVT_IPOLICY ICollide& policy | |
| #define DBVT_CHECKTYPE | | #define DBVT_CHECKTYPE | |
| #endif | | #endif | |
| | | | |
| #if DBVT_USE_MEMMOVE | | #if DBVT_USE_MEMMOVE | |
| #ifndef __CELLOS_LV2__ | | #ifndef __CELLOS_LV2__ | |
| | | | |
| skipping to change at line 148 | | skipping to change at line 148 | |
| static inline btDbvtAabbMm FromMM(const btVector3& mi,c
onst btVector3& mx); | | static inline btDbvtAabbMm FromMM(const btVector3& mi,c
onst btVector3& mx); | |
| static inline btDbvtAabbMm FromPoints(const btVector3*
pts,int n); | | static inline btDbvtAabbMm FromPoints(const btVector3*
pts,int n); | |
| static inline btDbvtAabbMm FromPoints(const btVector3**
ppts,int n); | | static inline btDbvtAabbMm FromPoints(const btVector3**
ppts,int n); | |
| DBVT_INLINE void Expand(const btVecto
r3& e); | | DBVT_INLINE void Expand(const btVecto
r3& e); | |
| DBVT_INLINE void SignedExpand(const b
tVector3& e); | | DBVT_INLINE void SignedExpand(const b
tVector3& e); | |
| DBVT_INLINE bool Contain(const btDbvt
AabbMm& a) const; | | DBVT_INLINE bool Contain(const btDbvt
AabbMm& a) const; | |
| DBVT_INLINE int Classify(const btVec
tor3& n,btScalar o,int s) const; | | DBVT_INLINE int Classify(const btVec
tor3& n,btScalar o,int s) const; | |
| DBVT_INLINE btScalar ProjectMinimum(const btVecto
r3& v,unsigned signs) const; | | DBVT_INLINE btScalar ProjectMinimum(const btVecto
r3& v,unsigned signs) const; | |
| DBVT_INLINE friend bool Intersect( const btDbvt
AabbMm& a, | | DBVT_INLINE friend bool Intersect( const btDbvt
AabbMm& a, | |
| const btDbvtAabbMm& b); | | const btDbvtAabbMm& b); | |
|
| DBVT_INLINE friend bool Intersect( const btDbvt | | | |
| AabbMm& a, | | | |
| const btDbvtAabbMm& b, | | | |
| const btTransform& xform); | | | |
| DBVT_INLINE friend bool Intersect( const btDbvt
AabbMm& a, | | DBVT_INLINE friend bool Intersect( const btDbvt
AabbMm& a, | |
| const btVector3& b); | | const btVector3& b); | |
| | | | |
| DBVT_INLINE friend btScalar Proximity( const btDbvt
AabbMm& a, | | DBVT_INLINE friend btScalar Proximity( const btDbvt
AabbMm& a, | |
| const btDbvtAabbMm& b); | | const btDbvtAabbMm& b); | |
| DBVT_INLINE friend int Select( const btDbvt
AabbMm& o, | | DBVT_INLINE friend int Select( const btDbvt
AabbMm& o, | |
| const btDbvtAabbMm& a, | | const btDbvtAabbMm& a, | |
| const btDbvtAabbMm& b); | | const btDbvtAabbMm& b); | |
| DBVT_INLINE friend void Merge( const btDbvt
AabbMm& a, | | DBVT_INLINE friend void Merge( const btDbvt
AabbMm& a, | |
| const btDbvtAabbMm& b, | | const btDbvtAabbMm& b, | |
| | | | |
| skipping to change at line 304 | | skipping to change at line 302 | |
| DBVT_IPOLICY); | | DBVT_IPOLICY); | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| void collideTT( const btDbvtNode* root0, | | void collideTT( const btDbvtNode* root0, | |
| const btDbvtNode* root1, | | const btDbvtNode* root1, | |
| DBVT_IPOLICY); | | DBVT_IPOLICY); | |
| | | | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| void collideTTpersistentStack( const btDbvt
Node* root0, | | void collideTTpersistentStack( const btDbvt
Node* root0, | |
| const btDbvtNode* root1, | | const btDbvtNode* root1, | |
| DBVT_IPOLICY); | | DBVT_IPOLICY); | |
|
| | | #if 0 | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| void collideTT( const btDbvtNode* root0, | | void collideTT( const btDbvtNode* root0, | |
| const btDbvtNode* root1, | | const btDbvtNode* root1, | |
| const btTransform& xform, | | const btTransform& xform, | |
| DBVT_IPOLICY); | | DBVT_IPOLICY); | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| void collideTT( const btDbvtNode* root0, | | void collideTT( const btDbvtNode* root0, | |
| const btTransform& xform0, | | const btTransform& xform0, | |
| const btDbvtNode* root1, | | const btDbvtNode* root1, | |
| const btTransform& xform1, | | const btTransform& xform1, | |
| DBVT_IPOLICY); | | DBVT_IPOLICY); | |
|
| | | #endif | |
| | | | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| void collideTV( const btDbvtNode* root, | | void collideTV( const btDbvtNode* root, | |
| const btDbvtVolume& volume, | | const btDbvtVolume& volume, | |
| DBVT_IPOLICY); | | DBVT_IPOLICY); | |
| ///rayTest is a re-entrant ray test, and can be called in parallel a
s long as the btAlignedAlloc is thread-safe (uses locking etc) | | ///rayTest is a re-entrant ray test, and can be called in parallel a
s long as the btAlignedAlloc is thread-safe (uses locking etc) | |
| ///rayTest is slower than rayTestInternal, because it builds a local
stack, using memory allocations, and it recomputes signs/rayDirectionInver
ses each time | | ///rayTest is slower than rayTestInternal, because it builds a local
stack, using memory allocations, and it recomputes signs/rayDirectionInver
ses each time | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| static void rayTest( const btDbvtNode* ro
ot, | | static void rayTest( const btDbvtNode* ro
ot, | |
| const btVector3& rayFrom, | | const btVector3& rayFrom, | |
| const btVector3& rayTo, | | const btVector3& rayTo, | |
| | | | |
| skipping to change at line 532 | | skipping to change at line 532 | |
| (a.mx.x()>=b.mi.x())&& | | (a.mx.x()>=b.mi.x())&& | |
| (a.mi.y()<=b.mx.y())&& | | (a.mi.y()<=b.mx.y())&& | |
| (a.mx.y()>=b.mi.y())&& | | (a.mx.y()>=b.mi.y())&& | |
| (a.mi.z()<=b.mx.z())&& | | (a.mi.z()<=b.mx.z())&& | |
| (a.mx.z()>=b.mi.z())); | | (a.mx.z()>=b.mi.z())); | |
| #endif | | #endif | |
| } | | } | |
| | | | |
| // | | // | |
| DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, | | DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, | |
|
| const btDb | | | |
| vtAabbMm& b, | | | |
| const btTr | | | |
| ansform& xform) | | | |
| { | | | |
| const btVector3 d0=xform*b.Center()-a.Center(); | | | |
| const btVector3 d1=d0*xform.getBasis(); | | | |
| btScalar s0[2]={0,0}; | | | |
| btScalar s1[2]={dot(xform.getOrigin(),d0),s1[ | | | |
| 0]}; | | | |
| a.AddSpan(d0,s0[0],s0[1]); | | | |
| b.AddSpan(d1,s1[0],s1[1]); | | | |
| if(s0[0]>(s1[1])) return(false); | | | |
| if(s0[1]<(s1[0])) return(false); | | | |
| return(true); | | | |
| } | | | |
| | | | |
| // | | | |
| DBVT_INLINE bool Intersect( const btDbvtAabbMm& a, | | | |
| const btVe
ctor3& b) | | const btVe
ctor3& b) | |
| { | | { | |
| return( (b.x()>=a.mi.x())&& | | return( (b.x()>=a.mi.x())&& | |
| (b.y()>=a.mi.y())&& | | (b.y()>=a.mi.y())&& | |
| (b.z()>=a.mi.z())&& | | (b.z()>=a.mi.z())&& | |
| (b.x()<=a.mx.x())&& | | (b.x()<=a.mx.x())&& | |
| (b.y()<=a.mx.y())&& | | (b.y()<=a.mx.y())&& | |
| (b.z()<=a.mx.z())); | | (b.z()<=a.mx.z())); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 839 | | skipping to change at line 823 | |
| else | | else | |
| { | | { | |
| policy.Process(p.a,p
.b); | | policy.Process(p.a,p
.b); | |
| } | | } | |
| } | | } | |
| } | | } | |
| } while(depth); | | } while(depth); | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | #if 0 | |
| // | | // | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| inline void btDbvt::collideTT( const btDbvtNode* root0, | | inline void btDbvt::collideTT( const btDbvtNode* root0, | |
| const btDb
vtNode* root1, | | const btDb
vtNode* root1, | |
| const btTr
ansform& xform, | | const btTr
ansform& xform, | |
| DBVT_IPOLI
CY) | | DBVT_IPOLI
CY) | |
| { | | { | |
| DBVT_CHECKTYPE | | DBVT_CHECKTYPE | |
| if(root0&&root1) | | if(root0&&root1) | |
| { | | { | |
| | | | |
| skipping to change at line 906 | | skipping to change at line 890 | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| inline void btDbvt::collideTT( const btDbvtNode* root0, | | inline void btDbvt::collideTT( const btDbvtNode* root0, | |
| const btTr
ansform& xform0, | | const btTr
ansform& xform0, | |
| const btDb
vtNode* root1, | | const btDb
vtNode* root1, | |
| const btTr
ansform& xform1, | | const btTr
ansform& xform1, | |
| DBVT_IPOLI
CY) | | DBVT_IPOLI
CY) | |
| { | | { | |
| const btTransform xform=xform0.inverse()*xform1; | | const btTransform xform=xform0.inverse()*xform1; | |
| collideTT(root0,root1,xform,policy); | | collideTT(root0,root1,xform,policy); | |
| } | | } | |
|
| | | #endif | |
| | | | |
| // | | // | |
| DBVT_PREFIX | | DBVT_PREFIX | |
| inline void btDbvt::collideTV( const btDbvtNode* root, | | inline void btDbvt::collideTV( const btDbvtNode* root, | |
| const btDb
vtVolume& vol, | | const btDb
vtVolume& vol, | |
| DBVT_IPOLI
CY) | | DBVT_IPOLI
CY) | |
| { | | { | |
| DBVT_CHECKTYPE | | DBVT_CHECKTYPE | |
| if(root) | | if(root) | |
| { | | { | |
| | | | |
End of changes. 8 change blocks. |
| 26 lines changed or deleted | | 8 lines changed or added | |
|
| btDiscreteDynamicsWorld.h | | btDiscreteDynamicsWorld.h | |
| | | | |
| skipping to change at line 26 | | skipping to change at line 26 | |
| #ifndef BT_DISCRETE_DYNAMICS_WORLD_H | | #ifndef BT_DISCRETE_DYNAMICS_WORLD_H | |
| #define BT_DISCRETE_DYNAMICS_WORLD_H | | #define BT_DISCRETE_DYNAMICS_WORLD_H | |
| | | | |
| #include "btDynamicsWorld.h" | | #include "btDynamicsWorld.h" | |
| | | | |
| class btDispatcher; | | class btDispatcher; | |
| class btOverlappingPairCache; | | class btOverlappingPairCache; | |
| class btConstraintSolver; | | class btConstraintSolver; | |
| class btSimulationIslandManager; | | class btSimulationIslandManager; | |
| class btTypedConstraint; | | class btTypedConstraint; | |
|
| | | class btActionInterface; | |
| | | | |
|
| class btRaycastVehicle; | | | |
| class btCharacterControllerInterface; | | | |
| class btIDebugDraw; | | class btIDebugDraw; | |
| #include "LinearMath/btAlignedObjectArray.h" | | #include "LinearMath/btAlignedObjectArray.h" | |
| | | | |
| ///btDiscreteDynamicsWorld provides discrete rigid body simulation | | ///btDiscreteDynamicsWorld provides discrete rigid body simulation | |
| ///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsContr
oller | | ///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsContr
oller | |
| class btDiscreteDynamicsWorld : public btDynamicsWorld | | class btDiscreteDynamicsWorld : public btDynamicsWorld | |
| { | | { | |
| protected: | | protected: | |
| | | | |
| btConstraintSolver* m_constraintSolver; | | btConstraintSolver* m_constraintSolver; | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 52 | |
| | | | |
| btVector3 m_gravity; | | btVector3 m_gravity; | |
| | | | |
| //for variable timesteps | | //for variable timesteps | |
| btScalar m_localTime; | | btScalar m_localTime; | |
| //for variable timesteps | | //for variable timesteps | |
| | | | |
| bool m_ownsIslandManager; | | bool m_ownsIslandManager; | |
| bool m_ownsConstraintSolver; | | bool m_ownsConstraintSolver; | |
| | | | |
|
| btAlignedObjectArray<btRaycastVehicle*> m_vehicles; | | btAlignedObjectArray<btActionInterface*> m_actions; | |
| | | | |
| btAlignedObjectArray<btCharacterControllerInterface*> m_characters; | | | |
| | | | |
| int m_profileTimings; | | int m_profileTimings; | |
| | | | |
| virtual void predictUnconstraintMotion(btScalar timeStep); | | virtual void predictUnconstraintMotion(btScalar timeStep); | |
| | | | |
| virtual void integrateTransforms(btScalar timeStep); | | virtual void integrateTransforms(btScalar timeStep); | |
| | | | |
| virtual void calculateSimulationIslands(); | | virtual void calculateSimulationIslands(); | |
| | | | |
| virtual void solveConstraints(btContactSolverInfo& solverInfo); | | virtual void solveConstraints(btContactSolverInfo& solverInfo); | |
| | | | |
| void updateActivationState(btScalar timeStep); | | void updateActivationState(btScalar timeStep); | |
| | | | |
|
| void updateVehicles(btScalar timeStep); | | void updateActions(btScalar timeStep); | |
| | | | |
| void updateCharacters(btScalar timeStep); | | | |
| | | | |
| void startProfiling(btScalar timeStep); | | void startProfiling(btScalar timeStep); | |
| | | | |
| virtual void internalSingleStepSimulation( btScalar timeStep); | | virtual void internalSingleStepSimulation( btScalar timeStep); | |
| | | | |
| virtual void saveKinematicState(btScalar timeStep); | | virtual void saveKinematicState(btScalar timeStep); | |
| | | | |
| void debugDrawSphere(btScalar radius, const btTransform& transfor
m, const btVector3& color); | | void debugDrawSphere(btScalar radius, const btTransform& transfor
m, const btVector3& color); | |
| | | | |
| public: | | public: | |
| | | | |
| skipping to change at line 100 | | skipping to change at line 95 | |
| | | | |
| virtual void synchronizeMotionStates(); | | virtual void synchronizeMotionStates(); | |
| | | | |
| ///this can be useful to synchronize a single rigid body -> graphics
object | | ///this can be useful to synchronize a single rigid body -> graphics
object | |
| void synchronizeSingleMotionState(btRigidBody* body); | | void synchronizeSingleMotionState(btRigidBody* body); | |
| | | | |
| virtual void addConstraint(btTypedConstraint* constraint, bool di
sableCollisionsBetweenLinkedBodies=false); | | virtual void addConstraint(btTypedConstraint* constraint, bool di
sableCollisionsBetweenLinkedBodies=false); | |
| | | | |
| virtual void removeConstraint(btTypedConstraint* constraint); | | virtual void removeConstraint(btTypedConstraint* constraint); | |
| | | | |
|
| virtual void addVehicle(btRaycastVehicle* vehicle); | | virtual void addAction(btActionInterface*); | |
| | | | |
| virtual void removeVehicle(btRaycastVehicle* vehicle); | | | |
| | | | |
| virtual void addCharacter(btCharacterControllerInterface* charact | | | |
| er); | | | |
| | | | |
|
| virtual void removeCharacter(btCharacterControllerInterface* char
acter); | | virtual void removeAction(btActionInterface*); | |
| | | | |
| btSimulationIslandManager* getSimulationIslandManager() | | btSimulationIslandManager* getSimulationIslandManager() | |
| { | | { | |
| return m_islandManager; | | return m_islandManager; | |
| } | | } | |
| | | | |
| const btSimulationIslandManager* getSimulationIslandManager()
const | | const btSimulationIslandManager* getSimulationIslandManager()
const | |
| { | | { | |
| return m_islandManager; | | return m_islandManager; | |
| } | | } | |
| | | | |
| skipping to change at line 134 | | skipping to change at line 126 | |
| virtual btVector3 getGravity () const; | | virtual btVector3 getGravity () const; | |
| | | | |
| virtual void addRigidBody(btRigidBody* body); | | virtual void addRigidBody(btRigidBody* body); | |
| | | | |
| virtual void addRigidBody(btRigidBody* body, short group, short m
ask); | | virtual void addRigidBody(btRigidBody* body, short group, short m
ask); | |
| | | | |
| virtual void removeRigidBody(btRigidBody* body); | | virtual void removeRigidBody(btRigidBody* body); | |
| | | | |
| void debugDrawObject(const btTransform& worldTransform, const btC
ollisionShape* shape, const btVector3& color); | | void debugDrawObject(const btTransform& worldTransform, const btC
ollisionShape* shape, const btVector3& color); | |
| | | | |
|
| | | void debugDrawConstraint(btTypedConstraint* constraint); | |
| | | | |
| virtual void debugDrawWorld(); | | virtual void debugDrawWorld(); | |
| | | | |
| virtual void setConstraintSolver(btConstraintSolver* solver); | | virtual void setConstraintSolver(btConstraintSolver* solver); | |
| | | | |
| virtual btConstraintSolver* getConstraintSolver(); | | virtual btConstraintSolver* getConstraintSolver(); | |
| | | | |
| virtual int getNumConstraints() const; | | virtual int getNumConstraints() const; | |
| | | | |
| virtual btTypedConstraint* getConstraint(int index) ; | | virtual btTypedConstraint* getConstraint(int index) ; | |
| | | | |
| | | | |
| skipping to change at line 162 | | skipping to change at line 156 | |
| virtual void clearForces(); | | virtual void clearForces(); | |
| | | | |
| ///apply gravity, call this once per timestep | | ///apply gravity, call this once per timestep | |
| virtual void applyGravity(); | | virtual void applyGravity(); | |
| | | | |
| virtual void setNumTasks(int numTasks) | | virtual void setNumTasks(int numTasks) | |
| { | | { | |
| (void) numTasks; | | (void) numTasks; | |
| } | | } | |
| | | | |
|
| | | ///obsolete, use updateActions instead | |
| | | virtual void updateVehicles(btScalar timeStep) | |
| | | { | |
| | | updateActions(timeStep); | |
| | | } | |
| | | | |
| | | ///obsolete, use addAction instead | |
| | | virtual void addVehicle(btActionInterface* vehicle); | |
| | | ///obsolete, use removeAction instead | |
| | | virtual void removeVehicle(btActionInterface* vehicle); | |
| | | ///obsolete, use addAction instead | |
| | | virtual void addCharacter(btActionInterface* character); | |
| | | ///obsolete, use removeAction instead | |
| | | virtual void removeCharacter(btActionInterface* character); | |
| | | | |
| }; | | }; | |
| | | | |
| #endif //BT_DISCRETE_DYNAMICS_WORLD_H | | #endif //BT_DISCRETE_DYNAMICS_WORLD_H | |
| | | | |
End of changes. 8 change blocks. |
| 15 lines changed or deleted | | 22 lines changed or added | |
|
| btGeneric6DofConstraint.h | | btGeneric6DofConstraint.h | |
| | | | |
| skipping to change at line 91 | | skipping to change at line 91 | |
| m_ERP = limot.m_ERP; | | m_ERP = limot.m_ERP; | |
| m_bounce = limot.m_bounce; | | m_bounce = limot.m_bounce; | |
| m_currentLimit = limot.m_currentLimit; | | m_currentLimit = limot.m_currentLimit; | |
| m_currentLimitError = limot.m_currentLimitError; | | m_currentLimitError = limot.m_currentLimitError; | |
| m_enableMotor = limot.m_enableMotor; | | m_enableMotor = limot.m_enableMotor; | |
| } | | } | |
| | | | |
| //! Is limited | | //! Is limited | |
| bool isLimited() | | bool isLimited() | |
| { | | { | |
|
| if(m_loLimit>=m_hiLimit) return false; | | if(m_loLimit > m_hiLimit) return false; | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| //! Need apply correction | | //! Need apply correction | |
| bool needApplyTorques() | | bool needApplyTorques() | |
| { | | { | |
| if(m_currentLimit == 0 && m_enableMotor == false) return false; | | if(m_currentLimit == 0 && m_enableMotor == false) return false; | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| //! calculates error | | //! calculates error | |
| /*! | | /*! | |
| calculates m_currentLimit and m_currentLimitError. | | calculates m_currentLimit and m_currentLimitError. | |
| */ | | */ | |
| int testLimitValue(btScalar test_value); | | int testLimitValue(btScalar test_value); | |
| | | | |
| //! apply the correction impulses for two bodies | | //! apply the correction impulses for two bodies | |
|
| btScalar solveAngularLimits(btScalar timeStep,btVector3& axis, btScalar
jacDiagABInv,btRigidBody * body0, btRigidBody * body1); | | btScalar solveAngularLimits(btScalar timeStep,btVector3& axis, btScalar
jacDiagABInv,btRigidBody * body0, btSolverBody& bodyA,btRigidBody * body1,
btSolverBody& bodyB); | |
| | | | |
| }; | | }; | |
| | | | |
| class btTranslationalLimitMotor | | class btTranslationalLimitMotor | |
| { | | { | |
| public: | | public: | |
| btVector3 m_lowerLimit;//!< the constraint lower limits | | btVector3 m_lowerLimit;//!< the constraint lower limits | |
| btVector3 m_upperLimit;//!< the constraint upper limits | | btVector3 m_upperLimit;//!< the constraint upper limits | |
| btVector3 m_accumulatedImpulse; | | btVector3 m_accumulatedImpulse; | |
| //! Linear_Limit_parameters | | //! Linear_Limit_parameters | |
| //!@{ | | //!@{ | |
| btScalar m_limitSoftness;//!< Softness for linear limit | | btScalar m_limitSoftness;//!< Softness for linear limit | |
| btScalar m_damping;//!< Damping for linear limit | | btScalar m_damping;//!< Damping for linear limit | |
| btScalar m_restitution;//! Bounce parameter for linear limit | | btScalar m_restitution;//! Bounce parameter for linear limit | |
| //!@} | | //!@} | |
|
| | | bool m_enableMotor[3]; | |
| | | btVector3 m_targetVelocity;//!< target motor velocity | |
| | | btVector3 m_maxMotorForce;//!< max force on motor | |
| | | btVector3 m_currentLimitError;//! How much is violated this limit | |
| | | int m_currentLimit[3];//!< 0=free, 1=at lower li | |
| | | mit, 2=at upper limit | |
| | | | |
| btTranslationalLimitMotor() | | btTranslationalLimitMotor() | |
| { | | { | |
| m_lowerLimit.setValue(0.f,0.f,0.f); | | m_lowerLimit.setValue(0.f,0.f,0.f); | |
| m_upperLimit.setValue(0.f,0.f,0.f); | | m_upperLimit.setValue(0.f,0.f,0.f); | |
| m_accumulatedImpulse.setValue(0.f,0.f,0.f); | | m_accumulatedImpulse.setValue(0.f,0.f,0.f); | |
| | | | |
| m_limitSoftness = 0.7f; | | m_limitSoftness = 0.7f; | |
| m_damping = btScalar(1.0f); | | m_damping = btScalar(1.0f); | |
| m_restitution = btScalar(0.5f); | | m_restitution = btScalar(0.5f); | |
|
| | | for(int i=0; i < 3; i++) | |
| | | { | |
| | | m_enableMotor[i] = false; | |
| | | m_targetVelocity[i] = btScalar(0.f); | |
| | | m_maxMotorForce[i] = btScalar(0.f); | |
| | | } | |
| } | | } | |
| | | | |
| btTranslationalLimitMotor(const btTranslationalLimitMotor & other ) | | btTranslationalLimitMotor(const btTranslationalLimitMotor & other ) | |
| { | | { | |
| m_lowerLimit = other.m_lowerLimit; | | m_lowerLimit = other.m_lowerLimit; | |
| m_upperLimit = other.m_upperLimit; | | m_upperLimit = other.m_upperLimit; | |
| m_accumulatedImpulse = other.m_accumulatedImpulse; | | m_accumulatedImpulse = other.m_accumulatedImpulse; | |
| | | | |
| m_limitSoftness = other.m_limitSoftness ; | | m_limitSoftness = other.m_limitSoftness ; | |
| m_damping = other.m_damping; | | m_damping = other.m_damping; | |
| m_restitution = other.m_restitution; | | m_restitution = other.m_restitution; | |
|
| | | for(int i=0; i < 3; i++) | |
| | | { | |
| | | m_enableMotor[i] = other.m_enableMotor[i]; | |
| | | m_targetVelocity[i] = other.m_targetVelocity[i]; | |
| | | m_maxMotorForce[i] = other.m_maxMotorForce[i]; | |
| | | } | |
| } | | } | |
| | | | |
| //! Test limit | | //! Test limit | |
| /*! | | /*! | |
| - free means upper < lower, | | - free means upper < lower, | |
| - locked means upper == lower | | - locked means upper == lower | |
| - limited means upper > lower | | - limited means upper > lower | |
| - limitIndex: first 3 are linear, next 3 are angular | | - limitIndex: first 3 are linear, next 3 are angular | |
| */ | | */ | |
| inline bool isLimited(int limitIndex) | | inline bool isLimited(int limitIndex) | |
| { | | { | |
| return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]); | | return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]); | |
| } | | } | |
|
| | | inline bool needApplyForce(int limitIndex) | |
| | | { | |
| | | if(m_currentLimit[limitIndex] == 0 && m_enableMotor[limitIndex] == f | |
| | | alse) return false; | |
| | | return true; | |
| | | } | |
| | | int testLimitValue(int limitIndex, btScalar test_value); | |
| | | | |
| btScalar solveLinearAxis( | | btScalar solveLinearAxis( | |
| btScalar timeStep, | | btScalar timeStep, | |
| btScalar jacDiagABInv, | | btScalar jacDiagABInv, | |
|
| btRigidBody& body1,const btVector3 &pointInA, | | btRigidBody& body1,btSolverBody& bodyA,const btVector3 &pointInA, | |
| btRigidBody& body2,const btVector3 &pointInB, | | btRigidBody& body2,btSolverBody& bodyB,const btVector3 &pointInB, | |
| int limit_index, | | int limit_index, | |
| const btVector3 & axis_normal_on_a, | | const btVector3 & axis_normal_on_a, | |
| const btVector3 & anchorPos); | | const btVector3 & anchorPos); | |
| | | | |
| }; | | }; | |
| | | | |
| /// btGeneric6DofConstraint between two rigidbodies each with a pivotpoint
that descibes the axis location in local space | | /// btGeneric6DofConstraint between two rigidbodies each with a pivotpoint
that descibes the axis location in local space | |
| /*! | | /*! | |
| btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or
'locked'. | | btGeneric6DofConstraint can leave any of the 6 degree of freedom 'free' or
'locked'. | |
| currently this limit supports rotational motors<br> | | currently this limit supports rotational motors<br> | |
| | | | |
| skipping to change at line 239 | | skipping to change at line 262 | |
| //!@} | | //!@} | |
| | | | |
| protected: | | protected: | |
| //! temporal variables | | //! temporal variables | |
| //!@{ | | //!@{ | |
| btScalar m_timeStep; | | btScalar m_timeStep; | |
| btTransform m_calculatedTransformA; | | btTransform m_calculatedTransformA; | |
| btTransform m_calculatedTransformB; | | btTransform m_calculatedTransformB; | |
| btVector3 m_calculatedAxisAngleDiff; | | btVector3 m_calculatedAxisAngleDiff; | |
| btVector3 m_calculatedAxis[3]; | | btVector3 m_calculatedAxis[3]; | |
|
| | | btVector3 m_calculatedLinearDiff; | |
| | | | |
| btVector3 m_AnchorPos; // point betwen pivots of bodies A and B to s
olve linear axes | | btVector3 m_AnchorPos; // point betwen pivots of bodies A and B to s
olve linear axes | |
| | | | |
| bool m_useLinearReferenceFrameA; | | bool m_useLinearReferenceFrameA; | |
| | | | |
| //!@} | | //!@} | |
| | | | |
| btGeneric6DofConstraint& operator=(btGeneric6DofConstraint& othe
r) | | btGeneric6DofConstraint& operator=(btGeneric6DofConstraint& othe
r) | |
| { | | { | |
| btAssert(0); | | btAssert(0); | |
| (void) other; | | (void) other; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
|
| | | int setAngularLimits(btConstraintInfo2 *info, int row_offset); | |
| | | | |
| | | int setLinearLimits(btConstraintInfo2 *info); | |
| | | | |
| void buildLinearJacobian( | | void buildLinearJacobian( | |
| btJacobianEntry & jacLinear,const btVector3 & normalWorld, | | btJacobianEntry & jacLinear,const btVector3 & normalWorld, | |
| const btVector3 & pivotAInW,const btVector3 & pivotBInW); | | const btVector3 & pivotAInW,const btVector3 & pivotBInW); | |
| | | | |
| void buildAngularJacobian(btJacobianEntry & jacAngular,const btVector3
& jointAxisW); | | void buildAngularJacobian(btJacobianEntry & jacAngular,const btVector3
& jointAxisW); | |
| | | | |
|
| | | // tests linear limits | |
| | | void calculateLinearInfo(); | |
| | | | |
| //! calcs the euler angles between the two bodies. | | //! calcs the euler angles between the two bodies. | |
| void calculateAngleInfo(); | | void calculateAngleInfo(); | |
| | | | |
| public: | | public: | |
|
| | | | |
| | | ///for backwards compatibility during the transition to 'getInfo/get | |
| | | Info2' | |
| | | bool m_useSolveConstraintObsolete; | |
| | | | |
| btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTra
nsform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrame
A); | | btGeneric6DofConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTra
nsform& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrame
A); | |
| | | | |
| btGeneric6DofConstraint(); | | btGeneric6DofConstraint(); | |
| | | | |
| //! Calcs global transform of the offsets | | //! Calcs global transform of the offsets | |
| /*! | | /*! | |
| Calcs the global transform for the joint offset for body A an B, and
also calcs the agle differences between the bodies. | | Calcs the global transform for the joint offset for body A an B, and
also calcs the agle differences between the bodies. | |
| \sa btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofC
onstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleIn
fo | | \sa btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofC
onstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleIn
fo | |
| */ | | */ | |
| void calculateTransforms(); | | void calculateTransforms(); | |
| | | | |
| skipping to change at line 315 | | skipping to change at line 350 | |
| } | | } | |
| | | | |
| btTransform & getFrameOffsetB() | | btTransform & getFrameOffsetB() | |
| { | | { | |
| return m_frameInB; | | return m_frameInB; | |
| } | | } | |
| | | | |
| //! performs Jacobian calculation, and also calculates angle differe
nces and axis | | //! performs Jacobian calculation, and also calculates angle differe
nces and axis | |
| virtual void buildJacobian(); | | virtual void buildJacobian(); | |
| | | | |
|
| virtual void solveConstraint(btScalar timeStep); | | virtual void getInfo1 (btConstraintInfo1* info); | |
| | | | |
| | | virtual void getInfo2 (btConstraintInfo2* info); | |
| | | | |
| | | virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolver | |
| | | Body& bodyB,btScalar timeStep); | |
| | | | |
| void updateRHS(btScalar timeStep); | | void updateRHS(btScalar timeStep); | |
| | | | |
| //! Get the rotation axis in global coordinates | | //! Get the rotation axis in global coordinates | |
| /*! | | /*! | |
| \pre btGeneric6DofConstraint.buildJacobian must be called previously
. | | \pre btGeneric6DofConstraint.buildJacobian must be called previously
. | |
| */ | | */ | |
| btVector3 getAxis(int axis_index) const; | | btVector3 getAxis(int axis_index) const; | |
| | | | |
| //! Get the relative Euler angle | | //! Get the relative Euler angle | |
| | | | |
| skipping to change at line 417 | | skipping to change at line 456 | |
| { | | { | |
| return m_rbA; | | return m_rbA; | |
| } | | } | |
| const btRigidBody& getRigidBodyB() const | | const btRigidBody& getRigidBodyB() const | |
| { | | { | |
| return m_rbB; | | return m_rbB; | |
| } | | } | |
| | | | |
| virtual void calcAnchorPos(void); // overridable | | virtual void calcAnchorPos(void); // overridable | |
| | | | |
|
| | | int get_limit_motor_info2( btRotationalLimitMotor * limot, | |
| | | btRigidBody | |
| | | * body0, btRigidBody * body1, | |
| | | btConstraint | |
| | | Info2 *info, int row, btVector3& ax1, int rotational); | |
| | | | |
| }; | | }; | |
| | | | |
| #endif //GENERIC_6DOF_CONSTRAINT_H | | #endif //GENERIC_6DOF_CONSTRAINT_H | |
| | | | |
End of changes. 13 change blocks. |
| 5 lines changed or deleted | | 54 lines changed or added | |
|
| btIDebugDraw.h | | btIDebugDraw.h | |
| | | | |
| skipping to change at line 31 | | skipping to change at line 31 | |
| SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| DEALINGS IN THE SOFTWARE. | | DEALINGS IN THE SOFTWARE. | |
| */ | | */ | |
| | | | |
| #ifndef IDEBUG_DRAW__H | | #ifndef IDEBUG_DRAW__H | |
| #define IDEBUG_DRAW__H | | #define IDEBUG_DRAW__H | |
| | | | |
| #include "btVector3.h" | | #include "btVector3.h" | |
|
| | | #include "btTransform.h" | |
| | | | |
| ///The btIDebugDraw interface class allows hooking up a debug renderer to v
isually debug simulations. | | ///The btIDebugDraw interface class allows hooking up a debug renderer to v
isually debug simulations. | |
| ///Typical use case: create a debug drawer object, and assign it to a btCol
lisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld
. | | ///Typical use case: create a debug drawer object, and assign it to a btCol
lisionWorld or btDynamicsWorld using setDebugDrawer and call debugDrawWorld
. | |
| ///A class that implements the btIDebugDraw interface has to implement the
drawLine method at a minimum. | | ///A class that implements the btIDebugDraw interface has to implement the
drawLine method at a minimum. | |
| class btIDebugDraw | | class btIDebugDraw | |
| { | | { | |
| public: | | public: | |
| | | | |
| enum DebugDrawModes | | enum DebugDrawModes | |
| { | | { | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 54 | |
| DBG_DrawAabb=2, | | DBG_DrawAabb=2, | |
| DBG_DrawFeaturesText=4, | | DBG_DrawFeaturesText=4, | |
| DBG_DrawContactPoints=8, | | DBG_DrawContactPoints=8, | |
| DBG_NoDeactivation=16, | | DBG_NoDeactivation=16, | |
| DBG_NoHelpText = 32, | | DBG_NoHelpText = 32, | |
| DBG_DrawText=64, | | DBG_DrawText=64, | |
| DBG_ProfileTimings = 128, | | DBG_ProfileTimings = 128, | |
| DBG_EnableSatComparison = 256, | | DBG_EnableSatComparison = 256, | |
| DBG_DisableBulletLCP = 512, | | DBG_DisableBulletLCP = 512, | |
| DBG_EnableCCD = 1024, | | DBG_EnableCCD = 1024, | |
|
| | | DBG_DrawConstraints = (1 << 11), | |
| | | DBG_DrawConstraintLimits = (1 << 12), | |
| DBG_MAX_DEBUG_DRAW_MODE | | DBG_MAX_DEBUG_DRAW_MODE | |
| }; | | }; | |
| | | | |
| virtual ~btIDebugDraw() {}; | | virtual ~btIDebugDraw() {}; | |
| | | | |
|
| | | virtual void drawLine(const btVector3& from,const btVector3& to, | |
| | | const btVector3& fromColor, const btVector3& toColor) | |
| | | { | |
| | | drawLine (from, to, fromColor); | |
| | | } | |
| | | | |
| | | virtual void drawBox (const btVector3& boxMin, const btVector3& b | |
| | | oxMax, const btVector3& color, btScalar alpha) | |
| | | { | |
| | | } | |
| | | | |
| | | virtual void drawSphere (const btVector3& p, btScalar radius, con | |
| | | st btVector3& color) | |
| | | { | |
| | | } | |
| | | | |
| virtual void drawLine(const btVector3& from,const btVector3& to,c
onst btVector3& color)=0; | | virtual void drawLine(const btVector3& from,const btVector3& to,c
onst btVector3& color)=0; | |
| | | | |
| virtual void drawTriangle(const btVector3& v0,const btVector3& v1
,const btVector3& v2,const btVector3& /*n0*/,const btVector3& /*n1*/,const
btVector3& /*n2*/,const btVector3& color, btScalar alpha) | | virtual void drawTriangle(const btVector3& v0,const btVector3& v1
,const btVector3& v2,const btVector3& /*n0*/,const btVector3& /*n1*/,const
btVector3& /*n2*/,const btVector3& color, btScalar alpha) | |
| { | | { | |
| drawTriangle(v0,v1,v2,color,alpha); | | drawTriangle(v0,v1,v2,color,alpha); | |
| } | | } | |
| virtual void drawTriangle(const btVector3& v0,const btVector3& v1
,const btVector3& v2,const btVector3& color, btScalar /*alpha*/) | | virtual void drawTriangle(const btVector3& v0,const btVector3& v1
,const btVector3& v2,const btVector3& color, btScalar /*alpha*/) | |
| { | | { | |
| drawLine(v0,v1,color); | | drawLine(v0,v1,color); | |
| drawLine(v1,v2,color); | | drawLine(v1,v2,color); | |
| | | | |
| skipping to change at line 110 | | skipping to change at line 126 | |
| edgecoord[2]*halfExtents[2]); | | edgecoord[2]*halfExtents[2]); | |
| pb+=center; | | pb+=center; | |
| | | | |
| drawLine(pa,pb,color); | | drawLine(pa,pb,color); | |
| } | | } | |
| edgecoord = btVector3(-1.f,-1.f,-1.f); | | edgecoord = btVector3(-1.f,-1.f,-1.f); | |
| if (i<3) | | if (i<3) | |
| edgecoord[i]*=-1.f; | | edgecoord[i]*=-1.f; | |
| } | | } | |
| } | | } | |
|
| | | void drawTransform(const btTransform& transform, btScalar orthoLen) | |
| | | { | |
| | | btVector3 start = transform.getOrigin(); | |
| | | drawLine(start, start+transform.getBasis() * btVector3(ortho | |
| | | Len, 0, 0), btVector3(0.7f,0,0)); | |
| | | drawLine(start, start+transform.getBasis() * btVector3(0, or | |
| | | thoLen, 0), btVector3(0,0.7f,0)); | |
| | | drawLine(start, start+transform.getBasis() * btVector3(0, 0, | |
| | | orthoLen), btVector3(0,0,0.7f)); | |
| | | } | |
| | | | |
| | | void drawArc(const btVector3& center, const btVector3& normal, const | |
| | | btVector3& axis, btScalar radiusA, btScalar radiusB, btScalar minAngle, bt | |
| | | Scalar maxAngle, | |
| | | const btVector3& color, bool drawSect, btSca | |
| | | lar stepDegrees = btScalar(10.f)) | |
| | | { | |
| | | const btVector3& vx = axis; | |
| | | btVector3 vy = normal.cross(axis); | |
| | | btScalar step = stepDegrees * SIMD_RADS_PER_DEG; | |
| | | int nSteps = (int)((maxAngle - minAngle) / step); | |
| | | if(!nSteps) nSteps = 1; | |
| | | btVector3 prev = center + radiusA * vx * btCos(minAngle) + r | |
| | | adiusB * vy * btSin(minAngle); | |
| | | if(drawSect) | |
| | | { | |
| | | drawLine(center, prev, color); | |
| | | } | |
| | | for(int i = 1; i <= nSteps; i++) | |
| | | { | |
| | | btScalar angle = minAngle + (maxAngle - minAngle) * | |
| | | btScalar(i) / btScalar(nSteps); | |
| | | btVector3 next = center + radiusA * vx * btCos(angle | |
| | | ) + radiusB * vy * btSin(angle); | |
| | | drawLine(prev, next, color); | |
| | | prev = next; | |
| | | } | |
| | | if(drawSect) | |
| | | { | |
| | | drawLine(center, prev, color); | |
| | | } | |
| | | } | |
| | | void drawSpherePatch(const btVector3& center, const btVector3& up, c | |
| | | onst btVector3& axis, btScalar radius, | |
| | | btScalar minTh, btScalar maxTh, btScalar minPs, btScalar max | |
| | | Ps, const btVector3& color, btScalar stepDegrees = btScalar(10.f)) | |
| | | { | |
| | | btVector3 vA[74]; | |
| | | btVector3 vB[74]; | |
| | | btVector3 *pvA = vA, *pvB = vB, *pT; | |
| | | btVector3 npole = center + up * radius; | |
| | | btVector3 spole = center - up * radius; | |
| | | btVector3 arcStart; | |
| | | btScalar step = stepDegrees * SIMD_RADS_PER_DEG; | |
| | | const btVector3& kv = up; | |
| | | const btVector3& iv = axis; | |
| | | btVector3 jv = kv.cross(iv); | |
| | | bool drawN = false; | |
| | | bool drawS = false; | |
| | | if(minTh <= -SIMD_HALF_PI) | |
| | | { | |
| | | minTh = -SIMD_HALF_PI + step; | |
| | | drawN = true; | |
| | | } | |
| | | if(maxTh >= SIMD_HALF_PI) | |
| | | { | |
| | | maxTh = SIMD_HALF_PI - step; | |
| | | drawS = true; | |
| | | } | |
| | | if(minTh > maxTh) | |
| | | { | |
| | | minTh = -SIMD_HALF_PI + step; | |
| | | maxTh = SIMD_HALF_PI - step; | |
| | | drawN = drawS = true; | |
| | | } | |
| | | int n_hor = (int)((maxTh - minTh) / step) + 1; | |
| | | if(n_hor < 2) n_hor = 2; | |
| | | btScalar step_h = (maxTh - minTh) / btScalar(n_hor - 1); | |
| | | bool isClosed = false; | |
| | | if(minPs > maxPs) | |
| | | { | |
| | | minPs = -SIMD_PI + step; | |
| | | maxPs = SIMD_PI; | |
| | | isClosed = true; | |
| | | } | |
| | | else if((maxPs - minPs) >= SIMD_PI * btScalar(2.f)) | |
| | | { | |
| | | isClosed = true; | |
| | | } | |
| | | else | |
| | | { | |
| | | isClosed = false; | |
| | | } | |
| | | int n_vert = (int)((maxPs - minPs) / step) + 1; | |
| | | if(n_vert < 2) n_vert = 2; | |
| | | btScalar step_v = (maxPs - minPs) / btScalar(n_vert - 1); | |
| | | for(int i = 0; i < n_hor; i++) | |
| | | { | |
| | | btScalar th = minTh + btScalar(i) * step_h; | |
| | | btScalar sth = radius * btSin(th); | |
| | | btScalar cth = radius * btCos(th); | |
| | | for(int j = 0; j < n_vert; j++) | |
| | | { | |
| | | btScalar psi = minPs + btScalar(j) * step_v; | |
| | | btScalar sps = btSin(psi); | |
| | | btScalar cps = btCos(psi); | |
| | | pvB[j] = center + cth * cps * iv + cth * sps | |
| | | * jv + sth * kv; | |
| | | if(i) | |
| | | { | |
| | | drawLine(pvA[j], pvB[j], color); | |
| | | } | |
| | | else if(drawS) | |
| | | { | |
| | | drawLine(spole, pvB[j], color); | |
| | | } | |
| | | if(j) | |
| | | { | |
| | | drawLine(pvB[j-1], pvB[j], color); | |
| | | } | |
| | | else | |
| | | { | |
| | | arcStart = pvB[j]; | |
| | | } | |
| | | if((i == (n_hor - 1)) && drawN) | |
| | | { | |
| | | drawLine(npole, pvB[j], color); | |
| | | } | |
| | | if(isClosed) | |
| | | { | |
| | | if(j == (n_vert-1)) | |
| | | { | |
| | | drawLine(arcStart, pvB[j], c | |
| | | olor); | |
| | | } | |
| | | } | |
| | | else | |
| | | { | |
| | | if(((!i) || (i == (n_hor-1))) && ((! | |
| | | j) || (j == (n_vert-1)))) | |
| | | { | |
| | | drawLine(center, pvB[j], col | |
| | | or); | |
| | | } | |
| | | } | |
| | | } | |
| | | pT = pvA; pvA = pvB; pvB = pT; | |
| | | } | |
| | | } | |
| | | | |
| | | void drawBox(const btVector3& bbMin, const btVector3& bbMax, const b | |
| | | tVector3& color) | |
| | | { | |
| | | drawLine(btVector3(bbMin[0], bbMin[1], bbMin[2]), btVector3( | |
| | | bbMax[0], bbMin[1], bbMin[2]), color); | |
| | | drawLine(btVector3(bbMax[0], bbMin[1], bbMin[2]), btVector3( | |
| | | bbMax[0], bbMax[1], bbMin[2]), color); | |
| | | drawLine(btVector3(bbMax[0], bbMax[1], bbMin[2]), btVector3( | |
| | | bbMin[0], bbMax[1], bbMin[2]), color); | |
| | | drawLine(btVector3(bbMin[0], bbMax[1], bbMin[2]), btVector3( | |
| | | bbMin[0], bbMin[1], bbMin[2]), color); | |
| | | drawLine(btVector3(bbMin[0], bbMin[1], bbMin[2]), btVector3( | |
| | | bbMin[0], bbMin[1], bbMax[2]), color); | |
| | | drawLine(btVector3(bbMax[0], bbMin[1], bbMin[2]), btVector3( | |
| | | bbMax[0], bbMin[1], bbMax[2]), color); | |
| | | drawLine(btVector3(bbMax[0], bbMax[1], bbMin[2]), btVector3( | |
| | | bbMax[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(btVector3(bbMin[0], bbMax[1], bbMin[2]), btVector3( | |
| | | bbMin[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(btVector3(bbMin[0], bbMin[1], bbMax[2]), btVector3( | |
| | | bbMax[0], bbMin[1], bbMax[2]), color); | |
| | | drawLine(btVector3(bbMax[0], bbMin[1], bbMax[2]), btVector3( | |
| | | bbMax[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(btVector3(bbMax[0], bbMax[1], bbMax[2]), btVector3( | |
| | | bbMin[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(btVector3(bbMin[0], bbMax[1], bbMax[2]), btVector3( | |
| | | bbMin[0], bbMin[1], bbMax[2]), color); | |
| | | } | |
| | | void drawBox(const btVector3& bbMin, const btVector3& bbMax, const b | |
| | | tTransform& trans, const btVector3& color) | |
| | | { | |
| | | drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMax[0], bbMin[1], bbMin[2]), color); | |
| | | drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMax[0], bbMax[1], bbMin[2]), color); | |
| | | drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMin[0], bbMax[1], bbMin[2]), color); | |
| | | drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMin[0], bbMin[1], bbMin[2]), color); | |
| | | drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMin[0], bbMin[1], bbMax[2]), color); | |
| | | drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMax[0], bbMin[1], bbMax[2]), color); | |
| | | drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMax[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMin[2]), tr | |
| | | ans * btVector3(bbMin[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(trans * btVector3(bbMin[0], bbMin[1], bbMax[2]), tr | |
| | | ans * btVector3(bbMax[0], bbMin[1], bbMax[2]), color); | |
| | | drawLine(trans * btVector3(bbMax[0], bbMin[1], bbMax[2]), tr | |
| | | ans * btVector3(bbMax[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(trans * btVector3(bbMax[0], bbMax[1], bbMax[2]), tr | |
| | | ans * btVector3(bbMin[0], bbMax[1], bbMax[2]), color); | |
| | | drawLine(trans * btVector3(bbMin[0], bbMax[1], bbMax[2]), tr | |
| | | ans * btVector3(bbMin[0], bbMin[1], bbMax[2]), color); | |
| | | } | |
| }; | | }; | |
| | | | |
| #endif //IDEBUG_DRAW__H | | #endif //IDEBUG_DRAW__H | |
| | | | |
End of changes. 4 change blocks. |
| 0 lines changed or deleted | | 225 lines changed or added | |
|
| btQuaternion.h | | btQuaternion.h | |
| | | | |
| skipping to change at line 19 | | skipping to change at line 19 | |
| | | | |
| 1. The origin of this software must not be misrepresented; you must not cla
im that you wrote the original software. If you use this software in a prod
uct, an acknowledgment in the product documentation would be appreciated bu
t is not required. | | 1. The origin of this software must not be misrepresented; you must not cla
im that you wrote the original software. If you use this software in a prod
uct, an acknowledgment in the product documentation would be appreciated bu
t is not required. | |
| 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. | | 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. | |
| 3. This notice may not be removed or altered from any source distribution. | | 3. This notice may not be removed or altered from any source distribution. | |
| */ | | */ | |
| | | | |
| #ifndef SIMD__QUATERNION_H_ | | #ifndef SIMD__QUATERNION_H_ | |
| #define SIMD__QUATERNION_H_ | | #define SIMD__QUATERNION_H_ | |
| | | | |
| #include "btVector3.h" | | #include "btVector3.h" | |
|
| | | #include "btQuadWord.h" | |
| | | | |
| /**@brief The btQuaternion implements quaternion to perform linear algebra
rotations in combination with btMatrix3x3, btVector3 and btTransform. */ | | /**@brief The btQuaternion implements quaternion to perform linear algebra
rotations in combination with btMatrix3x3, btVector3 and btTransform. */ | |
| class btQuaternion : public btQuadWord { | | class btQuaternion : public btQuadWord { | |
| public: | | public: | |
| /**@brief No initialization constructor */ | | /**@brief No initialization constructor */ | |
| btQuaternion() {} | | btQuaternion() {} | |
| | | | |
| // template <typename btScalar> | | // template <typename btScalar> | |
| // explicit Quaternion(const btScalar *v) : Tuple4<btSc
alar>(v) {} | | // explicit Quaternion(const btScalar *v) : Tuple4<btSc
alar>(v) {} | |
| /**@brief Constructor from scalars */ | | /**@brief Constructor from scalars */ | |
| | | | |
| skipping to change at line 57 | | skipping to change at line 58 | |
| #else | | #else | |
| setEulerZYX(yaw, pitch, roll); | | setEulerZYX(yaw, pitch, roll); | |
| #endif | | #endif | |
| } | | } | |
| /**@brief Set the rotation using axis angle notation | | /**@brief Set the rotation using axis angle notation | |
| * @param axis The axis around which to rotate | | * @param axis The axis around which to rotate | |
| * @param angle The magnitude of the rotation in Radians */ | | * @param angle The magnitude of the rotation in Radians */ | |
| void setRotation(const btVector3& axis, const btScalar& angle) | | void setRotation(const btVector3& axis, const btScalar& angle) | |
| { | | { | |
| btScalar d = axis.length(); | | btScalar d = axis.length(); | |
|
| assert(d != btScalar(0.0)); | | btAssert(d != btScalar(0.0)); | |
| btScalar s = btSin(angle * btScalar(0.5)) / d; | | btScalar s = btSin(angle * btScalar(0.5)) / d; | |
| setValue(axis.x() * s, axis.y() * s, axis.z() * s, | | setValue(axis.x() * s, axis.y() * s, axis.z() * s, | |
| btCos(angle * btScalar(0.5))); | | btCos(angle * btScalar(0.5))); | |
| } | | } | |
| /**@brief Set the quaternion using Euler angles | | /**@brief Set the quaternion using Euler angles | |
| * @param yaw Angle around Y | | * @param yaw Angle around Y | |
| * @param pitch Angle around X | | * @param pitch Angle around X | |
| * @param roll Angle around Z */ | | * @param roll Angle around Z */ | |
| void setEuler(const btScalar& yaw, const btScalar& pitch, const btSc
alar& roll) | | void setEuler(const btScalar& yaw, const btScalar& pitch, const btSc
alar& roll) | |
| { | | { | |
| | | | |
| skipping to change at line 175 | | skipping to change at line 176 | |
| SIMD_FORCE_INLINE btQuaternion | | SIMD_FORCE_INLINE btQuaternion | |
| operator*(const btScalar& s) const | | operator*(const btScalar& s) const | |
| { | | { | |
| return btQuaternion(x() * s, y() * s, z() * s, m_floats[3] *
s); | | return btQuaternion(x() * s, y() * s, z() * s, m_floats[3] *
s); | |
| } | | } | |
| | | | |
| /**@brief Return an inversely scaled versionof this quaternion | | /**@brief Return an inversely scaled versionof this quaternion | |
| * @param s The inverse scale factor */ | | * @param s The inverse scale factor */ | |
| btQuaternion operator/(const btScalar& s) const | | btQuaternion operator/(const btScalar& s) const | |
| { | | { | |
|
| assert(s != btScalar(0.0)); | | btAssert(s != btScalar(0.0)); | |
| return *this * (btScalar(1.0) / s); | | return *this * (btScalar(1.0) / s); | |
| } | | } | |
| | | | |
| /**@brief Inversely scale this quaternion | | /**@brief Inversely scale this quaternion | |
| * @param s The scale factor */ | | * @param s The scale factor */ | |
| btQuaternion& operator/=(const btScalar& s) | | btQuaternion& operator/=(const btScalar& s) | |
| { | | { | |
|
| assert(s != btScalar(0.0)); | | btAssert(s != btScalar(0.0)); | |
| return *this *= btScalar(1.0) / s; | | return *this *= btScalar(1.0) / s; | |
| } | | } | |
| | | | |
| /**@brief Return a normalized version of this quaternion */ | | /**@brief Return a normalized version of this quaternion */ | |
| btQuaternion normalized() const | | btQuaternion normalized() const | |
| { | | { | |
| return *this / length(); | | return *this / length(); | |
| } | | } | |
| /**@brief Return the angle between this quaternion and the other | | /**@brief Return the angle between this quaternion and the other | |
| * @param q The other quaternion */ | | * @param q The other quaternion */ | |
| btScalar angle(const btQuaternion& q) const | | btScalar angle(const btQuaternion& q) const | |
| { | | { | |
| btScalar s = btSqrt(length2() * q.length2()); | | btScalar s = btSqrt(length2() * q.length2()); | |
|
| assert(s != btScalar(0.0)); | | btAssert(s != btScalar(0.0)); | |
| return btAcos(dot(q) / s); | | return btAcos(dot(q) / s); | |
| } | | } | |
| /**@brief Return the angle of rotation represented by this quaternion */ | | /**@brief Return the angle of rotation represented by this quaternion */ | |
| btScalar getAngle() const | | btScalar getAngle() const | |
| { | | { | |
| btScalar s = btScalar(2.) * btAcos(m_floats[3]); | | btScalar s = btScalar(2.) * btAcos(m_floats[3]); | |
| return s; | | return s; | |
| } | | } | |
| | | | |
| /**@brief Return the inverse of this quaternion */ | | /**@brief Return the inverse of this quaternion */ | |
| | | | |
| skipping to change at line 272 | | skipping to change at line 273 | |
| (m_floats[1] * s0 + q.y() * s1) * d, | | (m_floats[1] * s0 + q.y() * s1) * d, | |
| (m_floats[2] * s0 + q.z() * s1) * d, | | (m_floats[2] * s0 + q.z() * s1) * d, | |
| (m_floats[3] * s0 + q.m_floats[3] * s1) * d)
; | | (m_floats[3] * s0 + q.m_floats[3] * s1) * d)
; | |
| } | | } | |
| else | | else | |
| { | | { | |
| return *this; | | return *this; | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | static const btQuaternion& getIdentity() | |
| | | { | |
| | | static const btQuaternion identityQuat(btScalar(0.),btScalar | |
| | | (0.),btScalar(0.),btScalar(1.)); | |
| | | return identityQuat; | |
| | | } | |
| | | | |
| SIMD_FORCE_INLINE const btScalar& getW() const { return m_floats[3];
} | | SIMD_FORCE_INLINE const btScalar& getW() const { return m_floats[3];
} | |
| | | | |
| }; | | }; | |
| | | | |
| /**@brief Return the negative of a quaternion */ | | /**@brief Return the negative of a quaternion */ | |
| SIMD_FORCE_INLINE btQuaternion | | SIMD_FORCE_INLINE btQuaternion | |
| operator-(const btQuaternion& q) | | operator-(const btQuaternion& q) | |
| { | | { | |
| return btQuaternion(-q.x(), -q.y(), -q.z(), -q.w()); | | return btQuaternion(-q.x(), -q.y(), -q.z(), -q.w()); | |
| } | | } | |
| | | | |
End of changes. 6 change blocks. |
| 4 lines changed or deleted | | 12 lines changed or added | |
|
| btSequentialImpulseConstraintSolver.h | | btSequentialImpulseConstraintSolver.h | |
| | | | |
| skipping to change at line 25 | | skipping to change at line 25 | |
| | | | |
| #ifndef SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H | | #ifndef SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H | |
| #define SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H | | #define SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H | |
| | | | |
| #include "btConstraintSolver.h" | | #include "btConstraintSolver.h" | |
| class btIDebugDraw; | | class btIDebugDraw; | |
| #include "btContactConstraint.h" | | #include "btContactConstraint.h" | |
| #include "btSolverBody.h" | | #include "btSolverBody.h" | |
| #include "btSolverConstraint.h" | | #include "btSolverConstraint.h" | |
| | | | |
|
| ///The btSequentialImpulseConstraintSolver uses a Propagation Method and Se | | ///The btSequentialImpulseConstraintSolver is a fast SIMD implementation of | |
| quentially applies impulses | | the Projected Gauss Seidel (iterative LCP) method. | |
| ///The approach is the 3D version of Erin Catto's GDC 2006 tutorial. See ht | | | |
| tp://www.gphysics.com | | | |
| ///Although Sequential Impulse is more intuitive, it is mathematically equi | | | |
| valent to Projected Successive Overrelaxation (iterative LCP) | | | |
| ///Applies impulses for combined restitution and penetration recovery and t | | | |
| o simulate friction | | | |
| class btSequentialImpulseConstraintSolver : public btConstraintSolver | | class btSequentialImpulseConstraintSolver : public btConstraintSolver | |
| { | | { | |
|
| | | protected: | |
| | | | |
| btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool; | | btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool; | |
|
| btAlignedObjectArray<btSolverConstraint> m_tmpSolverConstrain | | btConstraintArray m_tmpSolverContactConstraint | |
| tPool; | | Pool; | |
| btAlignedObjectArray<btSolverConstraint> m_tmpSolverFrictionC | | btConstraintArray m_tmpSolverNonContactConstra | |
| onstraintPool; | | intPool; | |
| | | btConstraintArray m_tmpSolverContactFrictionCo | |
| | | nstraintPool; | |
| btAlignedObjectArray<int> m_orderTmpConstraintPool; | | btAlignedObjectArray<int> m_orderTmpConstraintPool; | |
| btAlignedObjectArray<int> m_orderFrictionConstraintPool; | | btAlignedObjectArray<int> m_orderFrictionConstraintPool; | |
| | | | |
|
| protected: | | | |
| btScalar solve(btRigidBody* body0,btRigidBody* body1, btManifoldPoin | | | |
| t& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer); | | | |
| btScalar solveFriction(btRigidBody* body0,btRigidBody* body1, btMani | | | |
| foldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debug | | | |
| Drawer); | | | |
| void prepareConstraints(btPersistentManifold* manifoldPtr, const bt | | | |
| ContactSolverInfo& info,btIDebugDraw* debugDrawer); | | | |
| btSolverConstraint& addFrictionConstraint(const btVector3& norma
lAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint
& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject*
colObj0,btCollisionObject* colObj1, btScalar relaxation); | | btSolverConstraint& addFrictionConstraint(const btVector3& norma
lAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint
& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject*
colObj0,btCollisionObject* colObj1, btScalar relaxation); | |
| | | | |
|
| ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CO | | | |
| NTACT_SOLVER_TYPES]; | | | |
| ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_C | | | |
| ONTACT_SOLVER_TYPES]; | | | |
| | | | |
| ///m_btSeed2 is used for re-arranging the constraint rows. improves
convergence/quality of friction | | ///m_btSeed2 is used for re-arranging the constraint rows. improves
convergence/quality of friction | |
| unsigned long m_btSeed2; | | unsigned long m_btSeed2; | |
| | | | |
|
| public: | | void initSolverBody(btSolverBody* solverBody, btCollisionObject* | |
| | | collisionObject); | |
| | | btScalar restitutionCurve(btScalar rel_vel, btScalar restitution); | |
| | | | |
|
| btSequentialImpulseConstraintSolver(); | | void convertContact(btPersistentManifold* manifold,const btContac
tSolverInfo& infoGlobal); | |
| | | | |
|
| ///Advanced: Override the default contact solving function for conta | | void resolveSplitPenetrationImpulseCacheFriendly( | |
| cts, for certain types of rigidbody | | btSolverBody& body1, | |
| ///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionS | | btSolverBody& body2, | |
| olverType | | const btSolverConstraint& contactConstraint, | |
| void setContactSolverFunc(ContactSolverFunc func,int type0,int ty | | const btContactSolverInfo& solverInfo); | |
| pe1) | | | |
| { | | | |
| m_contactDispatch[type0][type1] = func; | | | |
| } | | | |
| | | | |
|
| ///Advanced: Override the default friction solving function for cont | | //internal method | |
| acts, for certain types of rigidbody | | int getOrInitSolverBody(btCollisionObject& body); | |
| ///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionS | | | |
| olverType | | void resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolv | |
| void SetFrictionSolverFunc(ContactSolverFunc func,int type0,int t | | erBody& body2,const btSolverConstraint& contactConstraint); | |
| ype1) | | | |
| { | | | |
| m_frictionDispatch[type0][type1] = func; | | | |
| } | | | |
| | | | |
|
| | | void resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,bt | |
| | | SolverBody& body2,const btSolverConstraint& contactConstraint); | |
| | | | |
| | | void resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btS | |
| | | olverBody& body2,const btSolverConstraint& contactConstraint); | |
| | | | |
| | | void resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1 | |
| | | ,btSolverBody& body2,const btSolverConstraint& contactConstraint); | |
| | | | |
| | | public: | |
| | | | |
| | | btSequentialImpulseConstraintSolver(); | |
| virtual ~btSequentialImpulseConstraintSolver(); | | virtual ~btSequentialImpulseConstraintSolver(); | |
| | | | |
| virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies
,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** const
raints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* de
bugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); | | virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies
,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** const
raints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* de
bugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); | |
| | | | |
|
| virtual btScalar solveGroupCacheFriendly(btCollisionObject** bodies, | | | |
| int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedC | | | |
| onstraint** constraints,int numConstraints,const btContactSolverInfo& infoG | | | |
| lobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); | | | |
| btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodie | | | |
| s,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btType | | | |
| dConstraint** constraints,int numConstraints,const btContactSolverInfo& inf | | | |
| oGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); | | | |
| btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int
numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedCons
traint** constraints,int numConstraints,const btContactSolverInfo& infoGlob
al,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); | | btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int
numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedCons
traint** constraints,int numConstraints,const btContactSolverInfo& infoGlob
al,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); | |
|
| | | btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodie
s,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btType
dConstraint** constraints,int numConstraints,const btContactSolverInfo& inf
oGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); | |
| | | | |
| ///clear internal cached data and reset random seed | | ///clear internal cached data and reset random seed | |
| virtual void reset(); | | virtual void reset(); | |
| | | | |
|
| btScalar solveCombinedContactFriction(btRigidBody* body0,btRigidBody | | | |
| * body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btID | | | |
| ebugDraw* debugDrawer); | | | |
| | | | |
| unsigned long btRand2(); | | unsigned long btRand2(); | |
| | | | |
| int btRandInt2 (int n); | | int btRandInt2 (int n); | |
| | | | |
| void setRandSeed(unsigned long seed) | | void setRandSeed(unsigned long seed) | |
| { | | { | |
| m_btSeed2 = seed; | | m_btSeed2 = seed; | |
| } | | } | |
| unsigned long getRandSeed() const | | unsigned long getRandSeed() const | |
| { | | { | |
| | | | |
End of changes. 13 change blocks. |
| 57 lines changed or deleted | | 36 lines changed or added | |
|
| btSliderConstraint.h | | btSliderConstraint.h | |
| | | | |
| skipping to change at line 49 | | skipping to change at line 49 | |
| | | | |
| #define SLIDER_CONSTRAINT_DEF_SOFTNESS (btScalar(1.0)) | | #define SLIDER_CONSTRAINT_DEF_SOFTNESS (btScalar(1.0)) | |
| #define SLIDER_CONSTRAINT_DEF_DAMPING (btScalar(1.0)) | | #define SLIDER_CONSTRAINT_DEF_DAMPING (btScalar(1.0)) | |
| #define SLIDER_CONSTRAINT_DEF_RESTITUTION (btScalar(0.7)) | | #define SLIDER_CONSTRAINT_DEF_RESTITUTION (btScalar(0.7)) | |
| | | | |
| //-------------------------------------------------------------------------
---- | | //-------------------------------------------------------------------------
---- | |
| | | | |
| class btSliderConstraint : public btTypedConstraint | | class btSliderConstraint : public btTypedConstraint | |
| { | | { | |
| protected: | | protected: | |
|
| | | ///for backwards compatibility during the transition to 'getInfo/get | |
| | | Info2' | |
| | | bool m_useSolveConstraintObsolete; | |
| btTransform m_frameInA; | | btTransform m_frameInA; | |
| btTransform m_frameInB; | | btTransform m_frameInB; | |
| // use frameA fo define limits, if true | | // use frameA fo define limits, if true | |
| bool m_useLinearReferenceFrameA; | | bool m_useLinearReferenceFrameA; | |
| // linear limits | | // linear limits | |
| btScalar m_lowerLinLimit; | | btScalar m_lowerLinLimit; | |
| btScalar m_upperLinLimit; | | btScalar m_upperLinLimit; | |
| // angular limits | | // angular limits | |
| btScalar m_lowerAngLimit; | | btScalar m_lowerAngLimit; | |
| btScalar m_upperAngLimit; | | btScalar m_upperAngLimit; | |
| | | | |
| skipping to change at line 107 | | skipping to change at line 109 | |
| btVector3 m_sliderAxis; | | btVector3 m_sliderAxis; | |
| btVector3 m_realPivotAInW; | | btVector3 m_realPivotAInW; | |
| btVector3 m_realPivotBInW; | | btVector3 m_realPivotBInW; | |
| btVector3 m_projPivotInW; | | btVector3 m_projPivotInW; | |
| btVector3 m_delta; | | btVector3 m_delta; | |
| btVector3 m_depth; | | btVector3 m_depth; | |
| btVector3 m_relPosA; | | btVector3 m_relPosA; | |
| btVector3 m_relPosB; | | btVector3 m_relPosB; | |
| | | | |
| btScalar m_linPos; | | btScalar m_linPos; | |
|
| | | btScalar m_angPos; | |
| | | | |
| btScalar m_angDepth; | | btScalar m_angDepth; | |
| btScalar m_kAngle; | | btScalar m_kAngle; | |
| | | | |
| bool m_poweredLinMotor; | | bool m_poweredLinMotor; | |
| btScalar m_targetLinMotorVelocity; | | btScalar m_targetLinMotorVelocity; | |
| btScalar m_maxLinMotorForce; | | btScalar m_maxLinMotorForce; | |
| btScalar m_accumulatedLinMotorImpulse; | | btScalar m_accumulatedLinMotorImpulse; | |
| | | | |
| bool m_poweredAngMotor; | | bool m_poweredAngMotor; | |
| | | | |
| skipping to change at line 129 | | skipping to change at line 132 | |
| btScalar m_accumulatedAngMotorImpulse; | | btScalar m_accumulatedAngMotorImpulse; | |
| | | | |
| //------------------------ | | //------------------------ | |
| void initParams(); | | void initParams(); | |
| public: | | public: | |
| // constructors | | // constructors | |
| btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransfor
m& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); | | btSliderConstraint(btRigidBody& rbA, btRigidBody& rbB, const btTransfor
m& frameInA, const btTransform& frameInB ,bool useLinearReferenceFrameA); | |
| btSliderConstraint(); | | btSliderConstraint(); | |
| // overrides | | // overrides | |
| virtual void buildJacobian(); | | virtual void buildJacobian(); | |
|
| virtual void solveConstraint(btScalar timeStep); | | virtual void getInfo1 (btConstraintInfo1* info); | |
| | | | |
| | | virtual void getInfo2 (btConstraintInfo2* info); | |
| | | | |
| | | virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolver | |
| | | Body& bodyB,btScalar timeStep); | |
| | | | |
| // access | | // access | |
| const btRigidBody& getRigidBodyA() const { return m_rbA; } | | const btRigidBody& getRigidBodyA() const { return m_rbA; } | |
| const btRigidBody& getRigidBodyB() const { return m_rbB; } | | const btRigidBody& getRigidBodyB() const { return m_rbB; } | |
| const btTransform & getCalculatedTransformA() const { return m_calculat
edTransformA; } | | const btTransform & getCalculatedTransformA() const { return m_calculat
edTransformA; } | |
| const btTransform & getCalculatedTransformB() const { return m_calculat
edTransformB; } | | const btTransform & getCalculatedTransformB() const { return m_calculat
edTransformB; } | |
| const btTransform & getFrameOffsetA() const { return m_frameInA; } | | const btTransform & getFrameOffsetA() const { return m_frameInA; } | |
| const btTransform & getFrameOffsetB() const { return m_frameInB; } | | const btTransform & getFrameOffsetB() const { return m_frameInB; } | |
| btTransform & getFrameOffsetA() { return m_frameInA; } | | btTransform & getFrameOffsetA() { return m_frameInA; } | |
| btTransform & getFrameOffsetB() { return m_frameInB; } | | btTransform & getFrameOffsetB() { return m_frameInB; } | |
| btScalar getLowerLinLimit() { return m_lowerLinLimit; } | | btScalar getLowerLinLimit() { return m_lowerLinLimit; } | |
| | | | |
| skipping to change at line 205 | | skipping to change at line 213 | |
| btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; } | | btScalar getMaxAngMotorForce() { return m_maxAngMotorForce; } | |
| btScalar getLinearPos() { return m_linPos; } | | btScalar getLinearPos() { return m_linPos; } | |
| | | | |
| // access for ODE solver | | // access for ODE solver | |
| bool getSolveLinLimit() { return m_solveLinLim; } | | bool getSolveLinLimit() { return m_solveLinLim; } | |
| btScalar getLinDepth() { return m_depth[0]; } | | btScalar getLinDepth() { return m_depth[0]; } | |
| bool getSolveAngLimit() { return m_solveAngLim; } | | bool getSolveAngLimit() { return m_solveAngLim; } | |
| btScalar getAngDepth() { return m_angDepth; } | | btScalar getAngDepth() { return m_angDepth; } | |
| // internal | | // internal | |
| void buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const b
tTransform& frameInA, const btTransform& frameInB); | | void buildJacobianInt(btRigidBody& rbA, btRigidBody& rbB, const b
tTransform& frameInA, const btTransform& frameInB); | |
|
| void solveConstraintInt(btRigidBody& rbA, btRigidBody& rbB); | | void solveConstraintInt(btRigidBody& rbA, btSolverBody& bodyA,btR
igidBody& rbB, btSolverBody& bodyB); | |
| // shared code used by ODE solver | | // shared code used by ODE solver | |
| void calculateTransforms(void); | | void calculateTransforms(void); | |
| void testLinLimits(void); | | void testLinLimits(void); | |
|
| | | void testLinLimits2(btConstraintInfo2* info); | |
| void testAngLimits(void); | | void testAngLimits(void); | |
| // access for PE Solver | | // access for PE Solver | |
| btVector3 getAncorInA(void); | | btVector3 getAncorInA(void); | |
| btVector3 getAncorInB(void); | | btVector3 getAncorInB(void); | |
| }; | | }; | |
| | | | |
| //-------------------------------------------------------------------------
---- | | //-------------------------------------------------------------------------
---- | |
| | | | |
| #endif //SLIDER_CONSTRAINT_H | | #endif //SLIDER_CONSTRAINT_H | |
| | | | |
End of changes. 5 change blocks. |
| 2 lines changed or deleted | | 13 lines changed or added | |
|
| btSoftBody.h | | btSoftBody.h | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 51 | |
| btDispatcher* m_dispatcher; | | btDispatcher* m_dispatcher; | |
| btVector3 m_gravity; | | btVector3 m_gravity; | |
| btSparseSdf<3> m_sparsesdf; | | btSparseSdf<3> m_sparsesdf; | |
| }; | | }; | |
| | | | |
| ///The btSoftBody is an class to simulate cloth and volumetric soft bodies. | | ///The btSoftBody is an class to simulate cloth and volumetric soft bodies. | |
| ///There is two-way interaction between btSoftBody and btRigidBody/btCollis
ionObject. | | ///There is two-way interaction between btSoftBody and btRigidBody/btCollis
ionObject. | |
| class btSoftBody : public btCollisionObject | | class btSoftBody : public btCollisionObject | |
| { | | { | |
| public: | | public: | |
|
| | | btAlignedObjectArray<class btCollisionObject*> m_collisionDisabledOb | |
| | | jects; | |
| | | | |
| // | | // | |
| // Enumerations | | // Enumerations | |
| // | | // | |
| | | | |
| ///eAeroModel | | ///eAeroModel | |
| struct eAeroModel { enum _ { | | struct eAeroModel { enum _ { | |
| V_Point, ///Vertex normals are oriented toward veloci
ty | | V_Point, ///Vertex normals are oriented toward veloci
ty | |
| V_TwoSided, ///Vertex normals are fliped to match veloci
ty | | V_TwoSided, ///Vertex normals are fliped to match veloci
ty | |
| V_OneSided, ///Vertex normals are taken as it is | | V_OneSided, ///Vertex normals are taken as it is | |
| F_TwoSided, ///Face normals are fliped to match velocity | | F_TwoSided, ///Face normals are fliped to match velocity | |
| | | | |
| skipping to change at line 298 | | skipping to change at line 300 | |
| int m_nv
impulses; | | int m_nv
impulses; | |
| int m_nd
impulses; | | int m_nd
impulses; | |
| btVector3 m_lv; | | btVector3 m_lv; | |
| btVector3 m_av; | | btVector3 m_av; | |
| btDbvtNode* m_leaf; | | btDbvtNode* m_leaf; | |
| btScalar m_ndamping;
/* Node damping */ | | btScalar m_ndamping;
/* Node damping */ | |
| btScalar m_ldamping;
/* Linear damping */ | | btScalar m_ldamping;
/* Linear damping */ | |
| btScalar m_adamping;
/* Angular damping */ | | btScalar m_adamping;
/* Angular damping */ | |
| btScalar m_matching; | | btScalar m_matching; | |
| bool m_collide; | | bool m_collide; | |
|
| | | int m_cl
usterIndex; | |
| Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping
(0),m_matching(0) {} | | Cluster() : m_leaf(0),m_ndamping(0),m_ldamping(0),m_adamping
(0),m_matching(0) {} | |
| }; | | }; | |
| /* Impulse */ | | /* Impulse */ | |
| struct Impulse | | struct Impulse | |
| { | | { | |
| btVector3 m_velocity; | | btVector3 m_velocity; | |
| btVector3 m_drift; | | btVector3 m_drift; | |
| int m_as
Velocity:1; | | int m_as
Velocity:1; | |
| int m_as
Drift:1; | | int m_as
Drift:1; | |
| Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0)
,m_asDrift(0) {} | | Impulse() : m_velocity(0,0,0),m_drift(0,0,0),m_asVelocity(0)
,m_asDrift(0) {} | |
| | | | |
| skipping to change at line 606 | | skipping to change at line 609 | |
| tJointArray m_joints; // J
oints | | tJointArray m_joints; // J
oints | |
| tMaterialArray m_materials; // Materials | | tMaterialArray m_materials; // Materials | |
| btScalar m_timeacc; // T
ime accumulator | | btScalar m_timeacc; // T
ime accumulator | |
| btVector3 m_bounds[2]; // Spatial b
ounds | | btVector3 m_bounds[2]; // Spatial b
ounds | |
| bool m_bUpdateRtCst; // Update ru
ntime constants | | bool m_bUpdateRtCst; // Update ru
ntime constants | |
| btDbvt m_ndbvt; // N
odes tree | | btDbvt m_ndbvt; // N
odes tree | |
| btDbvt m_fdbvt; // F
aces tree | | btDbvt m_fdbvt; // F
aces tree | |
| btDbvt m_cdbvt; // C
lusters tree | | btDbvt m_cdbvt; // C
lusters tree | |
| tClusterArray m_clusters; // Clusters | | tClusterArray m_clusters; // Clusters | |
| | | | |
|
| | | btAlignedObjectArray<bool>m_clusterConnectivity;//cluster connectivi | |
| | | ty, for self-collision | |
| | | | |
| | | btTransform m_initialWorldTransform; | |
| | | | |
| // | | // | |
| // Api | | // Api | |
| // | | // | |
| | | | |
| /* ctor
*/ | | /* ctor
*/ | |
| btSoftBody( btSoftBodyWorldInfo* worldInfo,int node_count, | | btSoftBody( btSoftBodyWorldInfo* worldInfo,int node_count, | |
| const btVector3* x, | | const btVector3* x, | |
| const btScalar* m); | | const btScalar* m); | |
| /* dtor
*/ | | /* dtor
*/ | |
| virtual ~btSoftBody(); | | virtual ~btSoftBody(); | |
| | | | |
| skipping to change at line 678 | | skipping to change at line 685 | |
| Material* mat=0, | | Material* mat=0, | |
| bool bcheckexist=false); | | bool bcheckexist=false); | |
| /* Append face
*/ | | /* Append face
*/ | |
| void appendFace(int model=-1,Material* ma
t=0); | | void appendFace(int model=-1,Material* ma
t=0); | |
| void appendFace( int node0, | | void appendFace( int node0, | |
| int node1, | | int node1, | |
| int node2, | | int node2, | |
| Material* mat=0); | | Material* mat=0); | |
| /* Append anchor
*/ | | /* Append anchor
*/ | |
| void appendAnchor( int node, | | void appendAnchor( int node, | |
|
| btRigidBody* body); | | btRigidBody* body, bool disableCollisionBetweenLinkedBodies=
false); | |
| /* Append linear joint
*/ | | /* Append linear joint
*/ | |
| void appendLinearJoint(const LJoint::Spec
s& specs,Cluster* body0,Body body1); | | void appendLinearJoint(const LJoint::Spec
s& specs,Cluster* body0,Body body1); | |
| void appendLinearJoint(const LJoint::Spec
s& specs,Body body=Body()); | | void appendLinearJoint(const LJoint::Spec
s& specs,Body body=Body()); | |
| void appendLinearJoint(const LJoint::Spec
s& specs,btSoftBody* body); | | void appendLinearJoint(const LJoint::Spec
s& specs,btSoftBody* body); | |
| /* Append linear joint
*/ | | /* Append linear joint
*/ | |
| void appendAngularJoint(const AJoint::Spe
cs& specs,Cluster* body0,Body body1); | | void appendAngularJoint(const AJoint::Spe
cs& specs,Cluster* body0,Body body1); | |
| void appendAngularJoint(const AJoint::Spe
cs& specs,Body body=Body()); | | void appendAngularJoint(const AJoint::Spe
cs& specs,Body body=Body()); | |
| void appendAngularJoint(const AJoint::Spe
cs& specs,btSoftBody* body); | | void appendAngularJoint(const AJoint::Spe
cs& specs,btSoftBody* body); | |
| /* Add force (or gravity) to the entire body
*/ | | /* Add force (or gravity) to the entire body
*/ | |
| void addForce( const btVect
or3& force); | | void addForce( const btVect
or3& force); | |
| | | | |
End of changes. 4 change blocks. |
| 1 lines changed or deleted | | 10 lines changed or added | |
|
| btSoftBodyInternals.h | | btSoftBodyInternals.h | |
| | | | |
| skipping to change at line 743 | | skipping to change at line 743 | |
| pj->m_split *= psb-
>m_cfg.kSR_SPLT_CL; | | pj->m_split *= psb-
>m_cfg.kSR_SPLT_CL; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| void Process(btSoftBody* ps,btCollisionObject* co
lOb) | | void Process(btSoftBody* ps,btCollisionObject* co
lOb) | |
| { | | { | |
| psb = ps; | | psb = ps; | |
| m_colObj = colOb; | | m_colObj = colOb; | |
| idt = ps->m_sst.isdt; | | idt = ps->m_sst.isdt; | |
|
| margin = m_colObj->getCollisionShape( | | margin = m_colObj->getCollisionShape( | |
| )->getMargin()+ | | )->getMargin(); | |
| m_colObj->getCollisionShape()->getMargin(); | | ///Bullet rigid body uses multiply instead of minimu | |
| | | m to determine combined friction. Some customization would be useful. | |
| friction = btMin(psb->m_cfg.kDF,m_colOb
j->getFriction()); | | friction = btMin(psb->m_cfg.kDF,m_colOb
j->getFriction()); | |
| btVector3 mins; | | btVector3 mins; | |
| btVector3 maxs; | | btVector3 maxs; | |
| | | | |
| ATTRIBUTE_ALIGNED16(btDbvtVolume) volu
me; | | ATTRIBUTE_ALIGNED16(btDbvtVolume) volu
me; | |
| colOb->getCollisionShape()->getAabb(colOb->getInterp
olationWorldTransform(),mins,maxs); | | colOb->getCollisionShape()->getAabb(colOb->getInterp
olationWorldTransform(),mins,maxs); | |
| volume=btDbvtVolume::FromMM(mins,maxs); | | volume=btDbvtVolume::FromMM(mins,maxs); | |
| volume.Expand(btVector3(1,1,1)*margin); | | volume.Expand(btVector3(1,1,1)*margin); | |
| ps->m_cdbvt.collideTV(ps->m_cdbvt.m_root,volume,*thi
s); | | ps->m_cdbvt.collideTV(ps->m_cdbvt.m_root,volume,*thi
s); | |
| } | | } | |
| | | | |
| skipping to change at line 766 | | skipping to change at line 766 | |
| // | | // | |
| // CollideCL_SS | | // CollideCL_SS | |
| // | | // | |
| struct CollideCL_SS : ClusterBase | | struct CollideCL_SS : ClusterBase | |
| { | | { | |
| btSoftBody* bodies[2]; | | btSoftBody* bodies[2]; | |
| void Process(const btDbvtNode* la,const btDbvtNod
e* lb) | | void Process(const btDbvtNode* la,const btDbvtNod
e* lb) | |
| { | | { | |
| btSoftBody::Cluster* cla=(btSoftBody::Clu
ster*)la->data; | | btSoftBody::Cluster* cla=(btSoftBody::Clu
ster*)la->data; | |
| btSoftBody::Cluster* clb=(btSoftBody::Clu
ster*)lb->data; | | btSoftBody::Cluster* clb=(btSoftBody::Clu
ster*)lb->data; | |
|
| btSoftClusterCollisionShape csa(cla); | | | |
| btSoftClusterCollisionShape csb(clb); | | bool connected=false; | |
| btGjkEpaSolver2::sResults res; | | if ((bodies[0]==bodies[1])&&(bodies[0]->m_clusterCon | |
| if(btGjkEpaSolver2::SignedDistance( &csa,btTrans | | nectivity.size())) | |
| form::getIdentity(), | | | |
| &csb,btTransform::getIdentity(), | | | |
| cla->m_com-clb->m_com,res)) | | | |
| { | | { | |
|
| btSoftBody::CJoint joint; | | connected = bodies[0]->m_clusterConnectivity | |
| if(SolveContact(res,cla,clb,joint)) | | [cla->m_clusterIndex+bodies[0]->m_clusters.size()*clb->m_clusterIndex]; | |
| | | } | |
| | | | |
| | | if (!connected) | |
| | | { | |
| | | btSoftClusterCollisionShape csa(cla); | |
| | | btSoftClusterCollisionShape csb(clb); | |
| | | btGjkEpaSolver2::sResults res; | |
| | | if(btGjkEpaSolver2::SignedDistance( &csa | |
| | | ,btTransform::getIdentity(), | |
| | | &csb,btTransform::getIdentity(), | |
| | | cla->m_com-clb->m_com,res)) | |
| { | | { | |
|
| btSoftBody::CJoint* pj=new(btAli | | btSoftBody::CJoint joint; | |
| gnedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint(); | | if(SolveContact(res,cla,clb,joint)) | |
| *pj=joint;bodies[0]->m_joints.push_b | | { | |
| ack(pj); | | btSoftBody::CJoint* pj=n | |
| pj->m_erp *= btMax(bodies | | ew(btAlignedAlloc(sizeof(btSoftBody::CJoint),16)) btSoftBody::CJoint(); | |
| [0]->m_cfg.kSSHR_CL,bodies[1]->m_cfg.kSSHR_CL); | | *pj=joint;bodies[0]->m_joint | |
| pj->m_split *= (bodies[0]-> | | s.push_back(pj); | |
| m_cfg.kSS_SPLT_CL+bodies[1]->m_cfg.kSS_SPLT_CL)/2; | | pj->m_erp *= btMa | |
| | | x(bodies[0]->m_cfg.kSSHR_CL,bodies[1]->m_cfg.kSSHR_CL); | |
| | | pj->m_split *= (bod | |
| | | ies[0]->m_cfg.kSS_SPLT_CL+bodies[1]->m_cfg.kSS_SPLT_CL)/2; | |
| | | } | |
| } | | } | |
|
| | | } else | |
| | | { | |
| | | static int count=0; | |
| | | count++; | |
| | | //printf("count=%d\n",count); | |
| | | | |
| } | | } | |
| } | | } | |
| void Process(btSoftBody* psa,btSoftBody* psb) | | void Process(btSoftBody* psa,btSoftBody* psb) | |
| { | | { | |
| idt = psa->m_sst.isdt; | | idt = psa->m_sst.isdt; | |
| margin = (psa->getCollisionShape()->g
etMargin()+psb->getCollisionShape()->getMargin())/2; | | margin = (psa->getCollisionShape()->g
etMargin()+psb->getCollisionShape()->getMargin())/2; | |
| friction = btMin(psa->m_cfg.kDF,psb->m_
cfg.kDF); | | friction = btMin(psa->m_cfg.kDF,psb->m_
cfg.kDF); | |
| bodies[0] = psa; | | bodies[0] = psa; | |
| bodies[1] = psb; | | bodies[1] = psb; | |
| psa->m_cdbvt.collideTT(psa->m_cdbvt.m_root,psb->m_cd
bvt.m_root,*this); | | psa->m_cdbvt.collideTT(psa->m_cdbvt.m_root,psb->m_cd
bvt.m_root,*this); | |
| | | | |
End of changes. 5 change blocks. |
| 20 lines changed or deleted | | 39 lines changed or added | |
|
| btSolverBody.h | | btSolverBody.h | |
| | | | |
| skipping to change at line 26 | | skipping to change at line 26 | |
| #ifndef BT_SOLVER_BODY_H | | #ifndef BT_SOLVER_BODY_H | |
| #define BT_SOLVER_BODY_H | | #define BT_SOLVER_BODY_H | |
| | | | |
| class btRigidBody; | | class btRigidBody; | |
| #include "LinearMath/btVector3.h" | | #include "LinearMath/btVector3.h" | |
| #include "LinearMath/btMatrix3x3.h" | | #include "LinearMath/btMatrix3x3.h" | |
| #include "BulletDynamics/Dynamics/btRigidBody.h" | | #include "BulletDynamics/Dynamics/btRigidBody.h" | |
| #include "LinearMath/btAlignedAllocator.h" | | #include "LinearMath/btAlignedAllocator.h" | |
| #include "LinearMath/btTransformUtil.h" | | #include "LinearMath/btTransformUtil.h" | |
| | | | |
|
| ///The btSolverBody is an internal datastructure for the constraint solver. | | ///Until we get other contributions, only use SIMD on Windows, when using V | |
| Only necessary data is packed to increase cache coherence/performance. | | isual Studio 2008 or later, and not double precision | |
| ATTRIBUTE_ALIGNED16 (struct) btSolverBody | | #ifdef BT_USE_SSE | |
| | | #define USE_SIMD 1 | |
| | | #endif // | |
| | | | |
| | | #ifdef USE_SIMD | |
| | | | |
| | | struct btSimdScalar | |
| { | | { | |
|
| BT_DECLARE_ALIGNED_ALLOCATOR(); | | SIMD_FORCE_INLINE btSimdScalar() | |
| | | { | |
| | | | |
|
| btMatrix3x3 m_worldInvInertiaTensor; | | } | |
| | | | |
|
| btVector3 m_angularVelocity; | | SIMD_FORCE_INLINE btSimdScalar(float fl) | |
| btVector3 m_linearVelocity; | | :m_vec128 (_mm_set1_ps(fl)) | |
| btVector3 m_centerOfMassPosition; | | { | |
| btVector3 m_pushVelocity; | | } | |
| btVector3 m_turnVelocity; | | | |
| | | | |
|
| float m_angularFactor; | | SIMD_FORCE_INLINE btSimdScalar(__m128 v128) | |
| float m_invMass; | | :m_vec128(v128) | |
| float m_friction; | | { | |
| btRigidBody* m_originalBody; | | } | |
| | | union | |
| | | { | |
| | | __m128 m_vec128; | |
| | | float m_floats[4]; | |
| | | int m_ints[4]; | |
| | | btScalar m_unusedPadding; | |
| | | }; | |
| | | SIMD_FORCE_INLINE __m128 get128() | |
| | | { | |
| | | return m_vec128; | |
| | | } | |
| | | | |
|
| SIMD_FORCE_INLINE void getVelocityInLocalPoint(const btVector3& rel
_pos, btVector3& velocity ) const | | SIMD_FORCE_INLINE const __m128 get128() const | |
| { | | { | |
|
| velocity = m_linearVelocity + m_angularVelocity.cross(rel_po
s); | | return m_vec128; | |
| } | | } | |
| | | | |
|
| //Optimization for the iterative solver: avoid calculating constant | | SIMD_FORCE_INLINE void set128(__m128 v128) | |
| terms involving inertia, normal, relative position | | | |
| SIMD_FORCE_INLINE void internalApplyImpulse(const btVector3& linearC | | | |
| omponent, const btVector3& angularComponent,btScalar impulseMagnitude) | | | |
| { | | { | |
|
| if (m_invMass) | | m_vec128 = v128; | |
| { | | | |
| m_linearVelocity += linearComponent*impulseMagnitude | | | |
| ; | | | |
| m_angularVelocity += angularComponent*(impulseMagnit | | | |
| ude*m_angularFactor); | | | |
| } | | | |
| } | | } | |
| | | | |
|
| SIMD_FORCE_INLINE void internalApplyPushImpulse(const btVector3& lin
earComponent, const btVector3& angularComponent,btScalar impulseMagnitude) | | SIMD_FORCE_INLINE operator __m128() | |
| { | | { | |
|
| if (m_invMass) | | return m_vec128; | |
| { | | } | |
| m_pushVelocity += linearComponent*impulseMagnitude; | | SIMD_FORCE_INLINE operator const __m128() const | |
| m_turnVelocity += angularComponent*(impulseMagnitude | | { | |
| *m_angularFactor); | | return m_vec128; | |
| } | | | |
| } | | } | |
| | | | |
|
| void writebackVelocity() | | SIMD_FORCE_INLINE operator float() const | |
| { | | { | |
|
| if (m_invMass) | | return m_floats[0]; | |
| { | | } | |
| m_originalBody->setLinearVelocity(m_linearVelocity); | | | |
| m_originalBody->setAngularVelocity(m_angularVelocity | | | |
| ); | | | |
| | | | |
|
| //m_originalBody->setCompanionId(-1); | | }; | |
| | | | |
| | | ///@brief Return the elementwise product of two btSimdScalar | |
| | | SIMD_FORCE_INLINE btSimdScalar | |
| | | operator*(const btSimdScalar& v1, const btSimdScalar& v2) | |
| | | { | |
| | | return btSimdScalar(_mm_mul_ps(v1.get128(),v2.get128())); | |
| | | } | |
| | | | |
| | | ///@brief Return the elementwise product of two btSimdScalar | |
| | | SIMD_FORCE_INLINE btSimdScalar | |
| | | operator+(const btSimdScalar& v1, const btSimdScalar& v2) | |
| | | { | |
| | | return btSimdScalar(_mm_add_ps(v1.get128(),v2.get128())); | |
| | | } | |
| | | | |
| | | #else | |
| | | #define btSimdScalar btScalar | |
| | | #endif | |
| | | | |
| | | ///The btSolverBody is an internal datastructure for the constraint solver. | |
| | | Only necessary data is packed to increase cache coherence/performance. | |
| | | ATTRIBUTE_ALIGNED16 (struct) btSolverBody | |
| | | { | |
| | | BT_DECLARE_ALIGNED_ALLOCATOR(); | |
| | | btVector3 m_deltaLinearVelocity; | |
| | | btVector3 m_deltaAngularVelocity; | |
| | | btScalar m_angularFactor; | |
| | | btScalar m_invMass; | |
| | | btScalar m_friction; | |
| | | btRigidBody* m_originalBody; | |
| | | btVector3 m_pushVelocity; | |
| | | //btVector3 m_turnVelocity; | |
| | | | |
| | | SIMD_FORCE_INLINE void getVelocityInLocalPointObsolete(const btVect | |
| | | or3& rel_pos, btVector3& velocity ) const | |
| | | { | |
| | | if (m_originalBody) | |
| | | velocity = m_originalBody->getLinearVelocity()+m_del | |
| | | taLinearVelocity + (m_originalBody->getAngularVelocity()+m_deltaAngularVelo | |
| | | city).cross(rel_pos); | |
| | | else | |
| | | velocity.setValue(0,0,0); | |
| | | } | |
| | | | |
| | | SIMD_FORCE_INLINE void getAngularVelocity(btVector3& angVel) const | |
| | | { | |
| | | if (m_originalBody) | |
| | | angVel = m_originalBody->getAngularVelocity()+m_delt | |
| | | aAngularVelocity; | |
| | | else | |
| | | angVel.setValue(0,0,0); | |
| | | } | |
| | | | |
| | | //Optimization for the iterative solver: avoid calculating constant | |
| | | terms involving inertia, normal, relative position | |
| | | SIMD_FORCE_INLINE void applyImpulse(const btVector3& linearComponent | |
| | | , const btVector3& angularComponent,const btScalar impulseMagnitude) | |
| | | { | |
| | | //if (m_invMass) | |
| | | { | |
| | | m_deltaLinearVelocity += linearComponent*impulseMagn | |
| | | itude; | |
| | | m_deltaAngularVelocity += angularComponent*(impulseM | |
| | | agnitude*m_angularFactor); | |
| } | | } | |
| } | | } | |
| | | | |
|
| void writebackVelocity(btScalar timeStep) | | /* | |
| | | | |
| | | void writebackVelocity() | |
| { | | { | |
| if (m_invMass) | | if (m_invMass) | |
| { | | { | |
|
| m_originalBody->setLinearVelocity(m_linearVelocity); | | m_originalBody->setLinearVelocity(m_originalBody->ge | |
| m_originalBody->setAngularVelocity(m_angularVelocity | | tLinearVelocity()+ m_deltaLinearVelocity); | |
| ); | | m_originalBody->setAngularVelocity(m_originalBody->g | |
| | | etAngularVelocity()+m_deltaAngularVelocity); | |
| //correct the position/orientation based on push/tur | | | |
| n recovery | | | |
| btTransform newTransform; | | | |
| btTransformUtil::integrateTransform(m_originalBody-> | | | |
| getWorldTransform(),m_pushVelocity,m_turnVelocity,timeStep,newTransform); | | | |
| m_originalBody->setWorldTransform(newTransform); | | | |
| | | | |
| //m_originalBody->setCompanionId(-1); | | //m_originalBody->setCompanionId(-1); | |
| } | | } | |
| } | | } | |
|
| | | */ | |
| | | | |
|
| void readVelocity() | | void writebackVelocity(btScalar timeStep=0) | |
| { | | { | |
| if (m_invMass) | | if (m_invMass) | |
| { | | { | |
|
| m_linearVelocity = m_originalBody->getLinearVelocity | | m_originalBody->setLinearVelocity(m_originalBody->ge | |
| (); | | tLinearVelocity()+m_deltaLinearVelocity); | |
| m_angularVelocity = m_originalBody->getAngularVeloci | | m_originalBody->setAngularVelocity(m_originalBody->g | |
| ty(); | | etAngularVelocity()+m_deltaAngularVelocity); | |
| | | //m_originalBody->setCompanionId(-1); | |
| } | | } | |
| } | | } | |
| | | | |
| }; | | }; | |
| | | | |
| #endif //BT_SOLVER_BODY_H | | #endif //BT_SOLVER_BODY_H | |
| | | | |
End of changes. 19 change blocks. |
| 57 lines changed or deleted | | 123 lines changed or added | |
|
| btTypedConstraint.h | | btTypedConstraint.h | |
| | | | |
| skipping to change at line 21 | | skipping to change at line 21 | |
| 1. The origin of this software must not be misrepresented; you must not cla
im that you wrote the original software. If you use this software in a prod
uct, an acknowledgment in the product documentation would be appreciated bu
t is not required. | | 1. The origin of this software must not be misrepresented; you must not cla
im that you wrote the original software. If you use this software in a prod
uct, an acknowledgment in the product documentation would be appreciated bu
t is not required. | |
| 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. | | 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. | |
| 3. This notice may not be removed or altered from any source distribution. | | 3. This notice may not be removed or altered from any source distribution. | |
| */ | | */ | |
| | | | |
| #ifndef TYPED_CONSTRAINT_H | | #ifndef TYPED_CONSTRAINT_H | |
| #define TYPED_CONSTRAINT_H | | #define TYPED_CONSTRAINT_H | |
| | | | |
| class btRigidBody; | | class btRigidBody; | |
| #include "LinearMath/btScalar.h" | | #include "LinearMath/btScalar.h" | |
|
| | | #include "btSolverConstraint.h" | |
| | | struct btSolverBody; | |
| | | | |
| enum btTypedConstraintType | | enum btTypedConstraintType | |
| { | | { | |
| POINT2POINT_CONSTRAINT_TYPE, | | POINT2POINT_CONSTRAINT_TYPE, | |
| HINGE_CONSTRAINT_TYPE, | | HINGE_CONSTRAINT_TYPE, | |
| CONETWIST_CONSTRAINT_TYPE, | | CONETWIST_CONSTRAINT_TYPE, | |
| D6_CONSTRAINT_TYPE, | | D6_CONSTRAINT_TYPE, | |
|
| VEHICLE_CONSTRAINT_TYPE, | | | |
| SLIDER_CONSTRAINT_TYPE | | SLIDER_CONSTRAINT_TYPE | |
| }; | | }; | |
| | | | |
| ///TypedConstraint is the baseclass for Bullet constraints and vehicles | | ///TypedConstraint is the baseclass for Bullet constraints and vehicles | |
| class btTypedConstraint | | class btTypedConstraint | |
| { | | { | |
| int m_userConstraintType; | | int m_userConstraintType; | |
| int m_userConstraintId; | | int m_userConstraintId; | |
| | | | |
| btTypedConstraintType m_constraintType; | | btTypedConstraintType m_constraintType; | |
| | | | |
| skipping to change at line 51 | | skipping to change at line 52 | |
| { | | { | |
| btAssert(0); | | btAssert(0); | |
| (void) other; | | (void) other; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| protected: | | protected: | |
| btRigidBody& m_rbA; | | btRigidBody& m_rbA; | |
| btRigidBody& m_rbB; | | btRigidBody& m_rbB; | |
| btScalar m_appliedImpulse; | | btScalar m_appliedImpulse; | |
|
| | | btScalar m_dbgDrawSize; | |
| | | | |
| public: | | public: | |
| | | | |
| btTypedConstraint(btTypedConstraintType type); | | btTypedConstraint(btTypedConstraintType type); | |
| virtual ~btTypedConstraint() {}; | | virtual ~btTypedConstraint() {}; | |
| btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA); | | btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA); | |
|
| | | | |
| btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRig
idBody& rbB); | | btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRig
idBody& rbB); | |
| | | | |
|
| | | struct btConstraintInfo1 { | |
| | | int m_numConstraintRows,nub; | |
| | | }; | |
| | | | |
| | | struct btConstraintInfo2 { | |
| | | // integrator parameters: frames per second (1/stepsize), de | |
| | | fault error | |
| | | // reduction parameter (0..1). | |
| | | btScalar fps,erp; | |
| | | | |
| | | // for the first and second body, pointers to two (linear an | |
| | | d angular) | |
| | | // n*3 jacobian sub matrices, stored by rows. these matrices | |
| | | will have | |
| | | // been initialized to 0 on entry. if the second body is zer | |
| | | o then the | |
| | | // J2xx pointers may be 0. | |
| | | btScalar *m_J1linearAxis,*m_J1angularAxis,*m_J2linearAxis,*m | |
| | | _J2angularAxis; | |
| | | | |
| | | // elements to jump from one row to the next in J's | |
| | | int rowskip; | |
| | | | |
| | | // right hand sides of the equation J*v = c + cfm * lambda. | |
| | | cfm is the | |
| | | // "constraint force mixing" vector. c is set to zero on ent | |
| | | ry, cfm is | |
| | | // set to a constant value (typically very small or zero) va | |
| | | lue on entry. | |
| | | btScalar *m_constraintError,*cfm; | |
| | | | |
| | | // lo and hi limits for variables (set to -/+ infinity on en | |
| | | try). | |
| | | btScalar *m_lowerLimit,*m_upperLimit; | |
| | | | |
| | | // findex vector for variables. see the LCP solver interface | |
| | | for a | |
| | | // description of what this does. this is set to -1 on entry | |
| | | . | |
| | | // note that the returned indexes are relative to the first | |
| | | index of | |
| | | // the constraint. | |
| | | int *findex; | |
| | | }; | |
| | | | |
| virtual void buildJacobian() = 0; | | virtual void buildJacobian() = 0; | |
| | | | |
|
| virtual void solveConstraint(btScalar timeStep) = 0; | | virtual void setupSolverConstraint(btConstraintArray& ca, int sol | |
| | | verBodyA,int solverBodyB, btScalar timeStep) | |
| | | { | |
| | | } | |
| | | virtual void getInfo1 (btConstraintInfo1* info)=0; | |
| | | | |
| | | virtual void getInfo2 (btConstraintInfo2* info)=0; | |
| | | | |
| | | virtual void solveConstraintObsolete(btSolverBody& bodyA,btSolver | |
| | | Body& bodyB,btScalar timeStep) = 0; | |
| | | | |
| | | btScalar getMotorFactor(btScalar pos, btScalar lowLim, btScalar uppL | |
| | | im, btScalar vel, btScalar timeFact); | |
| | | | |
| const btRigidBody& getRigidBodyA() const | | const btRigidBody& getRigidBodyA() const | |
| { | | { | |
| return m_rbA; | | return m_rbA; | |
| } | | } | |
| const btRigidBody& getRigidBodyB() const | | const btRigidBody& getRigidBodyB() const | |
| { | | { | |
| return m_rbB; | | return m_rbB; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 117 | | skipping to change at line 160 | |
| btScalar getAppliedImpulse() const | | btScalar getAppliedImpulse() const | |
| { | | { | |
| return m_appliedImpulse; | | return m_appliedImpulse; | |
| } | | } | |
| | | | |
| btTypedConstraintType getConstraintType () const | | btTypedConstraintType getConstraintType () const | |
| { | | { | |
| return m_constraintType; | | return m_constraintType; | |
| } | | } | |
| | | | |
|
| | | void setDbgDrawSize(btScalar dbgDrawSize) | |
| | | { | |
| | | m_dbgDrawSize = dbgDrawSize; | |
| | | } | |
| | | btScalar getDbgDrawSize() | |
| | | { | |
| | | return m_dbgDrawSize; | |
| | | } | |
| | | | |
| }; | | }; | |
| | | | |
| #endif //TYPED_CONSTRAINT_H | | #endif //TYPED_CONSTRAINT_H | |
| | | | |
End of changes. 7 change blocks. |
| 3 lines changed or deleted | | 70 lines changed or added | |
|
| btVector3.h | | btVector3.h | |
| | | | |
| skipping to change at line 18 | | skipping to change at line 18 | |
| subject to the following restrictions: | | subject to the following restrictions: | |
| | | | |
| 1. The origin of this software must not be misrepresented; you must not cla
im that you wrote the original software. If you use this software in a prod
uct, an acknowledgment in the product documentation would be appreciated bu
t is not required. | | 1. The origin of this software must not be misrepresented; you must not cla
im that you wrote the original software. If you use this software in a prod
uct, an acknowledgment in the product documentation would be appreciated bu
t is not required. | |
| 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. | | 2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software. | |
| 3. This notice may not be removed or altered from any source distribution. | | 3. This notice may not be removed or altered from any source distribution. | |
| */ | | */ | |
| | | | |
| #ifndef SIMD__VECTOR3_H | | #ifndef SIMD__VECTOR3_H | |
| #define SIMD__VECTOR3_H | | #define SIMD__VECTOR3_H | |
| | | | |
|
| #include "btQuadWord.h" | | #include "btScalar.h" | |
| | | #include "btScalar.h" | |
| | | #include "btMinMax.h" | |
| /**@brief btVector3 can be used to represent 3D points and vectors. | | /**@brief btVector3 can be used to represent 3D points and vectors. | |
| * It has an un-used w component to suit 16-byte alignment when btVector3 i
s stored in containers. This extra component can be used by derived classes
(Quaternion?) or by user | | * It has an un-used w component to suit 16-byte alignment when btVector3 i
s stored in containers. This extra component can be used by derived classes
(Quaternion?) or by user | |
| * Ideally, this class should be replaced by a platform optimized SIMD vers
ion that keeps the data in registers | | * Ideally, this class should be replaced by a platform optimized SIMD vers
ion that keeps the data in registers | |
| */ | | */ | |
|
| class btVector3 : public btQuadWord { | | | |
| | | | |
|
| | | ATTRIBUTE_ALIGNED16(class) btVector3 | |
| | | { | |
| public: | | public: | |
|
| /**@brief No initialization constructor */ | | | |
| SIMD_FORCE_INLINE btVector3() {} | | | |
| | | | |
|
| /**@brief Constructor from btQuadWordStorage (btVector3 inherits from thi | | #if defined (__SPU__) && defined (__CELLOS_LV2__) | |
| s so is also valid) | | union { | |
| * Note: Vector3 derives from btQuadWordStorage*/ | | vec_float4 mVec128; | |
| SIMD_FORCE_INLINE btVector3(const btQuadWordStorage& q) | | btScalar m_floats[4]; | |
| : btQuadWord(q) | | }; | |
| | | public: | |
| | | vec_float4 get128() const | |
| { | | { | |
|
| | | return mVec128; | |
| } | | } | |
|
| | | public: | |
| | | #else //__CELLOS_LV2__ __SPU__ | |
| | | #ifdef BT_USE_SSE // WIN32 | |
| | | union { | |
| | | __m128 mVec128; | |
| | | btScalar m_floats[4]; | |
| | | }; | |
| | | SIMD_FORCE_INLINE __m128 get128() const | |
| | | { | |
| | | return mVec128; | |
| | | } | |
| | | SIMD_FORCE_INLINE void set128(__m128 v128) | |
| | | { | |
| | | mVec128 = v128; | |
| | | } | |
| | | #else | |
| | | btScalar m_floats[4]; | |
| | | #endif | |
| | | #endif //__CELLOS_LV2__ __SPU__ | |
| | | | |
| | | public: | |
| | | | |
| | | /**@brief No initialization constructor */ | |
| | | SIMD_FORCE_INLINE btVector3() {} | |
| | | | |
| /**@brief Constructor from scalars | | /**@brief Constructor from scalars | |
| * @param x X value | | * @param x X value | |
| * @param y Y value | | * @param y Y value | |
| * @param z Z value | | * @param z Z value | |
| */ | | */ | |
| SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, co
nst btScalar& z) | | SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, co
nst btScalar& z) | |
|
| :btQuadWord(x,y,z,btScalar(0.)) | | | |
| { | | { | |
|
| | | m_floats[0] = x; | |
| | | m_floats[1] = y; | |
| | | m_floats[2] = z; | |
| | | m_floats[3] = btScalar(0.); | |
| } | | } | |
| | | | |
|
| // SIMD_FORCE_INLINE btVector3(const btScalar& x, const btScalar& y, co | | | |
| nst btScalar& z,const btScalar& w) | | | |
| // : btQuadWord(x,y,z,w) | | | |
| // { | | | |
| // } | | | |
| | | | |
| /**@brief Add a vector to this one | | /**@brief Add a vector to this one | |
| * @param The vector to add to this one */ | | * @param The vector to add to this one */ | |
| SIMD_FORCE_INLINE btVector3& operator+=(const btVector3& v) | | SIMD_FORCE_INLINE btVector3& operator+=(const btVector3& v) | |
| { | | { | |
| | | | |
|
| m_floats[0] += v.x(); m_floats[1] += v.y(); m_floats[2] += v
.z(); | | m_floats[0] += v.m_floats[0]; m_floats[1] += v.m_floats[1];m
_floats[2] += v.m_floats[2]; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| /**@brief Subtract a vector from this one | | /**@brief Subtract a vector from this one | |
| * @param The vector to subtract */ | | * @param The vector to subtract */ | |
| SIMD_FORCE_INLINE btVector3& operator-=(const btVector3& v) | | SIMD_FORCE_INLINE btVector3& operator-=(const btVector3& v) | |
| { | | { | |
|
| m_floats[0] -= v.x(); m_floats[1] -= v.y(); m_floats[2] -= v
.z(); | | m_floats[0] -= v.m_floats[0]; m_floats[1] -= v.m_floats[1];m
_floats[2] -= v.m_floats[2]; | |
| return *this; | | return *this; | |
| } | | } | |
| /**@brief Scale the vector | | /**@brief Scale the vector | |
| * @param s Scale factor */ | | * @param s Scale factor */ | |
| SIMD_FORCE_INLINE btVector3& operator*=(const btScalar& s) | | SIMD_FORCE_INLINE btVector3& operator*=(const btScalar& s) | |
| { | | { | |
|
| m_floats[0] *= s; m_floats[1] *= s; m_floats[2] *= s; | | m_floats[0] *= s; m_floats[1] *= s;m_floats[2] *= s; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| /**@brief Inversely scale the vector | | /**@brief Inversely scale the vector | |
| * @param s Scale factor to divide by */ | | * @param s Scale factor to divide by */ | |
| SIMD_FORCE_INLINE btVector3& operator/=(const btScalar& s) | | SIMD_FORCE_INLINE btVector3& operator/=(const btScalar& s) | |
| { | | { | |
| btFullAssert(s != btScalar(0.0)); | | btFullAssert(s != btScalar(0.0)); | |
| return *this *= btScalar(1.0) / s; | | return *this *= btScalar(1.0) / s; | |
| } | | } | |
| | | | |
| /**@brief Return the dot product | | /**@brief Return the dot product | |
| * @param v The other vector in the dot product */ | | * @param v The other vector in the dot product */ | |
| SIMD_FORCE_INLINE btScalar dot(const btVector3& v) const | | SIMD_FORCE_INLINE btScalar dot(const btVector3& v) const | |
| { | | { | |
|
| return m_floats[0] * v.x() + m_floats[1] * v.y() + m_floats[
2] * v.z(); | | return m_floats[0] * v.m_floats[0] + m_floats[1] * v.m_float
s[1] +m_floats[2] * v.m_floats[2]; | |
| } | | } | |
| | | | |
| /**@brief Return the length of the vector squared */ | | /**@brief Return the length of the vector squared */ | |
| SIMD_FORCE_INLINE btScalar length2() const | | SIMD_FORCE_INLINE btScalar length2() const | |
| { | | { | |
| return dot(*this); | | return dot(*this); | |
| } | | } | |
| | | | |
| /**@brief Return the length of the vector */ | | /**@brief Return the length of the vector */ | |
| SIMD_FORCE_INLINE btScalar length() const | | SIMD_FORCE_INLINE btScalar length() const | |
| | | | |
| skipping to change at line 147 | | skipping to change at line 173 | |
| return btVector3( | | return btVector3( | |
| btFabs(m_floats[0]), | | btFabs(m_floats[0]), | |
| btFabs(m_floats[1]), | | btFabs(m_floats[1]), | |
| btFabs(m_floats[2])); | | btFabs(m_floats[2])); | |
| } | | } | |
| /**@brief Return the cross product between this and another vector | | /**@brief Return the cross product between this and another vector | |
| * @param v The other vector */ | | * @param v The other vector */ | |
| SIMD_FORCE_INLINE btVector3 cross(const btVector3& v) const | | SIMD_FORCE_INLINE btVector3 cross(const btVector3& v) const | |
| { | | { | |
| return btVector3( | | return btVector3( | |
|
| m_floats[1] * v.z() - m_floats[2] * v.y(), | | m_floats[1] * v.m_floats[2] -m_floats[2] * v.m_float | |
| m_floats[2] * v.x() - m_floats[0] * v.z(), | | s[1], | |
| m_floats[0] * v.y() - m_floats[1] * v.x()); | | m_floats[2] * v.m_floats[0] - m_floats[0] * v.m_floa | |
| | | ts[2], | |
| | | m_floats[0] * v.m_floats[1] - m_floats[1] * v.m_floa | |
| | | ts[0]); | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE btScalar triple(const btVector3& v1, const btVecto
r3& v2) const | | SIMD_FORCE_INLINE btScalar triple(const btVector3& v1, const btVecto
r3& v2) const | |
| { | | { | |
|
| return m_floats[0] * (v1.y() * v2.z() - v1.z() * v2.y()) + | | return m_floats[0] * (v1.m_floats[1] * v2.m_floats[2] - v1.m | |
| m_floats[1] * (v1.z() * v2.x() - v1.x() * v2.z()) + | | _floats[2] * v2.m_floats[1]) + | |
| m_floats[2] * (v1.x() * v2.y() - v1.y() * v2.x()); | | m_floats[1] * (v1.m_floats[2] * v2.m_floats[0] - v1. | |
| | | m_floats[0] * v2.m_floats[2]) + | |
| | | m_floats[2] * (v1.m_floats[0] * v2.m_floats[1] - v1. | |
| | | m_floats[1] * v2.m_floats[0]); | |
| } | | } | |
| | | | |
| /**@brief Return the axis with the smallest value | | /**@brief Return the axis with the smallest value | |
| * Note return values are 0,1,2 for x, y, or z */ | | * Note return values are 0,1,2 for x, y, or z */ | |
| SIMD_FORCE_INLINE int minAxis() const | | SIMD_FORCE_INLINE int minAxis() const | |
| { | | { | |
|
| return m_floats[0] < m_floats[1] ? (m_floats[0] < m_floats[2
] ? 0 : 2) : (m_floats[1] < m_floats[2] ? 1 : 2); | | return m_floats[0] < m_floats[1] ? (m_floats[0] <m_floats[2]
? 0 : 2) : (m_floats[1] <m_floats[2] ? 1 : 2); | |
| } | | } | |
| | | | |
| /**@brief Return the axis with the largest value | | /**@brief Return the axis with the largest value | |
| * Note return values are 0,1,2 for x, y, or z */ | | * Note return values are 0,1,2 for x, y, or z */ | |
| SIMD_FORCE_INLINE int maxAxis() const | | SIMD_FORCE_INLINE int maxAxis() const | |
| { | | { | |
|
| return m_floats[0] < m_floats[1] ? (m_floats[1] < m_floats[2
] ? 2 : 1) : (m_floats[0] < m_floats[2] ? 2 : 0); | | return m_floats[0] < m_floats[1] ? (m_floats[1] <m_floats[2]
? 2 : 1) : (m_floats[0] <m_floats[2] ? 2 : 0); | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE int furthestAxis() const | | SIMD_FORCE_INLINE int furthestAxis() const | |
| { | | { | |
| return absolute().minAxis(); | | return absolute().minAxis(); | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE int closestAxis() const | | SIMD_FORCE_INLINE int closestAxis() const | |
| { | | { | |
| return absolute().maxAxis(); | | return absolute().maxAxis(); | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE void setInterpolate3(const btVector3& v0, const bt
Vector3& v1, btScalar rt) | | SIMD_FORCE_INLINE void setInterpolate3(const btVector3& v0, const bt
Vector3& v1, btScalar rt) | |
| { | | { | |
| btScalar s = btScalar(1.0) - rt; | | btScalar s = btScalar(1.0) - rt; | |
|
| m_floats[0] = s * v0.x() + rt * v1.x(); | | m_floats[0] = s * v0.m_floats[0] + rt * v1.m_floats[0]; | |
| m_floats[1] = s * v0.y() + rt * v1.y(); | | m_floats[1] = s * v0.m_floats[1] + rt * v1.m_floats[1]; | |
| m_floats[2] = s * v0.z() + rt * v1.z(); | | m_floats[2] = s * v0.m_floats[2] + rt * v1.m_floats[2]; | |
| //don't do the unused w component | | //don't do the unused w component | |
| // m_co[3] = s * v0[3] + rt * v1[3]; | | // m_co[3] = s * v0[3] + rt * v1[3]; | |
| } | | } | |
| | | | |
| /**@brief Return the linear interpolation between this and another vector | | /**@brief Return the linear interpolation between this and another vector | |
| * @param v The other vector | | * @param v The other vector | |
| * @param t The ration of this to v (t = 0 => return this, t=1 => return
other) */ | | * @param t The ration of this to v (t = 0 => return this, t=1 => return
other) */ | |
| SIMD_FORCE_INLINE btVector3 lerp(const btVector3& v, const btScalar&
t) const | | SIMD_FORCE_INLINE btVector3 lerp(const btVector3& v, const btScalar&
t) const | |
| { | | { | |
|
| return btVector3(m_floats[0] + (v.x() - m_floats[0]) * t, | | return btVector3(m_floats[0] + (v.m_floats[0] - m_floats[0]) | |
| m_floats[1] + (v.y() - m_floats[1]) * t, | | * t, | |
| m_floats[2] + (v.z() - m_floats[2]) * t); | | m_floats[1] + (v.m_floats[1] - m_floats[1]) * t, | |
| | | m_floats[2] + (v.m_floats[2] -m_floats[2]) * t); | |
| } | | } | |
| | | | |
| /**@brief Elementwise multiply this vector by the other | | /**@brief Elementwise multiply this vector by the other | |
| * @param v The other vector */ | | * @param v The other vector */ | |
| SIMD_FORCE_INLINE btVector3& operator*=(const btVector3& v) | | SIMD_FORCE_INLINE btVector3& operator*=(const btVector3& v) | |
| { | | { | |
|
| m_floats[0] *= v.x(); m_floats[1] *= v.y(); m_floats[2] *= v
.z(); | | m_floats[0] *= v.m_floats[0]; m_floats[1] *= v.m_floats[1];m
_floats[2] *= v.m_floats[2]; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
|
| | | /**@brief Return the x value */ | |
| | | SIMD_FORCE_INLINE const btScalar& getX() const { return m_fl | |
| | | oats[0]; } | |
| | | /**@brief Return the y value */ | |
| | | SIMD_FORCE_INLINE const btScalar& getY() const { return m_fl | |
| | | oats[1]; } | |
| | | /**@brief Return the z value */ | |
| | | SIMD_FORCE_INLINE const btScalar& getZ() const { return m_fl | |
| | | oats[2]; } | |
| | | /**@brief Set the x value */ | |
| | | SIMD_FORCE_INLINE void setX(btScalar x) { m_floats[0] = x;} | |
| | | ; | |
| | | /**@brief Set the y value */ | |
| | | SIMD_FORCE_INLINE void setY(btScalar y) { m_floats[1] = y;} | |
| | | ; | |
| | | /**@brief Set the z value */ | |
| | | SIMD_FORCE_INLINE void setZ(btScalar z) {m_floats[2] = z;}; | |
| | | /**@brief Set the w value */ | |
| | | SIMD_FORCE_INLINE void setW(btScalar w) { m_floats[3] = w;} | |
| | | ; | |
| | | /**@brief Return the x value */ | |
| | | SIMD_FORCE_INLINE const btScalar& x() const { return m_float | |
| | | s[0]; } | |
| | | /**@brief Return the y value */ | |
| | | SIMD_FORCE_INLINE const btScalar& y() const { return m_float | |
| | | s[1]; } | |
| | | /**@brief Return the z value */ | |
| | | SIMD_FORCE_INLINE const btScalar& z() const { return m_float | |
| | | s[2]; } | |
| | | /**@brief Return the w value */ | |
| | | SIMD_FORCE_INLINE const btScalar& w() const { return m_float | |
| | | s[3]; } | |
| | | | |
| | | //SIMD_FORCE_INLINE btScalar& operator[](int i) { return | |
| | | (&m_floats[0])[i]; } | |
| | | //SIMD_FORCE_INLINE const btScalar& operator[](int i) const { return | |
| | | (&m_floats[0])[i]; } | |
| | | ///operator btScalar*() replaces operator[], using implicit conversi | |
| | | on. We added operator != and operator == to avoid pointer comparisons. | |
| | | SIMD_FORCE_INLINE operator btScalar *() { return & | |
| | | m_floats[0]; } | |
| | | SIMD_FORCE_INLINE operator const btScalar *() const { return & | |
| | | m_floats[0]; } | |
| | | | |
| | | SIMD_FORCE_INLINE bool operator==(const btVector3& other) c | |
| | | onst | |
| | | { | |
| | | return ((m_floats[3]==other.m_floats[3]) && (m_floats[2]==ot | |
| | | her.m_floats[2]) && (m_floats[1]==other.m_floats[1]) && (m_floats[0]==other | |
| | | .m_floats[0])); | |
| | | } | |
| | | | |
| | | SIMD_FORCE_INLINE bool operator!=(const btVector3& other) c | |
| | | onst | |
| | | { | |
| | | return !(*this == other); | |
| | | } | |
| | | | |
| | | /**@brief Set each element to the max of the current values and the | |
| | | values of another btVector3 | |
| | | * @param other The other btVector3 to compare with | |
| | | */ | |
| | | SIMD_FORCE_INLINE void setMax(const btVector3& other) | |
| | | { | |
| | | btSetMax(m_floats[0], other.m_floats[0]); | |
| | | btSetMax(m_floats[1], other.m_floats[1]); | |
| | | btSetMax(m_floats[2], other.m_floats[2]); | |
| | | btSetMax(m_floats[3], other.w()); | |
| | | } | |
| | | /**@brief Set each element to the min of the current values and the value | |
| | | s of another btVector3 | |
| | | * @param other The other btVector3 to compare with | |
| | | */ | |
| | | SIMD_FORCE_INLINE void setMin(const btVector3& other) | |
| | | { | |
| | | btSetMin(m_floats[0], other.m_floats[0]); | |
| | | btSetMin(m_floats[1], other.m_floats[1]); | |
| | | btSetMin(m_floats[2], other.m_floats[2]); | |
| | | btSetMin(m_floats[3], other.w()); | |
| | | } | |
| | | | |
| | | SIMD_FORCE_INLINE void setValue(const btScalar& x, const bt | |
| | | Scalar& y, const btScalar& z) | |
| | | { | |
| | | m_floats[0]=x; | |
| | | m_floats[1]=y; | |
| | | m_floats[2]=z; | |
| | | m_floats[3] = 0.f; | |
| | | } | |
| | | | |
| | | void getSkewSymmetricMatrix(btVector3* v0,btVector3* v1,b | |
| | | tVector3* v2) const | |
| | | { | |
| | | v0->setValue(0. ,-z() ,y()); | |
| | | v1->setValue(z() ,0. ,-x( | |
| | | )); | |
| | | v2->setValue(-y() ,x() ,0.); | |
| | | } | |
| | | | |
| }; | | }; | |
| | | | |
| /**@brief Return the sum of two vectors (Point symantics)*/ | | /**@brief Return the sum of two vectors (Point symantics)*/ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| operator+(const btVector3& v1, const btVector3& v2) | | operator+(const btVector3& v1, const btVector3& v2) | |
| { | | { | |
|
| return btVector3(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z()); | | return btVector3(v1.m_floats[0] + v2.m_floats[0], v1.m_floats[1] + v
2.m_floats[1], v1.m_floats[2] + v2.m_floats[2]); | |
| } | | } | |
| | | | |
| /**@brief Return the elementwise product of two vectors */ | | /**@brief Return the elementwise product of two vectors */ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| operator*(const btVector3& v1, const btVector3& v2) | | operator*(const btVector3& v1, const btVector3& v2) | |
| { | | { | |
|
| return btVector3(v1.x() * v2.x(), v1.y() * v2.y(), v1.z() * v2.z()); | | return btVector3(v1.m_floats[0] * v2.m_floats[0], v1.m_floats[1] * v
2.m_floats[1], v1.m_floats[2] * v2.m_floats[2]); | |
| } | | } | |
| | | | |
| /**@brief Return the difference between two vectors */ | | /**@brief Return the difference between two vectors */ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| operator-(const btVector3& v1, const btVector3& v2) | | operator-(const btVector3& v1, const btVector3& v2) | |
| { | | { | |
|
| return btVector3(v1.x() - v2.x(), v1.y() - v2.y(), v1.z() - v2.z()); | | return btVector3(v1.m_floats[0] - v2.m_floats[0], v1.m_floats[1] - v
2.m_floats[1], v1.m_floats[2] - v2.m_floats[2]); | |
| } | | } | |
| /**@brief Return the negative of the vector */ | | /**@brief Return the negative of the vector */ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| operator-(const btVector3& v) | | operator-(const btVector3& v) | |
| { | | { | |
|
| return btVector3(-v.x(), -v.y(), -v.z()); | | return btVector3(-v.m_floats[0], -v.m_floats[1], -v.m_floats[2]); | |
| } | | } | |
| | | | |
| /**@brief Return the vector scaled by s */ | | /**@brief Return the vector scaled by s */ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| operator*(const btVector3& v, const btScalar& s) | | operator*(const btVector3& v, const btScalar& s) | |
| { | | { | |
|
| return btVector3(v.x() * s, v.y() * s, v.z() * s); | | return btVector3(v.m_floats[0] * s, v.m_floats[1] * s, v.m_floats[2]
* s); | |
| } | | } | |
| | | | |
| /**@brief Return the vector scaled by s */ | | /**@brief Return the vector scaled by s */ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| operator*(const btScalar& s, const btVector3& v) | | operator*(const btScalar& s, const btVector3& v) | |
| { | | { | |
| return v * s; | | return v * s; | |
| } | | } | |
| | | | |
| /**@brief Return the vector inversely scaled by s */ | | /**@brief Return the vector inversely scaled by s */ | |
| | | | |
| skipping to change at line 266 | | skipping to change at line 367 | |
| operator/(const btVector3& v, const btScalar& s) | | operator/(const btVector3& v, const btScalar& s) | |
| { | | { | |
| btFullAssert(s != btScalar(0.0)); | | btFullAssert(s != btScalar(0.0)); | |
| return v * (btScalar(1.0) / s); | | return v * (btScalar(1.0) / s); | |
| } | | } | |
| | | | |
| /**@brief Return the vector inversely scaled by s */ | | /**@brief Return the vector inversely scaled by s */ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| operator/(const btVector3& v1, const btVector3& v2) | | operator/(const btVector3& v1, const btVector3& v2) | |
| { | | { | |
|
| return btVector3(v1.x() / v2.x(),v1.y() / v2.y(),v1.z() / v2.z()); | | return btVector3(v1.m_floats[0] / v2.m_floats[0],v1.m_floats[1] / v2
.m_floats[1],v1.m_floats[2] / v2.m_floats[2]); | |
| } | | } | |
| | | | |
| /**@brief Return the dot product between two vectors */ | | /**@brief Return the dot product between two vectors */ | |
| SIMD_FORCE_INLINE btScalar | | SIMD_FORCE_INLINE btScalar | |
| dot(const btVector3& v1, const btVector3& v2) | | dot(const btVector3& v1, const btVector3& v2) | |
| { | | { | |
| return v1.dot(v2); | | return v1.dot(v2); | |
| } | | } | |
| | | | |
| /**@brief Return the distance squared between two vectors */ | | /**@brief Return the distance squared between two vectors */ | |
| | | | |
| skipping to change at line 320 | | skipping to change at line 421 | |
| /**@brief Return the linear interpolation between two vectors | | /**@brief Return the linear interpolation between two vectors | |
| * @param v1 One vector | | * @param v1 One vector | |
| * @param v2 The other vector | | * @param v2 The other vector | |
| * @param t The ration of this to v (t = 0 => return v1, t=1 => return v2)
*/ | | * @param t The ration of this to v (t = 0 => return v1, t=1 => return v2)
*/ | |
| SIMD_FORCE_INLINE btVector3 | | SIMD_FORCE_INLINE btVector3 | |
| lerp(const btVector3& v1, const btVector3& v2, const btScalar& t) | | lerp(const btVector3& v1, const btVector3& v2, const btScalar& t) | |
| { | | { | |
| return v1.lerp(v2, t); | | return v1.lerp(v2, t); | |
| } | | } | |
| | | | |
|
| /**@brief Test if each element of the vector is equivalent */ | | | |
| SIMD_FORCE_INLINE bool operator==(const btVector3& p1, const btVector3& p2) | | | |
| { | | | |
| return p1.x() == p2.x() && p1.y() == p2.y() && p1.z() == p2.z(); | | | |
| } | | | |
| | | | |
| SIMD_FORCE_INLINE btScalar btVector3::distance2(const btVector3& v) const | | SIMD_FORCE_INLINE btScalar btVector3::distance2(const btVector3& v) const | |
| { | | { | |
| return (v - *this).length2(); | | return (v - *this).length2(); | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const | | SIMD_FORCE_INLINE btScalar btVector3::distance(const btVector3& v) const | |
| { | | { | |
| return (v - *this).length(); | | return (v - *this).length(); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 394 | | skipping to change at line 489 | |
| maxVal = m_floats[0]; | | maxVal = m_floats[0]; | |
| } | | } | |
| if (m_floats[1] > maxVal) | | if (m_floats[1] > maxVal) | |
| { | | { | |
| maxIndex = 1; | | maxIndex = 1; | |
| maxVal = m_floats[1]; | | maxVal = m_floats[1]; | |
| } | | } | |
| if (m_floats[2] > maxVal) | | if (m_floats[2] > maxVal) | |
| { | | { | |
| maxIndex = 2; | | maxIndex = 2; | |
|
| maxVal = m_floats[2]; | | maxVal =m_floats[2]; | |
| } | | } | |
| if (m_floats[3] > maxVal) | | if (m_floats[3] > maxVal) | |
| { | | { | |
| maxIndex = 3; | | maxIndex = 3; | |
| maxVal = m_floats[3]; | | maxVal = m_floats[3]; | |
| } | | } | |
| | | | |
| return maxIndex; | | return maxIndex; | |
| | | | |
| } | | } | |
| | | | |
| skipping to change at line 423 | | skipping to change at line 518 | |
| minVal = m_floats[0]; | | minVal = m_floats[0]; | |
| } | | } | |
| if (m_floats[1] < minVal) | | if (m_floats[1] < minVal) | |
| { | | { | |
| minIndex = 1; | | minIndex = 1; | |
| minVal = m_floats[1]; | | minVal = m_floats[1]; | |
| } | | } | |
| if (m_floats[2] < minVal) | | if (m_floats[2] < minVal) | |
| { | | { | |
| minIndex = 2; | | minIndex = 2; | |
|
| minVal = m_floats[2]; | | minVal =m_floats[2]; | |
| } | | } | |
| if (m_floats[3] < minVal) | | if (m_floats[3] < minVal) | |
| { | | { | |
| minIndex = 3; | | minIndex = 3; | |
| minVal = m_floats[3]; | | minVal = m_floats[3]; | |
| } | | } | |
| | | | |
| return minIndex; | | return minIndex; | |
| | | | |
| } | | } | |
| | | | |
| SIMD_FORCE_INLINE int closestAxis4() const | | SIMD_FORCE_INLINE int closestAxis4() const | |
| { | | { | |
| return absolute4().maxAxis4(); | | return absolute4().maxAxis4(); | |
| } | | } | |
| | | | |
|
| | | /**@brief Set x,y,z and zero w | |
| | | * @param x Value of x | |
| | | * @param y Value of y | |
| | | * @param z Value of z | |
| | | */ | |
| | | | |
| | | /* void getValue(btScalar *m) const | |
| | | { | |
| | | m[0] = m_floats[0]; | |
| | | m[1] = m_floats[1]; | |
| | | m[2] =m_floats[2]; | |
| | | } | |
| | | */ | |
| | | /**@brief Set the values | |
| | | * @param x Value of x | |
| | | * @param y Value of y | |
| | | * @param z Value of z | |
| | | * @param w Value of w | |
| | | */ | |
| | | SIMD_FORCE_INLINE void setValue(const btScalar& x, const bt | |
| | | Scalar& y, const btScalar& z,const btScalar& w) | |
| | | { | |
| | | m_floats[0]=x; | |
| | | m_floats[1]=y; | |
| | | m_floats[2]=z; | |
| | | m_floats[3]=w; | |
| | | } | |
| | | | |
| }; | | }; | |
| | | | |
| ///btSwapVector3Endian swaps vector endianness, useful for network and cros
s-platform serialization | | ///btSwapVector3Endian swaps vector endianness, useful for network and cros
s-platform serialization | |
| SIMD_FORCE_INLINE void btSwapScalarEndian(const btScalar& sourceVal, btScal
ar& destVal) | | SIMD_FORCE_INLINE void btSwapScalarEndian(const btScalar& sourceVal, btScal
ar& destVal) | |
| { | | { | |
| #ifdef BT_USE_DOUBLE_PRECISION | | #ifdef BT_USE_DOUBLE_PRECISION | |
| unsigned char* dest = (unsigned char*) &destVal; | | unsigned char* dest = (unsigned char*) &destVal; | |
| unsigned char* src = (unsigned char*) &sourceVal; | | unsigned char* src = (unsigned char*) &sourceVal; | |
| dest[0] = src[7]; | | dest[0] = src[7]; | |
| dest[1] = src[6]; | | dest[1] = src[6]; | |
| | | | |
End of changes. 32 change blocks. |
| 50 lines changed or deleted | | 202 lines changed or added | |
|