make sure aligned structures/classes use the btAlignedAlloc/btAlignedFree, by overriding the operator new/delete for that struct/class.
integrated some contributions from IBM Germany for libspe2
This commit is contained in:
@@ -213,7 +213,8 @@ m_handleSentinel(handleSentinel)
|
|||||||
{
|
{
|
||||||
if (!m_pairCache)
|
if (!m_pairCache)
|
||||||
{
|
{
|
||||||
m_pairCache = new btOverlappingPairCache();
|
void* ptr = btAlignedAlloc(sizeof(btOverlappingPairCache),16);
|
||||||
|
m_pairCache = new(ptr) btOverlappingPairCache();
|
||||||
m_ownsPairCache = true;
|
m_ownsPairCache = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +231,8 @@ m_handleSentinel(handleSentinel)
|
|||||||
m_quantize = btVector3(btScalar(maxInt),btScalar(maxInt),btScalar(maxInt)) / aabbSize;
|
m_quantize = btVector3(btScalar(maxInt),btScalar(maxInt),btScalar(maxInt)) / aabbSize;
|
||||||
|
|
||||||
// allocate handles buffer and put all handles on free list
|
// allocate handles buffer and put all handles on free list
|
||||||
m_pHandles = new Handle[maxHandles];
|
void* ptr = btAlignedAlloc(sizeof(Handle)*maxHandles,16);
|
||||||
|
m_pHandles = new(ptr) Handle[maxHandles];
|
||||||
m_maxHandles = maxHandles;
|
m_maxHandles = maxHandles;
|
||||||
m_numHandles = 0;
|
m_numHandles = 0;
|
||||||
|
|
||||||
@@ -243,9 +245,12 @@ m_handleSentinel(handleSentinel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// allocate edge buffers
|
// allocate edge buffers
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
m_pEdges[i] = new Edge[maxHandles * 2];
|
{
|
||||||
|
void* ptr = btAlignedAlloc(sizeof(Edge)*maxHandles*2,16);
|
||||||
|
m_pEdges[i] = new(ptr) Edge[maxHandles * 2];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//removed overlap management
|
//removed overlap management
|
||||||
|
|
||||||
@@ -275,12 +280,14 @@ btAxisSweep3Internal<BP_FP_INT_TYPE>::~btAxisSweep3Internal()
|
|||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 2; i >= 0; i--)
|
for (int i = 2; i >= 0; i--)
|
||||||
delete[] m_pEdges[i];
|
{
|
||||||
delete[] m_pHandles;
|
btAlignedFree(m_pEdges[i]);
|
||||||
|
}
|
||||||
|
btAlignedFree(m_pHandles);
|
||||||
|
|
||||||
if (m_ownsPairCache)
|
if (m_ownsPairCache)
|
||||||
{
|
{
|
||||||
delete m_pairCache;
|
btAlignedFree(m_pairCache);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,117 +1,117 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 BT_MULTI_SAP_BROADPHASE
|
#ifndef BT_MULTI_SAP_BROADPHASE
|
||||||
#define BT_MULTI_SAP_BROADPHASE
|
#define BT_MULTI_SAP_BROADPHASE
|
||||||
|
|
||||||
#include "btBroadphaseInterface.h"
|
#include "btBroadphaseInterface.h"
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
#include "btOverlappingPairCache.h"
|
#include "btOverlappingPairCache.h"
|
||||||
|
|
||||||
class btAxisSweep3;
|
class btAxisSweep3;
|
||||||
class btSimpleBroadphase;
|
class btSimpleBroadphase;
|
||||||
|
|
||||||
|
|
||||||
typedef btAlignedObjectArray<btAxisSweep3*> btSapBroadphaseArray;
|
typedef btAlignedObjectArray<btAxisSweep3*> btSapBroadphaseArray;
|
||||||
|
|
||||||
///multi SAP broadphase
|
///multi SAP broadphase
|
||||||
///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=328
|
///See http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=328
|
||||||
///and http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
|
///and http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
|
||||||
class btMultiSapBroadphase :public btBroadphaseInterface
|
class btMultiSapBroadphase :public btBroadphaseInterface
|
||||||
{
|
{
|
||||||
btSapBroadphaseArray m_sapBroadphases;
|
btSapBroadphaseArray m_sapBroadphases;
|
||||||
|
|
||||||
btSimpleBroadphase* m_simpleBroadphase;
|
btSimpleBroadphase* m_simpleBroadphase;
|
||||||
|
|
||||||
btOverlappingPairCache* m_overlappingPairs;
|
btOverlappingPairCache* m_overlappingPairs;
|
||||||
|
|
||||||
btOverlapFilterCallback* m_filterCallback;
|
btOverlapFilterCallback* m_filterCallback;
|
||||||
|
|
||||||
int m_invalidPair;
|
int m_invalidPair;
|
||||||
|
|
||||||
struct btChildProxy
|
struct btChildProxy
|
||||||
{
|
{
|
||||||
btBroadphaseProxy* m_proxy;
|
btBroadphaseProxy* m_proxy;
|
||||||
btBroadphaseInterface* m_childBroadphase;
|
btBroadphaseInterface* m_childBroadphase;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct btMultiSapProxy : public btBroadphaseProxy
|
struct btMultiSapProxy : public btBroadphaseProxy
|
||||||
{
|
{
|
||||||
|
|
||||||
///array with all the entries that this proxy belongs to
|
///array with all the entries that this proxy belongs to
|
||||||
btAlignedObjectArray<btChildProxy*> m_childProxies;
|
btAlignedObjectArray<btChildProxy*> m_childProxies;
|
||||||
btVector3 m_aabbMin;
|
btVector3 m_aabbMin;
|
||||||
btVector3 m_aabbMax;
|
btVector3 m_aabbMax;
|
||||||
|
|
||||||
int m_shapeType;
|
int m_shapeType;
|
||||||
void* m_userPtr;
|
void* m_userPtr;
|
||||||
short int m_collisionFilterGroup;
|
short int m_collisionFilterGroup;
|
||||||
short int m_collisionFilterMask;
|
short int m_collisionFilterMask;
|
||||||
|
|
||||||
btMultiSapProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask)
|
btMultiSapProxy(const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask)
|
||||||
:m_aabbMin(aabbMin),
|
:m_aabbMin(aabbMin),
|
||||||
m_aabbMax(aabbMax),
|
m_aabbMax(aabbMax),
|
||||||
m_shapeType(shapeType),
|
m_shapeType(shapeType),
|
||||||
m_userPtr(userPtr),
|
m_userPtr(userPtr),
|
||||||
m_collisionFilterGroup(collisionFilterGroup),
|
m_collisionFilterGroup(collisionFilterGroup),
|
||||||
m_collisionFilterMask(collisionFilterMask)
|
m_collisionFilterMask(collisionFilterMask)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
|
btAlignedObjectArray<btMultiSapProxy*> m_multiSapProxies;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btMultiSapBroadphase(int maxProxies = 16384);
|
btMultiSapBroadphase(int maxProxies = 16384);
|
||||||
|
|
||||||
btSapBroadphaseArray getBroadphaseArray()
|
btSapBroadphaseArray getBroadphaseArray()
|
||||||
{
|
{
|
||||||
return m_sapBroadphases;
|
return m_sapBroadphases;
|
||||||
}
|
}
|
||||||
|
|
||||||
const btSapBroadphaseArray getBroadphaseArray() const
|
const btSapBroadphaseArray getBroadphaseArray() const
|
||||||
{
|
{
|
||||||
return m_sapBroadphases;
|
return m_sapBroadphases;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~btMultiSapBroadphase();
|
virtual ~btMultiSapBroadphase();
|
||||||
|
|
||||||
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask);
|
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask);
|
||||||
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
virtual void destroyProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||||
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);
|
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);
|
||||||
|
|
||||||
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
|
||||||
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
virtual void calculateOverlappingPairs(btDispatcher* dispatcher);
|
||||||
|
|
||||||
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||||
|
|
||||||
virtual btOverlappingPairCache* getOverlappingPairCache()
|
virtual btOverlappingPairCache* getOverlappingPairCache()
|
||||||
{
|
{
|
||||||
return m_overlappingPairs;
|
return m_overlappingPairs;
|
||||||
}
|
}
|
||||||
virtual const btOverlappingPairCache* getOverlappingPairCache() const
|
virtual const btOverlappingPairCache* getOverlappingPairCache() const
|
||||||
{
|
{
|
||||||
return m_overlappingPairs;
|
return m_overlappingPairs;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //BT_MULTI_SAP_BROADPHASE
|
#endif //BT_MULTI_SAP_BROADPHASE
|
||||||
|
|||||||
@@ -1,129 +1,129 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 OVERLAPPING_PAIR_CACHE_H
|
#ifndef OVERLAPPING_PAIR_CACHE_H
|
||||||
#define OVERLAPPING_PAIR_CACHE_H
|
#define OVERLAPPING_PAIR_CACHE_H
|
||||||
|
|
||||||
|
|
||||||
#include "btBroadphaseInterface.h"
|
#include "btBroadphaseInterface.h"
|
||||||
#include "btBroadphaseProxy.h"
|
#include "btBroadphaseProxy.h"
|
||||||
#include "LinearMath/btPoint3.h"
|
#include "LinearMath/btPoint3.h"
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
class btDispatcher;
|
class btDispatcher;
|
||||||
|
|
||||||
struct btOverlapCallback
|
struct btOverlapCallback
|
||||||
{
|
{
|
||||||
virtual ~btOverlapCallback()
|
virtual ~btOverlapCallback()
|
||||||
{}
|
{}
|
||||||
//return true for deletion of the pair
|
//return true for deletion of the pair
|
||||||
virtual bool processOverlap(btBroadphasePair& pair) = 0;
|
virtual bool processOverlap(btBroadphasePair& pair) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct btOverlapFilterCallback
|
struct btOverlapFilterCallback
|
||||||
{
|
{
|
||||||
virtual ~btOverlapFilterCallback()
|
virtual ~btOverlapFilterCallback()
|
||||||
{}
|
{}
|
||||||
// return true when pairs need collision
|
// return true when pairs need collision
|
||||||
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const = 0;
|
virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef btAlignedObjectArray<btBroadphasePair> btBroadphasePairArray;
|
typedef btAlignedObjectArray<btBroadphasePair> btBroadphasePairArray;
|
||||||
|
|
||||||
///btOverlappingPairCache maintains the objects with overlapping AABB
|
///btOverlappingPairCache maintains the objects with overlapping AABB
|
||||||
///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase
|
///Typically managed by the Broadphase, Axis3Sweep or btSimpleBroadphase
|
||||||
class btOverlappingPairCache
|
class btOverlappingPairCache
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
//avoid brute-force finding all the time
|
//avoid brute-force finding all the time
|
||||||
btBroadphasePairArray m_overlappingPairArray;
|
btBroadphasePairArray m_overlappingPairArray;
|
||||||
|
|
||||||
//during the dispatch, check that user doesn't destroy/create proxy
|
//during the dispatch, check that user doesn't destroy/create proxy
|
||||||
bool m_blockedForChanges;
|
bool m_blockedForChanges;
|
||||||
|
|
||||||
//if set, use the callback instead of the built in filter in needBroadphaseCollision
|
//if set, use the callback instead of the built in filter in needBroadphaseCollision
|
||||||
btOverlapFilterCallback* m_overlapFilterCallback;
|
btOverlapFilterCallback* m_overlapFilterCallback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btOverlappingPairCache();
|
btOverlappingPairCache();
|
||||||
virtual ~btOverlappingPairCache();
|
virtual ~btOverlappingPairCache();
|
||||||
|
|
||||||
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
|
virtual void processAllOverlappingPairs(btOverlapCallback*,btDispatcher* dispatcher);
|
||||||
|
|
||||||
void removeOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
void removeOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
||||||
|
|
||||||
void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
void cleanOverlappingPair(btBroadphasePair& pair,btDispatcher* dispatcher);
|
||||||
|
|
||||||
void addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
void addOverlappingPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||||
|
|
||||||
btBroadphasePair* findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
btBroadphasePair* findPair(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
|
||||||
|
|
||||||
|
|
||||||
void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
void cleanProxyFromPairs(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||||
|
|
||||||
void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
void removeOverlappingPairsContainingProxy(btBroadphaseProxy* proxy,btDispatcher* dispatcher);
|
||||||
|
|
||||||
|
|
||||||
inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
|
inline bool needsBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
|
||||||
{
|
{
|
||||||
if (m_overlapFilterCallback)
|
if (m_overlapFilterCallback)
|
||||||
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
|
return m_overlapFilterCallback->needBroadphaseCollision(proxy0,proxy1);
|
||||||
|
|
||||||
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
bool collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
|
||||||
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
|
||||||
|
|
||||||
return collides;
|
return collides;
|
||||||
}
|
}
|
||||||
|
|
||||||
btBroadphasePairArray& getOverlappingPairArray()
|
btBroadphasePairArray& getOverlappingPairArray()
|
||||||
{
|
{
|
||||||
return m_overlappingPairArray;
|
return m_overlappingPairArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
const btBroadphasePairArray& getOverlappingPairArray() const
|
const btBroadphasePairArray& getOverlappingPairArray() const
|
||||||
{
|
{
|
||||||
return m_overlappingPairArray;
|
return m_overlappingPairArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
btBroadphasePair* getOverlappingPairArrayPtr()
|
btBroadphasePair* getOverlappingPairArrayPtr()
|
||||||
{
|
{
|
||||||
return &m_overlappingPairArray[0];
|
return &m_overlappingPairArray[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
const btBroadphasePair* getOverlappingPairArrayPtr() const
|
||||||
{
|
{
|
||||||
return &m_overlappingPairArray[0];
|
return &m_overlappingPairArray[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNumOverlappingPairs() const
|
int getNumOverlappingPairs() const
|
||||||
{
|
{
|
||||||
return m_overlappingPairArray.size();
|
return m_overlappingPairArray.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
btOverlapFilterCallback* getOverlapFilterCallback()
|
btOverlapFilterCallback* getOverlapFilterCallback()
|
||||||
{
|
{
|
||||||
return m_overlapFilterCallback;
|
return m_overlapFilterCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setOverlapFilterCallback(btOverlapFilterCallback* callback)
|
void setOverlapFilterCallback(btOverlapFilterCallback* callback)
|
||||||
{
|
{
|
||||||
m_overlapFilterCallback = callback;
|
m_overlapFilterCallback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif //OVERLAPPING_PAIR_CACHE_H
|
#endif //OVERLAPPING_PAIR_CACHE_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 SPHERE_TRIANGLE_DETECTOR_H
|
#ifndef SPHERE_TRIANGLE_DETECTOR_H
|
||||||
#define SPHERE_TRIANGLE_DETECTOR_H
|
#define SPHERE_TRIANGLE_DETECTOR_H
|
||||||
|
|
||||||
#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
|
#include "BulletCollision/NarrowPhaseCollision/btDiscreteCollisionDetectorInterface.h"
|
||||||
#include "LinearMath/btPoint3.h"
|
#include "LinearMath/btPoint3.h"
|
||||||
|
|
||||||
|
|
||||||
class btSphereShape;
|
class btSphereShape;
|
||||||
class btTriangleShape;
|
class btTriangleShape;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// sphere-triangle to match the btDiscreteCollisionDetectorInterface
|
/// sphere-triangle to match the btDiscreteCollisionDetectorInterface
|
||||||
struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface
|
struct SphereTriangleDetector : public btDiscreteCollisionDetectorInterface
|
||||||
{
|
{
|
||||||
virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw);
|
virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw);
|
||||||
|
|
||||||
SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle);
|
SphereTriangleDetector(btSphereShape* sphere,btTriangleShape* triangle);
|
||||||
|
|
||||||
virtual ~SphereTriangleDetector() {};
|
virtual ~SphereTriangleDetector() {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact);
|
bool collide(const btVector3& sphereCenter,btVector3 &point, btVector3& resultNormal, btScalar& depth, btScalar &timeOfImpact);
|
||||||
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
|
bool pointInTriangle(const btVector3 vertices[], const btVector3 &normal, btVector3 *p );
|
||||||
bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
|
bool facecontains(const btVector3 &p,const btVector3* vertices,btVector3& normal);
|
||||||
|
|
||||||
btSphereShape* m_sphere;
|
btSphereShape* m_sphere;
|
||||||
btTriangleShape* m_triangle;
|
btTriangleShape* m_triangle;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif //SPHERE_TRIANGLE_DETECTOR_H
|
#endif //SPHERE_TRIANGLE_DETECTOR_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,46 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 COLLISION_CREATE_FUNC
|
#ifndef COLLISION_CREATE_FUNC
|
||||||
#define COLLISION_CREATE_FUNC
|
#define COLLISION_CREATE_FUNC
|
||||||
|
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
typedef btAlignedObjectArray<class btCollisionObject*> btCollisionObjectArray;
|
typedef btAlignedObjectArray<class btCollisionObject*> btCollisionObjectArray;
|
||||||
class btCollisionAlgorithm;
|
class btCollisionAlgorithm;
|
||||||
class btCollisionObject;
|
class btCollisionObject;
|
||||||
|
|
||||||
struct btCollisionAlgorithmConstructionInfo;
|
struct btCollisionAlgorithmConstructionInfo;
|
||||||
|
|
||||||
///Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm
|
///Used by the btCollisionDispatcher to register and create instances for btCollisionAlgorithm
|
||||||
struct btCollisionAlgorithmCreateFunc
|
struct btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
bool m_swapped;
|
bool m_swapped;
|
||||||
|
|
||||||
btCollisionAlgorithmCreateFunc()
|
btCollisionAlgorithmCreateFunc()
|
||||||
:m_swapped(false)
|
:m_swapped(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual ~btCollisionAlgorithmCreateFunc(){};
|
virtual ~btCollisionAlgorithmCreateFunc(){};
|
||||||
|
|
||||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& , btCollisionObject* body0,btCollisionObject* body1)
|
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& , btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)body0;
|
(void)body0;
|
||||||
(void)body1;
|
(void)body1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif //COLLISION_CREATE_FUNC
|
#endif //COLLISION_CREATE_FUNC
|
||||||
|
|
||||||
|
|||||||
@@ -117,64 +117,19 @@ void btCollisionDispatcher::releaseManifold(btPersistentManifold* manifold)
|
|||||||
|
|
||||||
btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
|
btCollisionAlgorithm* btCollisionDispatcher::findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef USE_DISPATCH_REGISTRY_ARRAY
|
|
||||||
|
|
||||||
btCollisionAlgorithmConstructionInfo ci;
|
btCollisionAlgorithmConstructionInfo ci;
|
||||||
|
|
||||||
ci.m_dispatcher1 = this;
|
ci.m_dispatcher1 = this;
|
||||||
ci.m_manifold = sharedManifold;
|
ci.m_manifold = sharedManifold;
|
||||||
btCollisionAlgorithm* algo = m_doubleDispatch[body0->getCollisionShape()->getShapeType()][body1->getCollisionShape()->getShapeType()]
|
btCollisionAlgorithm* algo = m_doubleDispatch[body0->getCollisionShape()->getShapeType()][body1->getCollisionShape()->getShapeType()]->CreateCollisionAlgorithm(ci,body0,body1);
|
||||||
->CreateCollisionAlgorithm(ci,body0,body1);
|
|
||||||
#else
|
|
||||||
btCollisionAlgorithm* algo = internalFindAlgorithm(body0,body1);
|
|
||||||
#endif //USE_DISPATCH_REGISTRY_ARRAY
|
|
||||||
return algo;
|
return algo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef USE_DISPATCH_REGISTRY_ARRAY
|
|
||||||
|
|
||||||
btCollisionAlgorithm* btCollisionDispatcher::internalFindAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold)
|
|
||||||
{
|
|
||||||
m_count++;
|
|
||||||
|
|
||||||
btCollisionAlgorithmConstructionInfo ci;
|
|
||||||
ci.m_dispatcher = this;
|
|
||||||
|
|
||||||
if (body0->getCollisionShape()->isConvex() && body1->getCollisionShape()->isConvex() )
|
|
||||||
{
|
|
||||||
return new btConvexConvexAlgorithm(sharedManifold,ci,body0,body1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body0->getCollisionShape()->isConvex() && body1->getCollisionShape()->isConcave())
|
|
||||||
{
|
|
||||||
return new btConvexConcaveCollisionAlgorithm(ci,body0,body1,false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body1->getCollisionShape()->isConvex() && body0->getCollisionShape()->isConcave())
|
|
||||||
{
|
|
||||||
return new btConvexConcaveCollisionAlgorithm(ci,body0,body1,true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body0->getCollisionShape()->isCompound())
|
|
||||||
{
|
|
||||||
return new btCompoundCollisionAlgorithm(ci,body0,body1,false);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
if (body1->getCollisionShape()->isCompound())
|
|
||||||
{
|
|
||||||
return new btCompoundCollisionAlgorithm(ci,body0,body1,true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//failed to find an algorithm
|
|
||||||
return new btEmptyAlgorithm(ci);
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif //USE_DISPATCH_REGISTRY_ARRAY
|
|
||||||
|
|
||||||
bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
|
bool btCollisionDispatcher::needsResponse(btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
@@ -305,4 +260,4 @@ void* btCollisionDispatcher::allocateCollisionAlgorithm(int size)
|
|||||||
void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr)
|
void btCollisionDispatcher::freeCollisionAlgorithm(void* ptr)
|
||||||
{
|
{
|
||||||
m_collisionAlgorithmPoolAllocator->free(ptr);
|
m_collisionAlgorithmPoolAllocator->free(ptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ subject to the following restrictions:
|
|||||||
struct btBroadphaseProxy;
|
struct btBroadphaseProxy;
|
||||||
class btCollisionShape;
|
class btCollisionShape;
|
||||||
#include "LinearMath/btMotionState.h"
|
#include "LinearMath/btMotionState.h"
|
||||||
|
#include "LinearMath/btAlignedAllocator.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -89,6 +90,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
enum CollisionFlags
|
enum CollisionFlags
|
||||||
{
|
{
|
||||||
CF_STATIC_OBJECT= 1,
|
CF_STATIC_OBJECT= 1,
|
||||||
|
|||||||
@@ -1,61 +1,61 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 SIMULATION_ISLAND_MANAGER_H
|
#ifndef SIMULATION_ISLAND_MANAGER_H
|
||||||
#define SIMULATION_ISLAND_MANAGER_H
|
#define SIMULATION_ISLAND_MANAGER_H
|
||||||
|
|
||||||
#include "BulletCollision/CollisionDispatch/btUnionFind.h"
|
#include "BulletCollision/CollisionDispatch/btUnionFind.h"
|
||||||
#include "btCollisionCreateFunc.h"
|
#include "btCollisionCreateFunc.h"
|
||||||
|
|
||||||
class btCollisionObject;
|
class btCollisionObject;
|
||||||
class btCollisionWorld;
|
class btCollisionWorld;
|
||||||
class btDispatcher;
|
class btDispatcher;
|
||||||
|
|
||||||
///SimulationIslandManager creates and handles simulation islands, using btUnionFind
|
///SimulationIslandManager creates and handles simulation islands, using btUnionFind
|
||||||
class btSimulationIslandManager
|
class btSimulationIslandManager
|
||||||
{
|
{
|
||||||
btUnionFind m_unionFind;
|
btUnionFind m_unionFind;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btSimulationIslandManager();
|
btSimulationIslandManager();
|
||||||
virtual ~btSimulationIslandManager();
|
virtual ~btSimulationIslandManager();
|
||||||
|
|
||||||
|
|
||||||
void initUnionFind(int n);
|
void initUnionFind(int n);
|
||||||
|
|
||||||
|
|
||||||
btUnionFind& getUnionFind() { return m_unionFind;}
|
btUnionFind& getUnionFind() { return m_unionFind;}
|
||||||
|
|
||||||
virtual void updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher);
|
virtual void updateActivationState(btCollisionWorld* colWorld,btDispatcher* dispatcher);
|
||||||
virtual void storeIslandActivationState(btCollisionWorld* world);
|
virtual void storeIslandActivationState(btCollisionWorld* world);
|
||||||
|
|
||||||
|
|
||||||
void findUnions(btDispatcher* dispatcher);
|
void findUnions(btDispatcher* dispatcher);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct IslandCallback
|
struct IslandCallback
|
||||||
{
|
{
|
||||||
virtual ~IslandCallback() {};
|
virtual ~IslandCallback() {};
|
||||||
|
|
||||||
virtual void ProcessIsland(btCollisionObject** bodies,int numBodies,class btPersistentManifold** manifolds,int numManifolds, int islandId) = 0;
|
virtual void ProcessIsland(btCollisionObject** bodies,int numBodies,class btPersistentManifold** manifolds,int numManifolds, int islandId) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
|
void buildAndProcessIslands(btDispatcher* dispatcher,btCollisionObjectArray& collisionObjects, IslandCallback* callback);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SIMULATION_ISLAND_MANAGER_H
|
#endif //SIMULATION_ISLAND_MANAGER_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,67 +1,67 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 SPHERE_BOX_COLLISION_ALGORITHM_H
|
#ifndef SPHERE_BOX_COLLISION_ALGORITHM_H
|
||||||
#define SPHERE_BOX_COLLISION_ALGORITHM_H
|
#define SPHERE_BOX_COLLISION_ALGORITHM_H
|
||||||
|
|
||||||
#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
|
#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
|
||||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
||||||
#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
|
||||||
class btPersistentManifold;
|
class btPersistentManifold;
|
||||||
#include "btCollisionDispatcher.h"
|
#include "btCollisionDispatcher.h"
|
||||||
|
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
|
|
||||||
/// btSphereBoxCollisionAlgorithm provides sphere-box collision detection.
|
/// btSphereBoxCollisionAlgorithm provides sphere-box collision detection.
|
||||||
/// Other features are frame-coherency (persistent data) and collision response.
|
/// Other features are frame-coherency (persistent data) and collision response.
|
||||||
class btSphereBoxCollisionAlgorithm : public btCollisionAlgorithm
|
class btSphereBoxCollisionAlgorithm : public btCollisionAlgorithm
|
||||||
{
|
{
|
||||||
bool m_ownManifold;
|
bool m_ownManifold;
|
||||||
btPersistentManifold* m_manifoldPtr;
|
btPersistentManifold* m_manifoldPtr;
|
||||||
bool m_isSwapped;
|
bool m_isSwapped;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
|
btSphereBoxCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
|
||||||
|
|
||||||
virtual ~btSphereBoxCollisionAlgorithm();
|
virtual ~btSphereBoxCollisionAlgorithm();
|
||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
btScalar getSphereDistance( btCollisionObject* boxObj,btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius );
|
btScalar getSphereDistance( btCollisionObject* boxObj,btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius );
|
||||||
|
|
||||||
btScalar getSpherePenetration( btCollisionObject* boxObj, btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax);
|
btScalar getSpherePenetration( btCollisionObject* boxObj, btVector3& v3PointOnBox, btVector3& v3PointOnSphere, const btVector3& v3SphereCenter, btScalar fRadius, const btVector3& aabbMin, const btVector3& aabbMax);
|
||||||
|
|
||||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereBoxCollisionAlgorithm));
|
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereBoxCollisionAlgorithm));
|
||||||
if (!m_swapped)
|
if (!m_swapped)
|
||||||
{
|
{
|
||||||
return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,false);
|
return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,false);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,true);
|
return new(mem) btSphereBoxCollisionAlgorithm(0,ci,body0,body1,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SPHERE_BOX_COLLISION_ALGORITHM_H
|
#endif //SPHERE_BOX_COLLISION_ALGORITHM_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,59 +1,59 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 SPHERE_SPHERE_COLLISION_ALGORITHM_H
|
#ifndef SPHERE_SPHERE_COLLISION_ALGORITHM_H
|
||||||
#define SPHERE_SPHERE_COLLISION_ALGORITHM_H
|
#define SPHERE_SPHERE_COLLISION_ALGORITHM_H
|
||||||
|
|
||||||
#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
|
#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
|
||||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
||||||
#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
|
||||||
#include "btCollisionDispatcher.h"
|
#include "btCollisionDispatcher.h"
|
||||||
|
|
||||||
class btPersistentManifold;
|
class btPersistentManifold;
|
||||||
|
|
||||||
/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection.
|
/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection.
|
||||||
/// Other features are frame-coherency (persistent data) and collision response.
|
/// Other features are frame-coherency (persistent data) and collision response.
|
||||||
/// Also provides the most basic sample for custom/user btCollisionAlgorithm
|
/// Also provides the most basic sample for custom/user btCollisionAlgorithm
|
||||||
class btSphereSphereCollisionAlgorithm : public btCollisionAlgorithm
|
class btSphereSphereCollisionAlgorithm : public btCollisionAlgorithm
|
||||||
{
|
{
|
||||||
bool m_ownManifold;
|
bool m_ownManifold;
|
||||||
btPersistentManifold* m_manifoldPtr;
|
btPersistentManifold* m_manifoldPtr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
|
btSphereSphereCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1);
|
||||||
|
|
||||||
btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
btSphereSphereCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
||||||
: btCollisionAlgorithm(ci) {}
|
: btCollisionAlgorithm(ci) {}
|
||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
|
|
||||||
virtual ~btSphereSphereCollisionAlgorithm();
|
virtual ~btSphereSphereCollisionAlgorithm();
|
||||||
|
|
||||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereSphereCollisionAlgorithm));
|
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereSphereCollisionAlgorithm));
|
||||||
return new(mem) btSphereSphereCollisionAlgorithm(0,ci,body0,body1);
|
return new(mem) btSphereSphereCollisionAlgorithm(0,ci,body0,body1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SPHERE_SPHERE_COLLISION_ALGORITHM_H
|
#endif //SPHERE_SPHERE_COLLISION_ALGORITHM_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +1,62 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
|
#ifndef SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
|
||||||
#define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
|
#define SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
|
||||||
|
|
||||||
#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
|
#include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
|
||||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
|
||||||
#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
|
||||||
class btPersistentManifold;
|
class btPersistentManifold;
|
||||||
#include "btCollisionDispatcher.h"
|
#include "btCollisionDispatcher.h"
|
||||||
|
|
||||||
/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection.
|
/// btSphereSphereCollisionAlgorithm provides sphere-sphere collision detection.
|
||||||
/// Other features are frame-coherency (persistent data) and collision response.
|
/// Other features are frame-coherency (persistent data) and collision response.
|
||||||
/// Also provides the most basic sample for custom/user btCollisionAlgorithm
|
/// Also provides the most basic sample for custom/user btCollisionAlgorithm
|
||||||
class btSphereTriangleCollisionAlgorithm : public btCollisionAlgorithm
|
class btSphereTriangleCollisionAlgorithm : public btCollisionAlgorithm
|
||||||
{
|
{
|
||||||
bool m_ownManifold;
|
bool m_ownManifold;
|
||||||
btPersistentManifold* m_manifoldPtr;
|
btPersistentManifold* m_manifoldPtr;
|
||||||
bool m_swapped;
|
bool m_swapped;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool swapped);
|
btSphereTriangleCollisionAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool swapped);
|
||||||
|
|
||||||
btSphereTriangleCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
btSphereTriangleCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci)
|
||||||
: btCollisionAlgorithm(ci) {}
|
: btCollisionAlgorithm(ci) {}
|
||||||
|
|
||||||
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
|
||||||
|
|
||||||
|
|
||||||
virtual ~btSphereTriangleCollisionAlgorithm();
|
virtual ~btSphereTriangleCollisionAlgorithm();
|
||||||
|
|
||||||
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
struct CreateFunc :public btCollisionAlgorithmCreateFunc
|
||||||
{
|
{
|
||||||
|
|
||||||
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
|
||||||
{
|
{
|
||||||
|
|
||||||
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereTriangleCollisionAlgorithm));
|
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btSphereTriangleCollisionAlgorithm));
|
||||||
|
|
||||||
return new(mem) btSphereTriangleCollisionAlgorithm(ci.m_manifold,ci,body0,body1,m_swapped);
|
return new(mem) btSphereTriangleCollisionAlgorithm(ci.m_manifold,ci,body0,body1,m_swapped);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
|
#endif //SPHERE_TRIANGLE_COLLISION_ALGORITHM_H
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "btTriangleMeshShape.h"
|
#include "btTriangleMeshShape.h"
|
||||||
#include "btOptimizedBvh.h"
|
#include "btOptimizedBvh.h"
|
||||||
|
#include "LinearMath/btAlignedAllocator.h"
|
||||||
|
|
||||||
///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization.
|
///Bvh Concave triangle mesh is a static-triangle mesh shape with Bounding Volume Hierarchy optimization.
|
||||||
///Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
|
///Uses an interface to access the triangles to allow for sharing graphics/physics triangles.
|
||||||
@@ -31,6 +32,8 @@ ATTRIBUTE_ALIGNED16(class) btBvhTriangleMeshShape : public btTriangleMeshShape
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btBvhTriangleMeshShape() :btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {};
|
btBvhTriangleMeshShape() :btTriangleMeshShape(0),m_bvh(0),m_ownsBvh(false) {};
|
||||||
btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
|
btBvhTriangleMeshShape(btStridingMeshInterface* meshInterface, bool useQuantizedAabbCompression, bool buildBvh = true);
|
||||||
|
|
||||||
|
|||||||
@@ -1,60 +1,60 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 BT_CAPSULE_SHAPE_H
|
#ifndef BT_CAPSULE_SHAPE_H
|
||||||
#define BT_CAPSULE_SHAPE_H
|
#define BT_CAPSULE_SHAPE_H
|
||||||
|
|
||||||
#include "btConvexInternalShape.h"
|
#include "btConvexInternalShape.h"
|
||||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
|
||||||
|
|
||||||
|
|
||||||
///btCapsuleShape represents a capsule around the Y axis
|
///btCapsuleShape represents a capsule around the Y axis
|
||||||
///A more general solution that can represent capsules is the btMultiSphereShape
|
///A more general solution that can represent capsules is the btMultiSphereShape
|
||||||
class btCapsuleShape : public btConvexInternalShape
|
class btCapsuleShape : public btConvexInternalShape
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btCapsuleShape(btScalar radius,btScalar height);
|
btCapsuleShape(btScalar radius,btScalar height);
|
||||||
|
|
||||||
///CollisionShape Interface
|
///CollisionShape Interface
|
||||||
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia);
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia);
|
||||||
|
|
||||||
/// btConvexShape Interface
|
/// btConvexShape Interface
|
||||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||||
|
|
||||||
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
||||||
|
|
||||||
virtual int getShapeType() const { return CAPSULE_SHAPE_PROXYTYPE; }
|
virtual int getShapeType() const { return CAPSULE_SHAPE_PROXYTYPE; }
|
||||||
|
|
||||||
virtual char* getName()const
|
virtual char* getName()const
|
||||||
{
|
{
|
||||||
return "CapsuleShape";
|
return "CapsuleShape";
|
||||||
}
|
}
|
||||||
|
|
||||||
btScalar getRadius() const
|
btScalar getRadius() const
|
||||||
{
|
{
|
||||||
return m_implicitShapeDimensions.getX();
|
return m_implicitShapeDimensions.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
btScalar getHalfHeight() const
|
btScalar getHalfHeight() const
|
||||||
{
|
{
|
||||||
return m_implicitShapeDimensions.getY();
|
return m_implicitShapeDimensions.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //BT_CAPSULE_SHAPE_H
|
#endif //BT_CAPSULE_SHAPE_H
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ class btOptimizedBvh;
|
|||||||
|
|
||||||
ATTRIBUTE_ALIGNED16(struct) btCompoundShapeChild
|
ATTRIBUTE_ALIGNED16(struct) btCompoundShapeChild
|
||||||
{
|
{
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btTransform m_transform;
|
btTransform m_transform;
|
||||||
btCollisionShape* m_childShape;
|
btCollisionShape* m_childShape;
|
||||||
int m_childShapeType;
|
int m_childShapeType;
|
||||||
@@ -47,6 +49,8 @@ ATTRIBUTE_ALIGNED16(class) btCompoundShape : public btCollisionShape
|
|||||||
btOptimizedBvh* m_aabbTree;
|
btOptimizedBvh* m_aabbTree;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btCompoundShape();
|
btCompoundShape();
|
||||||
|
|
||||||
virtual ~btCompoundShape();
|
virtual ~btCompoundShape();
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ ATTRIBUTE_ALIGNED16(class) btConvexHullShape : public btPolyhedralConvexShape
|
|||||||
btAlignedObjectArray<btPoint3> m_points;
|
btAlignedObjectArray<btPoint3> m_points;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
|
|
||||||
///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive btScalar (x,y,z), the striding defines the number of bytes between each point, in memory.
|
///this constructor optionally takes in a pointer to points. Each point is assumed to be 3 consecutive btScalar (x,y,z), the striding defines the number of bytes between each point, in memory.
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ subject to the following restrictions:
|
|||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
#include "LinearMath/btMatrix3x3.h"
|
#include "LinearMath/btMatrix3x3.h"
|
||||||
#include "btCollisionMargin.h"
|
#include "btCollisionMargin.h"
|
||||||
|
#include "LinearMath/btAlignedAllocator.h"
|
||||||
|
|
||||||
//todo: get rid of this btConvexCastResult thing!
|
//todo: get rid of this btConvexCastResult thing!
|
||||||
struct btConvexCastResult;
|
struct btConvexCastResult;
|
||||||
@@ -36,6 +37,8 @@ ATTRIBUTE_ALIGNED16(class) btConvexShape : public btCollisionShape
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
virtual ~btConvexShape()
|
virtual ~btConvexShape()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -202,4 +202,4 @@ void btConvexTriangleMeshShape::setLocalScaling(const btVector3& scaling)
|
|||||||
const btVector3& btConvexTriangleMeshShape::getLocalScaling() const
|
const btVector3& btConvexTriangleMeshShape::getLocalScaling() const
|
||||||
{
|
{
|
||||||
return m_stridingMesh->getScaling();
|
return m_stridingMesh->getScaling();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +1,51 @@
|
|||||||
#ifndef CONVEX_TRIANGLEMESH_SHAPE_H
|
#ifndef CONVEX_TRIANGLEMESH_SHAPE_H
|
||||||
#define CONVEX_TRIANGLEMESH_SHAPE_H
|
#define CONVEX_TRIANGLEMESH_SHAPE_H
|
||||||
|
|
||||||
|
|
||||||
#include "btPolyhedralConvexShape.h"
|
#include "btPolyhedralConvexShape.h"
|
||||||
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
|
#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
|
||||||
|
|
||||||
|
|
||||||
/// btConvexTriangleMeshShape is a convex hull of a triangle mesh. If you just have a point cloud, you can use btConvexHullShape instead.
|
/// btConvexTriangleMeshShape is a convex hull of a triangle mesh. If you just have a point cloud, you can use btConvexHullShape instead.
|
||||||
/// It uses the btStridingMeshInterface instead of a point cloud. This can avoid the duplication of the triangle mesh data.
|
/// It uses the btStridingMeshInterface instead of a point cloud. This can avoid the duplication of the triangle mesh data.
|
||||||
class btConvexTriangleMeshShape : public btPolyhedralConvexShape
|
class btConvexTriangleMeshShape : public btPolyhedralConvexShape
|
||||||
{
|
{
|
||||||
|
|
||||||
class btStridingMeshInterface* m_stridingMesh;
|
class btStridingMeshInterface* m_stridingMesh;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btConvexTriangleMeshShape(btStridingMeshInterface* meshInterface);
|
btConvexTriangleMeshShape(btStridingMeshInterface* meshInterface);
|
||||||
|
|
||||||
class btStridingMeshInterface* getStridingMesh()
|
class btStridingMeshInterface* getStridingMesh()
|
||||||
{
|
{
|
||||||
return m_stridingMesh;
|
return m_stridingMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertex(const btVector3& vec)const;
|
||||||
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
|
||||||
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
|
||||||
|
|
||||||
virtual int getShapeType()const { return CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; }
|
virtual int getShapeType()const { return CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE; }
|
||||||
|
|
||||||
//debugging
|
//debugging
|
||||||
virtual char* getName()const {return "ConvexTrimesh";}
|
virtual char* getName()const {return "ConvexTrimesh";}
|
||||||
|
|
||||||
virtual int getNumVertices() const;
|
virtual int getNumVertices() const;
|
||||||
virtual int getNumEdges() const;
|
virtual int getNumEdges() const;
|
||||||
virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
|
virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const;
|
||||||
virtual void getVertex(int i,btPoint3& vtx) const;
|
virtual void getVertex(int i,btPoint3& vtx) const;
|
||||||
virtual int getNumPlanes() const;
|
virtual int getNumPlanes() const;
|
||||||
virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
|
virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const;
|
||||||
virtual bool isInside(const btPoint3& pt,btScalar tolerance) const;
|
virtual bool isInside(const btPoint3& pt,btScalar tolerance) const;
|
||||||
|
|
||||||
|
|
||||||
virtual void setLocalScaling(const btVector3& scaling);
|
virtual void setLocalScaling(const btVector3& scaling);
|
||||||
virtual const btVector3& getLocalScaling() const;
|
virtual const btVector3& getLocalScaling() const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //CONVEX_TRIANGLEMESH_SHAPE_H
|
#endif //CONVEX_TRIANGLEMESH_SHAPE_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,88 +1,88 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 HEIGHTFIELD_TERRAIN_SHAPE_H
|
#ifndef HEIGHTFIELD_TERRAIN_SHAPE_H
|
||||||
#define HEIGHTFIELD_TERRAIN_SHAPE_H
|
#define HEIGHTFIELD_TERRAIN_SHAPE_H
|
||||||
|
|
||||||
#include "btConcaveShape.h"
|
#include "btConcaveShape.h"
|
||||||
|
|
||||||
///btHeightfieldTerrainShape simulates a 2D heightfield terrain
|
///btHeightfieldTerrainShape simulates a 2D heightfield terrain
|
||||||
class btHeightfieldTerrainShape : public btConcaveShape
|
class btHeightfieldTerrainShape : public btConcaveShape
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
btVector3 m_localAabbMin;
|
btVector3 m_localAabbMin;
|
||||||
btVector3 m_localAabbMax;
|
btVector3 m_localAabbMax;
|
||||||
|
|
||||||
///terrain data
|
///terrain data
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_length;
|
int m_length;
|
||||||
btScalar m_maxHeight;
|
btScalar m_maxHeight;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
unsigned char* m_heightfieldDataUnsignedChar;
|
unsigned char* m_heightfieldDataUnsignedChar;
|
||||||
btScalar* m_heightfieldDataFloat;
|
btScalar* m_heightfieldDataFloat;
|
||||||
void* m_heightfieldDataUnknown;
|
void* m_heightfieldDataUnknown;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool m_useFloatData;
|
bool m_useFloatData;
|
||||||
bool m_flipQuadEdges;
|
bool m_flipQuadEdges;
|
||||||
bool m_useDiamondSubdivision;
|
bool m_useDiamondSubdivision;
|
||||||
|
|
||||||
int m_upAxis;
|
int m_upAxis;
|
||||||
|
|
||||||
btVector3 m_localScaling;
|
btVector3 m_localScaling;
|
||||||
|
|
||||||
virtual btScalar getHeightFieldValue(int x,int y) const;
|
virtual btScalar getHeightFieldValue(int x,int y) const;
|
||||||
void quantizeWithClamp(int* out, const btVector3& point) const;
|
void quantizeWithClamp(int* out, const btVector3& point) const;
|
||||||
void getVertex(int x,int y,btVector3& vertex) const;
|
void getVertex(int x,int y,btVector3& vertex) const;
|
||||||
|
|
||||||
inline bool testQuantizedAabbAgainstQuantizedAabb(int* aabbMin1, int* aabbMax1,const int* aabbMin2,const int* aabbMax2) const
|
inline bool testQuantizedAabbAgainstQuantizedAabb(int* aabbMin1, int* aabbMax1,const int* aabbMin2,const int* aabbMax2) const
|
||||||
{
|
{
|
||||||
bool overlap = true;
|
bool overlap = true;
|
||||||
overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
|
overlap = (aabbMin1[0] > aabbMax2[0] || aabbMax1[0] < aabbMin2[0]) ? false : overlap;
|
||||||
overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap;
|
overlap = (aabbMin1[2] > aabbMax2[2] || aabbMax1[2] < aabbMin2[2]) ? false : overlap;
|
||||||
overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap;
|
overlap = (aabbMin1[1] > aabbMax2[1] || aabbMax1[1] < aabbMin2[1]) ? false : overlap;
|
||||||
return overlap;
|
return overlap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btHeightfieldTerrainShape(int width,int height,void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges);
|
btHeightfieldTerrainShape(int width,int height,void* heightfieldData, btScalar maxHeight,int upAxis,bool useFloatData,bool flipQuadEdges);
|
||||||
|
|
||||||
virtual ~btHeightfieldTerrainShape();
|
virtual ~btHeightfieldTerrainShape();
|
||||||
|
|
||||||
|
|
||||||
void setUseDiamondSubdivision(bool useDiamondSubdivision=true) { m_useDiamondSubdivision = useDiamondSubdivision;}
|
void setUseDiamondSubdivision(bool useDiamondSubdivision=true) { m_useDiamondSubdivision = useDiamondSubdivision;}
|
||||||
|
|
||||||
virtual int getShapeType() const
|
virtual int getShapeType() const
|
||||||
{
|
{
|
||||||
return TERRAIN_SHAPE_PROXYTYPE;
|
return TERRAIN_SHAPE_PROXYTYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
||||||
|
|
||||||
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||||
|
|
||||||
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia);
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia);
|
||||||
|
|
||||||
virtual void setLocalScaling(const btVector3& scaling);
|
virtual void setLocalScaling(const btVector3& scaling);
|
||||||
|
|
||||||
virtual const btVector3& getLocalScaling() const;
|
virtual const btVector3& getLocalScaling() const;
|
||||||
|
|
||||||
//debugging
|
//debugging
|
||||||
virtual char* getName()const {return "HEIGHTFIELD";}
|
virtual char* getName()const {return "HEIGHTFIELD";}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //HEIGHTFIELD_TERRAIN_SHAPE_H
|
#endif //HEIGHTFIELD_TERRAIN_SHAPE_H
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
|
#include "LinearMath/btAlignedAllocator.h"
|
||||||
|
|
||||||
|
|
||||||
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf__m128.asp
|
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/vclrf__m128.asp
|
||||||
@@ -34,7 +35,8 @@ class btStridingMeshInterface;
|
|||||||
///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
|
///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).
|
||||||
ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
|
ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
|
||||||
{
|
{
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
//12 bytes
|
//12 bytes
|
||||||
unsigned short int m_quantizedAabbMin[3];
|
unsigned short int m_quantizedAabbMin[3];
|
||||||
unsigned short int m_quantizedAabbMax[3];
|
unsigned short int m_quantizedAabbMax[3];
|
||||||
@@ -63,6 +65,8 @@ ATTRIBUTE_ALIGNED16 (struct) btQuantizedBvhNode
|
|||||||
/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
|
/// Total node size is 44 bytes / node. You can use the compressed version of 16 bytes.
|
||||||
ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
|
ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
|
||||||
{
|
{
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
//32 bytes
|
//32 bytes
|
||||||
btVector3 m_aabbMinOrg;
|
btVector3 m_aabbMinOrg;
|
||||||
btVector3 m_aabbMaxOrg;
|
btVector3 m_aabbMaxOrg;
|
||||||
@@ -84,6 +88,8 @@ ATTRIBUTE_ALIGNED16 (struct) btOptimizedBvhNode
|
|||||||
ATTRIBUTE_ALIGNED16(class) btBvhSubtreeInfo
|
ATTRIBUTE_ALIGNED16(class) btBvhSubtreeInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
//12 bytes
|
//12 bytes
|
||||||
unsigned short int m_quantizedAabbMin[3];
|
unsigned short int m_quantizedAabbMin[3];
|
||||||
unsigned short int m_quantizedAabbMax[3];
|
unsigned short int m_quantizedAabbMax[3];
|
||||||
@@ -145,6 +151,8 @@ ATTRIBUTE_ALIGNED16(class) btOptimizedBvh
|
|||||||
btVector3 m_bvhAabbMax;
|
btVector3 m_bvhAabbMax;
|
||||||
btVector3 m_bvhQuantization;
|
btVector3 m_bvhQuantization;
|
||||||
public:
|
public:
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
enum btTraversalMode
|
enum btTraversalMode
|
||||||
{
|
{
|
||||||
TRAVERSAL_STACKLESS = 0,
|
TRAVERSAL_STACKLESS = 0,
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ ATTRIBUTE_ALIGNED16(class) btSphereShape : public btConvexInternalShape
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btSphereShape (btScalar radius);
|
btSphereShape (btScalar radius);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -121,4 +121,4 @@ void btStridingMeshInterface::calculateAabbBruteForce(btVector3& aabbMin,btVecto
|
|||||||
|
|
||||||
aabbMin = aabbCallback.m_aabbMin;
|
aabbMin = aabbCallback.m_aabbMin;
|
||||||
aabbMax = aabbCallback.m_aabbMax;
|
aabbMax = aabbCallback.m_aabbMax;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,61 +1,61 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 BT_TRIANGLE_BUFFER_H
|
#ifndef BT_TRIANGLE_BUFFER_H
|
||||||
#define BT_TRIANGLE_BUFFER_H
|
#define BT_TRIANGLE_BUFFER_H
|
||||||
|
|
||||||
#include "btTriangleCallback.h"
|
#include "btTriangleCallback.h"
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
|
|
||||||
struct btTriangle
|
struct btTriangle
|
||||||
{
|
{
|
||||||
btVector3 m_vertex0;
|
btVector3 m_vertex0;
|
||||||
btVector3 m_vertex1;
|
btVector3 m_vertex1;
|
||||||
btVector3 m_vertex2;
|
btVector3 m_vertex2;
|
||||||
int m_partId;
|
int m_partId;
|
||||||
int m_triangleIndex;
|
int m_triangleIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
///btTriangleBuffer can be useful to collect and store overlapping triangles between AABB and concave objects that support 'processAllTriangles'
|
///btTriangleBuffer can be useful to collect and store overlapping triangles between AABB and concave objects that support 'processAllTriangles'
|
||||||
class btTriangleBuffer : public btTriangleCallback
|
class btTriangleBuffer : public btTriangleCallback
|
||||||
{
|
{
|
||||||
|
|
||||||
btAlignedObjectArray<btTriangle> m_triangleBuffer;
|
btAlignedObjectArray<btTriangle> m_triangleBuffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
|
virtual void processTriangle(btVector3* triangle, int partId, int triangleIndex);
|
||||||
|
|
||||||
int getNumTriangles() const
|
int getNumTriangles() const
|
||||||
{
|
{
|
||||||
return int(m_triangleBuffer.size());
|
return int(m_triangleBuffer.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
const btTriangle& getTriangle(int index) const
|
const btTriangle& getTriangle(int index) const
|
||||||
{
|
{
|
||||||
return m_triangleBuffer[index];
|
return m_triangleBuffer[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearBuffer()
|
void clearBuffer()
|
||||||
{
|
{
|
||||||
m_triangleBuffer.clear();
|
m_triangleBuffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //BT_TRIANGLE_BUFFER_H
|
#endif //BT_TRIANGLE_BUFFER_H
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ subject to the following restrictions:
|
|||||||
///todo: explain with pictures
|
///todo: explain with pictures
|
||||||
ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
|
ATTRIBUTE_ALIGNED16( struct) btIndexedMesh
|
||||||
{
|
{
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
int m_numTriangles;
|
int m_numTriangles;
|
||||||
const unsigned char * m_triangleIndexBase;
|
const unsigned char * m_triangleIndexBase;
|
||||||
int m_triangleIndexStride;
|
int m_triangleIndexStride;
|
||||||
@@ -49,6 +51,8 @@ ATTRIBUTE_ALIGNED16( class) btTriangleIndexVertexArray : public btStridingMeshIn
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btTriangleIndexVertexArray()
|
btTriangleIndexVertexArray()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +1,53 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
GJK-EPA collision solver by Nathanael Presson
|
GJK-EPA collision solver by Nathanael Presson
|
||||||
Nov.2006
|
Nov.2006
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
|
#ifndef _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
|
||||||
#define _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
|
#define _05E48D53_04E0_49ad_BB0A_D74FE62E7366_
|
||||||
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
#include "BulletCollision/CollisionShapes/btConvexShape.h"
|
||||||
|
|
||||||
class btStackAlloc;
|
class btStackAlloc;
|
||||||
|
|
||||||
///btGjkEpaSolver contributed under zlib by Nathanael Presson
|
///btGjkEpaSolver contributed under zlib by Nathanael Presson
|
||||||
struct btGjkEpaSolver
|
struct btGjkEpaSolver
|
||||||
{
|
{
|
||||||
struct sResults
|
struct sResults
|
||||||
{
|
{
|
||||||
enum eStatus
|
enum eStatus
|
||||||
{
|
{
|
||||||
Separated, /* Shapes doesnt penetrate */
|
Separated, /* Shapes doesnt penetrate */
|
||||||
Penetrating, /* Shapes are penetrating */
|
Penetrating, /* Shapes are penetrating */
|
||||||
GJK_Failed, /* GJK phase fail, no big issue, shapes are probably just 'touching' */
|
GJK_Failed, /* GJK phase fail, no big issue, shapes are probably just 'touching' */
|
||||||
EPA_Failed, /* EPA phase fail, bigger problem, need to save parameters, and debug */
|
EPA_Failed, /* EPA phase fail, bigger problem, need to save parameters, and debug */
|
||||||
} status;
|
} status;
|
||||||
btVector3 witnesses[2];
|
btVector3 witnesses[2];
|
||||||
btVector3 normal;
|
btVector3 normal;
|
||||||
btScalar depth;
|
btScalar depth;
|
||||||
int epa_iterations;
|
int epa_iterations;
|
||||||
int gjk_iterations;
|
int gjk_iterations;
|
||||||
};
|
};
|
||||||
static bool Collide(const btConvexShape* shape0,const btTransform& wtrs0,
|
static bool Collide(const btConvexShape* shape0,const btTransform& wtrs0,
|
||||||
const btConvexShape* shape1,const btTransform& wtrs1,
|
const btConvexShape* shape1,const btTransform& wtrs1,
|
||||||
btScalar radialmargin,
|
btScalar radialmargin,
|
||||||
btStackAlloc* stackAlloc,
|
btStackAlloc* stackAlloc,
|
||||||
sResults& results);
|
sResults& results);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
EPA Copyright (c) Ricardo Padrela 2006
|
EPA Copyright (c) Ricardo Padrela 2006
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 BT_GJP_EPA_PENETRATION_DEPTH_H
|
#ifndef BT_GJP_EPA_PENETRATION_DEPTH_H
|
||||||
#define BT_GJP_EPA_PENETRATION_DEPTH_H
|
#define BT_GJP_EPA_PENETRATION_DEPTH_H
|
||||||
|
|
||||||
#include "btConvexPenetrationDepthSolver.h"
|
#include "btConvexPenetrationDepthSolver.h"
|
||||||
|
|
||||||
///EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to
|
///EpaPenetrationDepthSolver uses the Expanding Polytope Algorithm to
|
||||||
///calculate the penetration depth between two convex shapes.
|
///calculate the penetration depth between two convex shapes.
|
||||||
class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
|
class btGjkEpaPenetrationDepthSolver : public btConvexPenetrationDepthSolver
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
|
|
||||||
bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
bool calcPenDepth( btSimplexSolverInterface& simplexSolver,
|
||||||
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
|
const btConvexShape* pConvexA, const btConvexShape* pConvexB,
|
||||||
const btTransform& transformA, const btTransform& transformB,
|
const btTransform& transformA, const btTransform& transformB,
|
||||||
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
btVector3& v, btPoint3& wWitnessOnA, btPoint3& wWitnessOnB,
|
||||||
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
|
class btIDebugDraw* debugDraw,btStackAlloc* stackAlloc );
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BT_GJP_EPA_PENETRATION_DEPTH_H
|
#endif // BT_GJP_EPA_PENETRATION_DEPTH_H
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ subject to the following restrictions:
|
|||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
#include "btManifoldPoint.h"
|
#include "btManifoldPoint.h"
|
||||||
|
#include "LinearMath/btAlignedAllocator.h"
|
||||||
|
|
||||||
struct btCollisionResult;
|
struct btCollisionResult;
|
||||||
|
|
||||||
@@ -55,6 +56,8 @@ ATTRIBUTE_ALIGNED16( class) btPersistentManifold
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
int m_index1;
|
int m_index1;
|
||||||
|
|
||||||
btPersistentManifold();
|
btPersistentManifold();
|
||||||
|
|||||||
@@ -1,93 +1,93 @@
|
|||||||
#### Source code Dirs
|
#### Source code Dirs
|
||||||
VPATH = \
|
VPATH = \
|
||||||
../BroadphaseCollision \
|
../BroadphaseCollision \
|
||||||
../CollisionDispatch \
|
../CollisionDispatch \
|
||||||
../NarrowPhaseCollision \
|
../NarrowPhaseCollision \
|
||||||
../CollisionShapes
|
../CollisionShapes
|
||||||
|
|
||||||
ROOT = ../../..
|
ROOT = ../../..
|
||||||
|
|
||||||
#### Library
|
#### Library
|
||||||
LIBRARY_ppu = bulletcollision.a
|
LIBRARY_ppu = bulletcollision.a
|
||||||
|
|
||||||
#### Compiler flags
|
#### Compiler flags
|
||||||
CPPFLAGS = \
|
CPPFLAGS = \
|
||||||
-I../BroadphaseCollision \
|
-I../BroadphaseCollision \
|
||||||
-I../CollisionDispath \
|
-I../CollisionDispath \
|
||||||
-I../NarrowPhaseCollision \
|
-I../NarrowPhaseCollision \
|
||||||
-I../CollisionShapes \
|
-I../CollisionShapes \
|
||||||
-I$(ROOT)/src/ \
|
-I$(ROOT)/src/ \
|
||||||
-I$(SDKINC)
|
-I$(SDKINC)
|
||||||
|
|
||||||
#### Optimization level flags
|
#### Optimization level flags
|
||||||
#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG)
|
#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG)
|
||||||
CC_OPT_LEVEL = -O3
|
CC_OPT_LEVEL = -O3
|
||||||
|
|
||||||
##### Objects to be archived in lib
|
##### Objects to be archived in lib
|
||||||
|
|
||||||
OBJS = \
|
OBJS = \
|
||||||
btAxisSweep3.o \
|
btAxisSweep3.o \
|
||||||
btBroadphaseProxy.o \
|
btBroadphaseProxy.o \
|
||||||
btCollisionAlgorithm.o \
|
btCollisionAlgorithm.o \
|
||||||
btDispatcher.o \
|
btDispatcher.o \
|
||||||
btOverlappingPairCache.o \
|
btOverlappingPairCache.o \
|
||||||
btSimpleBroadphase.o \
|
btSimpleBroadphase.o \
|
||||||
btContinuousConvexCollision.o \
|
btContinuousConvexCollision.o \
|
||||||
btConvexCast.o \
|
btConvexCast.o \
|
||||||
btGjkConvexCast.o \
|
btGjkConvexCast.o \
|
||||||
btGjkEpa.o \
|
btGjkEpa.o \
|
||||||
btGjkEpaPenetrationDepthSolver.o \
|
btGjkEpaPenetrationDepthSolver.o \
|
||||||
btGjkPairDetector.o \
|
btGjkPairDetector.o \
|
||||||
btMinkowskiPenetrationDepthSolver.o \
|
btMinkowskiPenetrationDepthSolver.o \
|
||||||
btPersistentManifold.o \
|
btPersistentManifold.o \
|
||||||
btRaycastCallback.o \
|
btRaycastCallback.o \
|
||||||
btSubSimplexConvexCast.o \
|
btSubSimplexConvexCast.o \
|
||||||
btVoronoiSimplexSolver.o \
|
btVoronoiSimplexSolver.o \
|
||||||
btCollisionDispatcher.o \
|
btCollisionDispatcher.o \
|
||||||
btCollisionObject.o \
|
btCollisionObject.o \
|
||||||
btCollisionWorld.o \
|
btCollisionWorld.o \
|
||||||
btCompoundCollisionAlgorithm.o \
|
btCompoundCollisionAlgorithm.o \
|
||||||
btConvexConcaveCollisionAlgorithm.o \
|
btConvexConcaveCollisionAlgorithm.o \
|
||||||
btConvexConvexAlgorithm.o \
|
btConvexConvexAlgorithm.o \
|
||||||
btEmptyCollisionAlgorithm.o \
|
btEmptyCollisionAlgorithm.o \
|
||||||
btManifoldResult.o \
|
btManifoldResult.o \
|
||||||
btSimulationIslandManager.o \
|
btSimulationIslandManager.o \
|
||||||
btSphereBoxCollisionAlgorithm.o \
|
btSphereBoxCollisionAlgorithm.o \
|
||||||
btSphereSphereCollisionAlgorithm.o \
|
btSphereSphereCollisionAlgorithm.o \
|
||||||
btSphereTriangleCollisionAlgorithm.o \
|
btSphereTriangleCollisionAlgorithm.o \
|
||||||
btUnionFind.o \
|
btUnionFind.o \
|
||||||
SphereTriangleDetector.o \
|
SphereTriangleDetector.o \
|
||||||
btBoxShape.o \
|
btBoxShape.o \
|
||||||
btBvhTriangleMeshShape.o \
|
btBvhTriangleMeshShape.o \
|
||||||
btCapsuleShape.o \
|
btCapsuleShape.o \
|
||||||
btCollisionShape.o \
|
btCollisionShape.o \
|
||||||
btCompoundShape.o \
|
btCompoundShape.o \
|
||||||
btConcaveShape.o \
|
btConcaveShape.o \
|
||||||
btConeShape.o \
|
btConeShape.o \
|
||||||
btConvexHullShape.o \
|
btConvexHullShape.o \
|
||||||
btConvexShape.o \
|
btConvexShape.o \
|
||||||
btConvexInternalShape.o \
|
btConvexInternalShape.o \
|
||||||
btConvexTriangleMeshShape.o \
|
btConvexTriangleMeshShape.o \
|
||||||
btCylinderShape.o \
|
btCylinderShape.o \
|
||||||
btEmptyShape.o \
|
btEmptyShape.o \
|
||||||
btHeightfieldTerrainShape.o \
|
btHeightfieldTerrainShape.o \
|
||||||
btMinkowskiSumShape.o \
|
btMinkowskiSumShape.o \
|
||||||
btMultiSphereShape.o \
|
btMultiSphereShape.o \
|
||||||
btOptimizedBvh.o \
|
btOptimizedBvh.o \
|
||||||
btPolyhedralConvexShape.o \
|
btPolyhedralConvexShape.o \
|
||||||
btSphereShape.o \
|
btSphereShape.o \
|
||||||
btStaticPlaneShape.o \
|
btStaticPlaneShape.o \
|
||||||
btStridingMeshInterface.o \
|
btStridingMeshInterface.o \
|
||||||
btTetrahedronShape.o \
|
btTetrahedronShape.o \
|
||||||
btTriangleBuffer.o \
|
btTriangleBuffer.o \
|
||||||
btTriangleCallback.o \
|
btTriangleCallback.o \
|
||||||
btTriangleIndexVertexArray.o \
|
btTriangleIndexVertexArray.o \
|
||||||
btTriangleMesh.o \
|
btTriangleMesh.o \
|
||||||
btTriangleMeshShape.o \
|
btTriangleMeshShape.o \
|
||||||
btUniformScalingShape.o
|
btUniformScalingShape.o
|
||||||
|
|
||||||
#### Install directories
|
#### Install directories
|
||||||
INSTALL_DIR = $(ROOT)/lib/ibmsdk
|
INSTALL_DIR = $(ROOT)/lib/ibmsdk
|
||||||
INSTALL_FILES = $(LIBRARY_ppu)
|
INSTALL_FILES = $(LIBRARY_ppu)
|
||||||
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
||||||
include $(CELL_TOP)/make.footer
|
include $(CELL_TOP)/make.footer
|
||||||
|
|||||||
@@ -1,72 +1,75 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 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"
|
||||||
|
|
||||||
|
|
||||||
///btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance.
|
|
||||||
ATTRIBUTE_ALIGNED16 (struct) btSolverBody
|
///btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance.
|
||||||
{
|
ATTRIBUTE_ALIGNED16 (struct) btSolverBody
|
||||||
btVector3 m_centerOfMassPosition;
|
{
|
||||||
btVector3 m_linearVelocity;
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
btVector3 m_angularVelocity;
|
|
||||||
btRigidBody* m_originalBody;
|
btVector3 m_centerOfMassPosition;
|
||||||
float m_invMass;
|
btVector3 m_linearVelocity;
|
||||||
float m_friction;
|
btVector3 m_angularVelocity;
|
||||||
float m_angularFactor;
|
btRigidBody* m_originalBody;
|
||||||
|
float m_invMass;
|
||||||
inline void getVelocityInLocalPoint(const btVector3& rel_pos, btVector3& velocity ) const
|
float m_friction;
|
||||||
{
|
float m_angularFactor;
|
||||||
velocity = m_linearVelocity + m_angularVelocity.cross(rel_pos);
|
|
||||||
}
|
inline void getVelocityInLocalPoint(const btVector3& rel_pos, btVector3& velocity ) const
|
||||||
|
{
|
||||||
//Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position
|
velocity = m_linearVelocity + m_angularVelocity.cross(rel_pos);
|
||||||
inline void internalApplyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude)
|
}
|
||||||
{
|
|
||||||
m_linearVelocity += linearComponent*impulseMagnitude;
|
//Optimization for the iterative solver: avoid calculating constant terms involving inertia, normal, relative position
|
||||||
m_angularVelocity += angularComponent*impulseMagnitude*m_angularFactor;
|
inline void internalApplyImpulse(const btVector3& linearComponent, const btVector3& angularComponent,btScalar impulseMagnitude)
|
||||||
}
|
{
|
||||||
|
m_linearVelocity += linearComponent*impulseMagnitude;
|
||||||
void writebackVelocity()
|
m_angularVelocity += angularComponent*impulseMagnitude*m_angularFactor;
|
||||||
{
|
}
|
||||||
if (m_invMass)
|
|
||||||
{
|
void writebackVelocity()
|
||||||
m_originalBody->setLinearVelocity(m_linearVelocity);
|
{
|
||||||
m_originalBody->setAngularVelocity(m_angularVelocity);
|
if (m_invMass)
|
||||||
}
|
{
|
||||||
}
|
m_originalBody->setLinearVelocity(m_linearVelocity);
|
||||||
|
m_originalBody->setAngularVelocity(m_angularVelocity);
|
||||||
void readVelocity()
|
}
|
||||||
{
|
}
|
||||||
if (m_invMass)
|
|
||||||
{
|
void readVelocity()
|
||||||
m_linearVelocity = m_originalBody->getLinearVelocity();
|
{
|
||||||
m_angularVelocity = m_originalBody->getAngularVelocity();
|
if (m_invMass)
|
||||||
}
|
{
|
||||||
}
|
m_linearVelocity = m_originalBody->getLinearVelocity();
|
||||||
|
m_angularVelocity = m_originalBody->getAngularVelocity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //BT_SOLVER_BODY_H
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //BT_SOLVER_BODY_H
|
||||||
|
|||||||
@@ -1,63 +1,65 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 BT_SOLVER_CONSTRAINT_H
|
#ifndef BT_SOLVER_CONSTRAINT_H
|
||||||
#define BT_SOLVER_CONSTRAINT_H
|
#define BT_SOLVER_CONSTRAINT_H
|
||||||
|
|
||||||
class btRigidBody;
|
class btRigidBody;
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
#include "LinearMath/btMatrix3x3.h"
|
#include "LinearMath/btMatrix3x3.h"
|
||||||
|
|
||||||
//#define NO_FRICTION_TANGENTIALS 1
|
//#define NO_FRICTION_TANGENTIALS 1
|
||||||
|
|
||||||
///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints.
|
///1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and friction constraints.
|
||||||
ATTRIBUTE_ALIGNED16 (struct) btSolverConstraint
|
ATTRIBUTE_ALIGNED16 (struct) btSolverConstraint
|
||||||
{
|
{
|
||||||
btVector3 m_relpos1CrossNormal;
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
btVector3 m_relpos2CrossNormal;
|
|
||||||
btVector3 m_contactNormal;
|
btVector3 m_relpos1CrossNormal;
|
||||||
btVector3 m_angularComponentA;
|
btVector3 m_relpos2CrossNormal;
|
||||||
btVector3 m_angularComponentB;
|
btVector3 m_contactNormal;
|
||||||
|
btVector3 m_angularComponentA;
|
||||||
btScalar m_appliedVelocityImpulse;
|
btVector3 m_angularComponentB;
|
||||||
int m_solverBodyIdA;
|
|
||||||
int m_solverBodyIdB;
|
btScalar m_appliedVelocityImpulse;
|
||||||
btScalar m_friction;
|
int m_solverBodyIdA;
|
||||||
btScalar m_restitution;
|
int m_solverBodyIdB;
|
||||||
btScalar m_jacDiagABInv;
|
btScalar m_friction;
|
||||||
btScalar m_penetration;
|
btScalar m_restitution;
|
||||||
btScalar m_appliedImpulse;
|
btScalar m_jacDiagABInv;
|
||||||
|
btScalar m_penetration;
|
||||||
int m_constraintType;
|
btScalar m_appliedImpulse;
|
||||||
int m_frictionIndex;
|
|
||||||
int m_unusedPadding[2];
|
int m_constraintType;
|
||||||
|
int m_frictionIndex;
|
||||||
enum btSolverConstraintType
|
int m_unusedPadding[2];
|
||||||
{
|
|
||||||
BT_SOLVER_CONTACT_1D = 0,
|
enum btSolverConstraintType
|
||||||
BT_SOLVER_FRICTION_1D
|
{
|
||||||
};
|
BT_SOLVER_CONTACT_1D = 0,
|
||||||
};
|
BT_SOLVER_FRICTION_1D
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif //BT_SOLVER_CONSTRAINT_H
|
|
||||||
|
|
||||||
|
#endif //BT_SOLVER_CONSTRAINT_H
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,80 +1,80 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 BT_DYNAMICS_WORLD_H
|
#ifndef BT_DYNAMICS_WORLD_H
|
||||||
#define BT_DYNAMICS_WORLD_H
|
#define BT_DYNAMICS_WORLD_H
|
||||||
|
|
||||||
#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
|
#include "BulletCollision/CollisionDispatch/btCollisionWorld.h"
|
||||||
class btTypedConstraint;
|
class btTypedConstraint;
|
||||||
class btRaycastVehicle;
|
class btRaycastVehicle;
|
||||||
class btConstraintSolver;
|
class btConstraintSolver;
|
||||||
|
|
||||||
|
|
||||||
///btDynamicsWorld is the baseclass for several dynamics implementation, basic, discrete, parallel, and continuous
|
///btDynamicsWorld is the baseclass for several dynamics implementation, basic, discrete, parallel, and continuous
|
||||||
class btDynamicsWorld : public btCollisionWorld
|
class btDynamicsWorld : public btCollisionWorld
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase)
|
btDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* broadphase)
|
||||||
:btCollisionWorld(dispatcher,broadphase)
|
:btCollisionWorld(dispatcher,broadphase)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~btDynamicsWorld()
|
virtual ~btDynamicsWorld()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
///stepSimulation proceeds the simulation over timeStep units
|
///stepSimulation proceeds the simulation over timeStep units
|
||||||
///if maxSubSteps > 0, it will interpolate time steps
|
///if maxSubSteps > 0, it will interpolate time steps
|
||||||
virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0;
|
virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.))=0;
|
||||||
|
|
||||||
virtual void updateAabbs() = 0;
|
virtual void updateAabbs() = 0;
|
||||||
|
|
||||||
virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) { (void)constraint;};
|
virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false) { (void)constraint;};
|
||||||
|
|
||||||
virtual void removeConstraint(btTypedConstraint* constraint) {(void)constraint;};
|
virtual void removeConstraint(btTypedConstraint* constraint) {(void)constraint;};
|
||||||
|
|
||||||
virtual void addVehicle(btRaycastVehicle* vehicle) {(void)vehicle;};
|
virtual void addVehicle(btRaycastVehicle* vehicle) {(void)vehicle;};
|
||||||
|
|
||||||
virtual void removeVehicle(btRaycastVehicle* vehicle) {(void)vehicle;};
|
virtual void removeVehicle(btRaycastVehicle* vehicle) {(void)vehicle;};
|
||||||
|
|
||||||
|
|
||||||
virtual void setDebugDrawer(btIDebugDraw* debugDrawer) = 0;
|
virtual void setDebugDrawer(btIDebugDraw* debugDrawer) = 0;
|
||||||
|
|
||||||
virtual btIDebugDraw* getDebugDrawer() = 0;
|
virtual btIDebugDraw* getDebugDrawer() = 0;
|
||||||
|
|
||||||
//once a rigidbody is added to the dynamics world, it will get this gravity assigned
|
//once a rigidbody is added to the dynamics world, it will get this gravity assigned
|
||||||
//existing rigidbodies in the world get gravity assigned too, during this method
|
//existing rigidbodies in the world get gravity assigned too, during this method
|
||||||
virtual void setGravity(const btVector3& gravity) = 0;
|
virtual void setGravity(const btVector3& gravity) = 0;
|
||||||
|
|
||||||
virtual void addRigidBody(btRigidBody* body) = 0;
|
virtual void addRigidBody(btRigidBody* body) = 0;
|
||||||
|
|
||||||
virtual void removeRigidBody(btRigidBody* body) = 0;
|
virtual void removeRigidBody(btRigidBody* body) = 0;
|
||||||
|
|
||||||
virtual void setConstraintSolver(btConstraintSolver* solver) = 0;
|
virtual void setConstraintSolver(btConstraintSolver* solver) = 0;
|
||||||
|
|
||||||
virtual btConstraintSolver* getConstraintSolver() = 0;
|
virtual btConstraintSolver* getConstraintSolver() = 0;
|
||||||
|
|
||||||
virtual int getNumConstraints() const { return 0; }
|
virtual int getNumConstraints() const { return 0; }
|
||||||
|
|
||||||
virtual btTypedConstraint* getConstraint(int index) { (void)index; return 0; }
|
virtual btTypedConstraint* getConstraint(int index) { (void)index; return 0; }
|
||||||
|
|
||||||
virtual const btTypedConstraint* getConstraint(int index) const { (void)index; return 0; }
|
virtual const btTypedConstraint* getConstraint(int index) const { (void)index; return 0; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //BT_DYNAMICS_WORLD_H
|
#endif //BT_DYNAMICS_WORLD_H
|
||||||
|
|
||||||
|
|||||||
@@ -347,4 +347,4 @@ void btRigidBody::removeConstraintRef(btTypedConstraint* c)
|
|||||||
{
|
{
|
||||||
m_constraintRefs.remove(c);
|
m_constraintRefs.remove(c);
|
||||||
m_checkCollideWith = m_constraintRefs.size() > 0;
|
m_checkCollideWith = m_constraintRefs.size() > 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,84 +1,84 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but 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 BT_SIMPLE_DYNAMICS_WORLD_H
|
#ifndef BT_SIMPLE_DYNAMICS_WORLD_H
|
||||||
#define BT_SIMPLE_DYNAMICS_WORLD_H
|
#define BT_SIMPLE_DYNAMICS_WORLD_H
|
||||||
|
|
||||||
#include "btDynamicsWorld.h"
|
#include "btDynamicsWorld.h"
|
||||||
|
|
||||||
class btDispatcher;
|
class btDispatcher;
|
||||||
class btOverlappingPairCache;
|
class btOverlappingPairCache;
|
||||||
class btConstraintSolver;
|
class btConstraintSolver;
|
||||||
|
|
||||||
///btSimpleDynamicsWorld demonstrates very basic usage of Bullet rigid body dynamics
|
///btSimpleDynamicsWorld demonstrates very basic usage of Bullet rigid body dynamics
|
||||||
///It can be used for basic simulations, and as a starting point for porting Bullet
|
///It can be used for basic simulations, and as a starting point for porting Bullet
|
||||||
///btSimpleDynamicsWorld lacks object deactivation, island management and other concepts.
|
///btSimpleDynamicsWorld lacks object deactivation, island management and other concepts.
|
||||||
///For more complicated simulations, btDiscreteDynamicsWorld and btContinuousDynamicsWorld are recommended
|
///For more complicated simulations, btDiscreteDynamicsWorld and btContinuousDynamicsWorld are recommended
|
||||||
///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController
|
///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController
|
||||||
class btSimpleDynamicsWorld : public btDynamicsWorld
|
class btSimpleDynamicsWorld : public btDynamicsWorld
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
btConstraintSolver* m_constraintSolver;
|
btConstraintSolver* m_constraintSolver;
|
||||||
|
|
||||||
bool m_ownsConstraintSolver;
|
bool m_ownsConstraintSolver;
|
||||||
|
|
||||||
btIDebugDraw* m_debugDrawer;
|
btIDebugDraw* m_debugDrawer;
|
||||||
|
|
||||||
void predictUnconstraintMotion(btScalar timeStep);
|
void predictUnconstraintMotion(btScalar timeStep);
|
||||||
|
|
||||||
void integrateTransforms(btScalar timeStep);
|
void integrateTransforms(btScalar timeStep);
|
||||||
|
|
||||||
btVector3 m_gravity;
|
btVector3 m_gravity;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
|
///this btSimpleDynamicsWorld constructor creates dispatcher, broadphase pairCache and constraintSolver
|
||||||
btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver);
|
btSimpleDynamicsWorld(btDispatcher* dispatcher,btBroadphaseInterface* pairCache,btConstraintSolver* constraintSolver);
|
||||||
|
|
||||||
virtual ~btSimpleDynamicsWorld();
|
virtual ~btSimpleDynamicsWorld();
|
||||||
|
|
||||||
///maxSubSteps/fixedTimeStep for interpolation is currently ignored for btSimpleDynamicsWorld, use btDiscreteDynamicsWorld instead
|
///maxSubSteps/fixedTimeStep for interpolation is currently ignored for btSimpleDynamicsWorld, use btDiscreteDynamicsWorld instead
|
||||||
virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
|
virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
|
||||||
|
|
||||||
virtual void setDebugDrawer(btIDebugDraw* debugDrawer)
|
virtual void setDebugDrawer(btIDebugDraw* debugDrawer)
|
||||||
{
|
{
|
||||||
m_debugDrawer = debugDrawer;
|
m_debugDrawer = debugDrawer;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual btIDebugDraw* getDebugDrawer()
|
virtual btIDebugDraw* getDebugDrawer()
|
||||||
{
|
{
|
||||||
return m_debugDrawer;
|
return m_debugDrawer;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setGravity(const btVector3& gravity);
|
virtual void setGravity(const btVector3& gravity);
|
||||||
|
|
||||||
virtual void addRigidBody(btRigidBody* body);
|
virtual void addRigidBody(btRigidBody* body);
|
||||||
|
|
||||||
virtual void removeRigidBody(btRigidBody* body);
|
virtual void removeRigidBody(btRigidBody* body);
|
||||||
|
|
||||||
virtual void updateAabbs();
|
virtual void updateAabbs();
|
||||||
|
|
||||||
void synchronizeMotionStates();
|
void synchronizeMotionStates();
|
||||||
|
|
||||||
virtual void setConstraintSolver(btConstraintSolver* solver);
|
virtual void setConstraintSolver(btConstraintSolver* solver);
|
||||||
|
|
||||||
virtual btConstraintSolver* getConstraintSolver();
|
virtual btConstraintSolver* getConstraintSolver();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //BT_SIMPLE_DYNAMICS_WORLD_H
|
#endif //BT_SIMPLE_DYNAMICS_WORLD_H
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
SubDir TOP src BulletDynamics ;
|
SubDir TOP src BulletDynamics ;
|
||||||
|
|
||||||
Description bulletdynamics : "Bullet Rigidbody Dynamics" ;
|
Description bulletdynamics : "Bullet Rigidbody Dynamics" ;
|
||||||
Library bulletdynamics :
|
Library bulletdynamics :
|
||||||
[ Wildcard ConstraintSolver : *.h *.cpp ]
|
[ Wildcard ConstraintSolver : *.h *.cpp ]
|
||||||
[ Wildcard Dynamics : *.h *.cpp ]
|
[ Wildcard Dynamics : *.h *.cpp ]
|
||||||
[ Wildcard Vehicle : *.h *.cpp ]
|
[ Wildcard Vehicle : *.h *.cpp ]
|
||||||
;
|
;
|
||||||
|
|
||||||
LibDepends bulletdynamics : bulletcollision ;
|
LibDepends bulletdynamics : bulletcollision ;
|
||||||
|
|
||||||
|
|||||||
@@ -1,201 +1,201 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
|
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
* Permission to use, copy, modify, distribute and sell this software
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
* and its documentation for any purpose is hereby granted without fee,
|
||||||
* provided that the above copyright notice appear in all copies.
|
* provided that the above copyright notice appear in all copies.
|
||||||
* Erwin Coumans makes no representations about the suitability
|
* Erwin Coumans makes no representations about the suitability
|
||||||
* of this software for any purpose.
|
* of this software for any purpose.
|
||||||
* It is provided "as is" without express or implied warranty.
|
* It is provided "as is" without express or implied warranty.
|
||||||
*/
|
*/
|
||||||
#ifndef RAYCASTVEHICLE_H
|
#ifndef RAYCASTVEHICLE_H
|
||||||
#define RAYCASTVEHICLE_H
|
#define RAYCASTVEHICLE_H
|
||||||
|
|
||||||
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
||||||
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
|
#include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
|
||||||
#include "btVehicleRaycaster.h"
|
#include "btVehicleRaycaster.h"
|
||||||
class btDynamicsWorld;
|
class btDynamicsWorld;
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
#include "btWheelInfo.h"
|
#include "btWheelInfo.h"
|
||||||
|
|
||||||
class btVehicleTuning;
|
class btVehicleTuning;
|
||||||
|
|
||||||
///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
|
///rayCast vehicle, very special constraint that turn a rigidbody into a vehicle.
|
||||||
class btRaycastVehicle : public btTypedConstraint
|
class btRaycastVehicle : public btTypedConstraint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class btVehicleTuning
|
class btVehicleTuning
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
btVehicleTuning()
|
btVehicleTuning()
|
||||||
:m_suspensionStiffness(btScalar(5.88)),
|
:m_suspensionStiffness(btScalar(5.88)),
|
||||||
m_suspensionCompression(btScalar(0.83)),
|
m_suspensionCompression(btScalar(0.83)),
|
||||||
m_suspensionDamping(btScalar(0.88)),
|
m_suspensionDamping(btScalar(0.88)),
|
||||||
m_maxSuspensionTravelCm(btScalar(500.)),
|
m_maxSuspensionTravelCm(btScalar(500.)),
|
||||||
m_frictionSlip(btScalar(10.5))
|
m_frictionSlip(btScalar(10.5))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
btScalar m_suspensionStiffness;
|
btScalar m_suspensionStiffness;
|
||||||
btScalar m_suspensionCompression;
|
btScalar m_suspensionCompression;
|
||||||
btScalar m_suspensionDamping;
|
btScalar m_suspensionDamping;
|
||||||
btScalar m_maxSuspensionTravelCm;
|
btScalar m_maxSuspensionTravelCm;
|
||||||
btScalar m_frictionSlip;
|
btScalar m_frictionSlip;
|
||||||
|
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
|
|
||||||
btScalar m_tau;
|
btScalar m_tau;
|
||||||
btScalar m_damping;
|
btScalar m_damping;
|
||||||
btVehicleRaycaster* m_vehicleRaycaster;
|
btVehicleRaycaster* m_vehicleRaycaster;
|
||||||
btScalar m_pitchControl;
|
btScalar m_pitchControl;
|
||||||
btScalar m_steeringValue;
|
btScalar m_steeringValue;
|
||||||
btScalar m_currentVehicleSpeedKmHour;
|
btScalar m_currentVehicleSpeedKmHour;
|
||||||
|
|
||||||
btRigidBody* m_chassisBody;
|
btRigidBody* m_chassisBody;
|
||||||
|
|
||||||
int m_indexRightAxis;
|
int m_indexRightAxis;
|
||||||
int m_indexUpAxis;
|
int m_indexUpAxis;
|
||||||
int m_indexForwardAxis;
|
int m_indexForwardAxis;
|
||||||
|
|
||||||
void defaultInit(const btVehicleTuning& tuning);
|
void defaultInit(const btVehicleTuning& tuning);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//constructor to create a car from an existing rigidbody
|
//constructor to create a car from an existing rigidbody
|
||||||
btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster );
|
btRaycastVehicle(const btVehicleTuning& tuning,btRigidBody* chassis, btVehicleRaycaster* raycaster );
|
||||||
|
|
||||||
virtual ~btRaycastVehicle() ;
|
virtual ~btRaycastVehicle() ;
|
||||||
|
|
||||||
|
|
||||||
const btTransform& getChassisWorldTransform() const;
|
const btTransform& getChassisWorldTransform() const;
|
||||||
|
|
||||||
btScalar rayCast(btWheelInfo& wheel);
|
btScalar rayCast(btWheelInfo& wheel);
|
||||||
|
|
||||||
virtual void updateVehicle(btScalar step);
|
virtual void updateVehicle(btScalar step);
|
||||||
|
|
||||||
void resetSuspension();
|
void resetSuspension();
|
||||||
|
|
||||||
btScalar getSteeringValue(int wheel) const;
|
btScalar getSteeringValue(int wheel) const;
|
||||||
|
|
||||||
void setSteeringValue(btScalar steering,int wheel);
|
void setSteeringValue(btScalar steering,int wheel);
|
||||||
|
|
||||||
|
|
||||||
void applyEngineForce(btScalar force, int wheel);
|
void applyEngineForce(btScalar force, int wheel);
|
||||||
|
|
||||||
const btTransform& getWheelTransformWS( int wheelIndex ) const;
|
const btTransform& getWheelTransformWS( int wheelIndex ) const;
|
||||||
|
|
||||||
void updateWheelTransform( int wheelIndex, bool interpolatedTransform = true );
|
void updateWheelTransform( int wheelIndex, bool interpolatedTransform = true );
|
||||||
|
|
||||||
void setRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth);
|
void setRaycastWheelInfo( int wheelIndex , bool isInContact, const btVector3& hitPoint, const btVector3& hitNormal,btScalar depth);
|
||||||
|
|
||||||
btWheelInfo& addWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel);
|
btWheelInfo& addWheel( const btVector3& connectionPointCS0, const btVector3& wheelDirectionCS0,const btVector3& wheelAxleCS,btScalar suspensionRestLength,btScalar wheelRadius,const btVehicleTuning& tuning, bool isFrontWheel);
|
||||||
|
|
||||||
inline int getNumWheels() const {
|
inline int getNumWheels() const {
|
||||||
return int (m_wheelInfo.size());
|
return int (m_wheelInfo.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
btAlignedObjectArray<btWheelInfo> m_wheelInfo;
|
btAlignedObjectArray<btWheelInfo> m_wheelInfo;
|
||||||
|
|
||||||
|
|
||||||
const btWheelInfo& getWheelInfo(int index) const;
|
const btWheelInfo& getWheelInfo(int index) const;
|
||||||
|
|
||||||
btWheelInfo& getWheelInfo(int index);
|
btWheelInfo& getWheelInfo(int index);
|
||||||
|
|
||||||
void updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform = true);
|
void updateWheelTransformsWS(btWheelInfo& wheel , bool interpolatedTransform = true);
|
||||||
|
|
||||||
|
|
||||||
void setBrake(btScalar brake,int wheelIndex);
|
void setBrake(btScalar brake,int wheelIndex);
|
||||||
|
|
||||||
void setPitchControl(btScalar pitch)
|
void setPitchControl(btScalar pitch)
|
||||||
{
|
{
|
||||||
m_pitchControl = pitch;
|
m_pitchControl = pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateSuspension(btScalar deltaTime);
|
void updateSuspension(btScalar deltaTime);
|
||||||
|
|
||||||
void updateFriction(btScalar timeStep);
|
void updateFriction(btScalar timeStep);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
inline btRigidBody* getRigidBody()
|
inline btRigidBody* getRigidBody()
|
||||||
{
|
{
|
||||||
return m_chassisBody;
|
return m_chassisBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
const btRigidBody* getRigidBody() const
|
const btRigidBody* getRigidBody() const
|
||||||
{
|
{
|
||||||
return m_chassisBody;
|
return m_chassisBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int getRightAxis() const
|
inline int getRightAxis() const
|
||||||
{
|
{
|
||||||
return m_indexRightAxis;
|
return m_indexRightAxis;
|
||||||
}
|
}
|
||||||
inline int getUpAxis() const
|
inline int getUpAxis() const
|
||||||
{
|
{
|
||||||
return m_indexUpAxis;
|
return m_indexUpAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int getForwardAxis() const
|
inline int getForwardAxis() const
|
||||||
{
|
{
|
||||||
return m_indexForwardAxis;
|
return m_indexForwardAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///Worldspace forward vector
|
///Worldspace forward vector
|
||||||
btVector3 getForwardVector() const
|
btVector3 getForwardVector() const
|
||||||
{
|
{
|
||||||
const btTransform& chassisTrans = getChassisWorldTransform();
|
const btTransform& chassisTrans = getChassisWorldTransform();
|
||||||
|
|
||||||
btVector3 forwardW (
|
btVector3 forwardW (
|
||||||
chassisTrans.getBasis()[0][m_indexForwardAxis],
|
chassisTrans.getBasis()[0][m_indexForwardAxis],
|
||||||
chassisTrans.getBasis()[1][m_indexForwardAxis],
|
chassisTrans.getBasis()[1][m_indexForwardAxis],
|
||||||
chassisTrans.getBasis()[2][m_indexForwardAxis]);
|
chassisTrans.getBasis()[2][m_indexForwardAxis]);
|
||||||
|
|
||||||
return forwardW;
|
return forwardW;
|
||||||
}
|
}
|
||||||
|
|
||||||
///Velocity of vehicle (positive if velocity vector has same direction as foward vector)
|
///Velocity of vehicle (positive if velocity vector has same direction as foward vector)
|
||||||
btScalar getCurrentSpeedKmHour() const
|
btScalar getCurrentSpeedKmHour() const
|
||||||
{
|
{
|
||||||
return m_currentVehicleSpeedKmHour;
|
return m_currentVehicleSpeedKmHour;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex)
|
virtual void setCoordinateSystem(int rightIndex,int upIndex,int forwardIndex)
|
||||||
{
|
{
|
||||||
m_indexRightAxis = rightIndex;
|
m_indexRightAxis = rightIndex;
|
||||||
m_indexUpAxis = upIndex;
|
m_indexUpAxis = upIndex;
|
||||||
m_indexForwardAxis = forwardIndex;
|
m_indexForwardAxis = forwardIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void buildJacobian()
|
virtual void buildJacobian()
|
||||||
{
|
{
|
||||||
//not yet
|
//not yet
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void solveConstraint(btScalar timeStep)
|
virtual void solveConstraint(btScalar timeStep)
|
||||||
{
|
{
|
||||||
(void)timeStep;
|
(void)timeStep;
|
||||||
//not yet
|
//not yet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class btDefaultVehicleRaycaster : public btVehicleRaycaster
|
class btDefaultVehicleRaycaster : public btVehicleRaycaster
|
||||||
{
|
{
|
||||||
btDynamicsWorld* m_dynamicsWorld;
|
btDynamicsWorld* m_dynamicsWorld;
|
||||||
public:
|
public:
|
||||||
btDefaultVehicleRaycaster(btDynamicsWorld* world)
|
btDefaultVehicleRaycaster(btDynamicsWorld* world)
|
||||||
:m_dynamicsWorld(world)
|
:m_dynamicsWorld(world)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result);
|
virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //RAYCASTVEHICLE_H
|
#endif //RAYCASTVEHICLE_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
|
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
* Permission to use, copy, modify, distribute and sell this software
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
* and its documentation for any purpose is hereby granted without fee,
|
||||||
* provided that the above copyright notice appear in all copies.
|
* provided that the above copyright notice appear in all copies.
|
||||||
* Erwin Coumans makes no representations about the suitability
|
* Erwin Coumans makes no representations about the suitability
|
||||||
* of this software for any purpose.
|
* of this software for any purpose.
|
||||||
* It is provided "as is" without express or implied warranty.
|
* It is provided "as is" without express or implied warranty.
|
||||||
*/
|
*/
|
||||||
#ifndef VEHICLE_RAYCASTER_H
|
#ifndef VEHICLE_RAYCASTER_H
|
||||||
#define VEHICLE_RAYCASTER_H
|
#define VEHICLE_RAYCASTER_H
|
||||||
|
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
|
|
||||||
/// btVehicleRaycaster is provides interface for between vehicle simulation and raycasting
|
/// btVehicleRaycaster is provides interface for between vehicle simulation and raycasting
|
||||||
struct btVehicleRaycaster
|
struct btVehicleRaycaster
|
||||||
{
|
{
|
||||||
virtual ~btVehicleRaycaster()
|
virtual ~btVehicleRaycaster()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
struct btVehicleRaycasterResult
|
struct btVehicleRaycasterResult
|
||||||
{
|
{
|
||||||
btVehicleRaycasterResult() :m_distFraction(btScalar(-1.)){};
|
btVehicleRaycasterResult() :m_distFraction(btScalar(-1.)){};
|
||||||
btVector3 m_hitPointInWorld;
|
btVector3 m_hitPointInWorld;
|
||||||
btVector3 m_hitNormalInWorld;
|
btVector3 m_hitNormalInWorld;
|
||||||
btScalar m_distFraction;
|
btScalar m_distFraction;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) = 0;
|
virtual void* castRay(const btVector3& from,const btVector3& to, btVehicleRaycasterResult& result) = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //VEHICLE_RAYCASTER_H
|
#endif //VEHICLE_RAYCASTER_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,116 +1,116 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
|
* Copyright (c) 2005 Erwin Coumans http://continuousphysics.com/Bullet/
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, distribute and sell this software
|
* Permission to use, copy, modify, distribute and sell this software
|
||||||
* and its documentation for any purpose is hereby granted without fee,
|
* and its documentation for any purpose is hereby granted without fee,
|
||||||
* provided that the above copyright notice appear in all copies.
|
* provided that the above copyright notice appear in all copies.
|
||||||
* Erwin Coumans makes no representations about the suitability
|
* Erwin Coumans makes no representations about the suitability
|
||||||
* of this software for any purpose.
|
* of this software for any purpose.
|
||||||
* It is provided "as is" without express or implied warranty.
|
* It is provided "as is" without express or implied warranty.
|
||||||
*/
|
*/
|
||||||
#ifndef WHEEL_INFO_H
|
#ifndef WHEEL_INFO_H
|
||||||
#define WHEEL_INFO_H
|
#define WHEEL_INFO_H
|
||||||
|
|
||||||
#include "LinearMath/btVector3.h"
|
#include "LinearMath/btVector3.h"
|
||||||
#include "LinearMath/btTransform.h"
|
#include "LinearMath/btTransform.h"
|
||||||
|
|
||||||
class btRigidBody;
|
class btRigidBody;
|
||||||
|
|
||||||
struct btWheelInfoConstructionInfo
|
struct btWheelInfoConstructionInfo
|
||||||
{
|
{
|
||||||
btVector3 m_chassisConnectionCS;
|
btVector3 m_chassisConnectionCS;
|
||||||
btVector3 m_wheelDirectionCS;
|
btVector3 m_wheelDirectionCS;
|
||||||
btVector3 m_wheelAxleCS;
|
btVector3 m_wheelAxleCS;
|
||||||
btScalar m_suspensionRestLength;
|
btScalar m_suspensionRestLength;
|
||||||
btScalar m_maxSuspensionTravelCm;
|
btScalar m_maxSuspensionTravelCm;
|
||||||
btScalar m_wheelRadius;
|
btScalar m_wheelRadius;
|
||||||
|
|
||||||
btScalar m_suspensionStiffness;
|
btScalar m_suspensionStiffness;
|
||||||
btScalar m_wheelsDampingCompression;
|
btScalar m_wheelsDampingCompression;
|
||||||
btScalar m_wheelsDampingRelaxation;
|
btScalar m_wheelsDampingRelaxation;
|
||||||
btScalar m_frictionSlip;
|
btScalar m_frictionSlip;
|
||||||
bool m_bIsFrontWheel;
|
bool m_bIsFrontWheel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// btWheelInfo contains information per wheel about friction and suspension.
|
/// btWheelInfo contains information per wheel about friction and suspension.
|
||||||
struct btWheelInfo
|
struct btWheelInfo
|
||||||
{
|
{
|
||||||
struct RaycastInfo
|
struct RaycastInfo
|
||||||
{
|
{
|
||||||
//set by raycaster
|
//set by raycaster
|
||||||
btVector3 m_contactNormalWS;//contactnormal
|
btVector3 m_contactNormalWS;//contactnormal
|
||||||
btVector3 m_contactPointWS;//raycast hitpoint
|
btVector3 m_contactPointWS;//raycast hitpoint
|
||||||
btScalar m_suspensionLength;
|
btScalar m_suspensionLength;
|
||||||
btVector3 m_hardPointWS;//raycast starting point
|
btVector3 m_hardPointWS;//raycast starting point
|
||||||
btVector3 m_wheelDirectionWS; //direction in worldspace
|
btVector3 m_wheelDirectionWS; //direction in worldspace
|
||||||
btVector3 m_wheelAxleWS; // axle in worldspace
|
btVector3 m_wheelAxleWS; // axle in worldspace
|
||||||
bool m_isInContact;
|
bool m_isInContact;
|
||||||
void* m_groundObject; //could be general void* ptr
|
void* m_groundObject; //could be general void* ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
RaycastInfo m_raycastInfo;
|
RaycastInfo m_raycastInfo;
|
||||||
|
|
||||||
btTransform m_worldTransform;
|
btTransform m_worldTransform;
|
||||||
|
|
||||||
btVector3 m_chassisConnectionPointCS; //const
|
btVector3 m_chassisConnectionPointCS; //const
|
||||||
btVector3 m_wheelDirectionCS;//const
|
btVector3 m_wheelDirectionCS;//const
|
||||||
btVector3 m_wheelAxleCS; // const or modified by steering
|
btVector3 m_wheelAxleCS; // const or modified by steering
|
||||||
btScalar m_suspensionRestLength1;//const
|
btScalar m_suspensionRestLength1;//const
|
||||||
btScalar m_maxSuspensionTravelCm;
|
btScalar m_maxSuspensionTravelCm;
|
||||||
btScalar getSuspensionRestLength() const;
|
btScalar getSuspensionRestLength() const;
|
||||||
btScalar m_wheelsRadius;//const
|
btScalar m_wheelsRadius;//const
|
||||||
btScalar m_suspensionStiffness;//const
|
btScalar m_suspensionStiffness;//const
|
||||||
btScalar m_wheelsDampingCompression;//const
|
btScalar m_wheelsDampingCompression;//const
|
||||||
btScalar m_wheelsDampingRelaxation;//const
|
btScalar m_wheelsDampingRelaxation;//const
|
||||||
btScalar m_frictionSlip;
|
btScalar m_frictionSlip;
|
||||||
btScalar m_steering;
|
btScalar m_steering;
|
||||||
btScalar m_rotation;
|
btScalar m_rotation;
|
||||||
btScalar m_deltaRotation;
|
btScalar m_deltaRotation;
|
||||||
btScalar m_rollInfluence;
|
btScalar m_rollInfluence;
|
||||||
|
|
||||||
btScalar m_engineForce;
|
btScalar m_engineForce;
|
||||||
|
|
||||||
btScalar m_brake;
|
btScalar m_brake;
|
||||||
|
|
||||||
bool m_bIsFrontWheel;
|
bool m_bIsFrontWheel;
|
||||||
|
|
||||||
void* m_clientInfo;//can be used to store pointer to sync transforms...
|
void* m_clientInfo;//can be used to store pointer to sync transforms...
|
||||||
|
|
||||||
btWheelInfo(btWheelInfoConstructionInfo& ci)
|
btWheelInfo(btWheelInfoConstructionInfo& ci)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
m_suspensionRestLength1 = ci.m_suspensionRestLength;
|
m_suspensionRestLength1 = ci.m_suspensionRestLength;
|
||||||
m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm;
|
m_maxSuspensionTravelCm = ci.m_maxSuspensionTravelCm;
|
||||||
|
|
||||||
m_wheelsRadius = ci.m_wheelRadius;
|
m_wheelsRadius = ci.m_wheelRadius;
|
||||||
m_suspensionStiffness = ci.m_suspensionStiffness;
|
m_suspensionStiffness = ci.m_suspensionStiffness;
|
||||||
m_wheelsDampingCompression = ci.m_wheelsDampingCompression;
|
m_wheelsDampingCompression = ci.m_wheelsDampingCompression;
|
||||||
m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation;
|
m_wheelsDampingRelaxation = ci.m_wheelsDampingRelaxation;
|
||||||
m_chassisConnectionPointCS = ci.m_chassisConnectionCS;
|
m_chassisConnectionPointCS = ci.m_chassisConnectionCS;
|
||||||
m_wheelDirectionCS = ci.m_wheelDirectionCS;
|
m_wheelDirectionCS = ci.m_wheelDirectionCS;
|
||||||
m_wheelAxleCS = ci.m_wheelAxleCS;
|
m_wheelAxleCS = ci.m_wheelAxleCS;
|
||||||
m_frictionSlip = ci.m_frictionSlip;
|
m_frictionSlip = ci.m_frictionSlip;
|
||||||
m_steering = btScalar(0.);
|
m_steering = btScalar(0.);
|
||||||
m_engineForce = btScalar(0.);
|
m_engineForce = btScalar(0.);
|
||||||
m_rotation = btScalar(0.);
|
m_rotation = btScalar(0.);
|
||||||
m_deltaRotation = btScalar(0.);
|
m_deltaRotation = btScalar(0.);
|
||||||
m_brake = btScalar(0.);
|
m_brake = btScalar(0.);
|
||||||
m_rollInfluence = btScalar(0.1);
|
m_rollInfluence = btScalar(0.1);
|
||||||
m_bIsFrontWheel = ci.m_bIsFrontWheel;
|
m_bIsFrontWheel = ci.m_bIsFrontWheel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo);
|
void updateWheel(const btRigidBody& chassis,RaycastInfo& raycastInfo);
|
||||||
|
|
||||||
btScalar m_clippedInvContactDotSuspension;
|
btScalar m_clippedInvContactDotSuspension;
|
||||||
btScalar m_suspensionRelativeVelocity;
|
btScalar m_suspensionRelativeVelocity;
|
||||||
//calculated by suspension
|
//calculated by suspension
|
||||||
btScalar m_wheelsSuspensionForce;
|
btScalar m_wheelsSuspensionForce;
|
||||||
btScalar m_skidInfo;
|
btScalar m_skidInfo;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //WHEEL_INFO_H
|
#endif //WHEEL_INFO_H
|
||||||
|
|
||||||
|
|||||||
@@ -1,44 +1,44 @@
|
|||||||
#### Source code Dirs
|
#### Source code Dirs
|
||||||
VPATH = \
|
VPATH = \
|
||||||
../ConstraintSolver \
|
../ConstraintSolver \
|
||||||
../Dynamics \
|
../Dynamics \
|
||||||
../Vehicle
|
../Vehicle
|
||||||
|
|
||||||
ROOT = ../../..
|
ROOT = ../../..
|
||||||
|
|
||||||
#### Library
|
#### Library
|
||||||
LIBRARY_ppu = bulletdynamics.a
|
LIBRARY_ppu = bulletdynamics.a
|
||||||
|
|
||||||
#### Compiler flags
|
#### Compiler flags
|
||||||
CPPFLAGS = \
|
CPPFLAGS = \
|
||||||
-I../ConstraintSolver \
|
-I../ConstraintSolver \
|
||||||
-I../Dynamics \
|
-I../Dynamics \
|
||||||
-I../Vehicle \
|
-I../Vehicle \
|
||||||
-I$(ROOT)/src \
|
-I$(ROOT)/src \
|
||||||
-I$(SDKINC)
|
-I$(SDKINC)
|
||||||
|
|
||||||
#### Optimization level flags
|
#### Optimization level flags
|
||||||
#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG)
|
#CC_OPT_LEVEL = $(CC_OPT_LEVEL_DEBUG)
|
||||||
CC_OPT_LEVEL = -O3
|
CC_OPT_LEVEL = -O3
|
||||||
|
|
||||||
##### Objects to be archived in lib
|
##### Objects to be archived in lib
|
||||||
|
|
||||||
OBJS = \
|
OBJS = \
|
||||||
btContactConstraint.o \
|
btContactConstraint.o \
|
||||||
btGeneric6DofConstraint.o \
|
btGeneric6DofConstraint.o \
|
||||||
btHingeConstraint.o \
|
btHingeConstraint.o \
|
||||||
btPoint2PointConstraint.o \
|
btPoint2PointConstraint.o \
|
||||||
btSequentialImpulseConstraintSolver.o \
|
btSequentialImpulseConstraintSolver.o \
|
||||||
btSolve2LinearConstraint.o \
|
btSolve2LinearConstraint.o \
|
||||||
btTypedConstraint.o \
|
btTypedConstraint.o \
|
||||||
btDiscreteDynamicsWorld.o \
|
btDiscreteDynamicsWorld.o \
|
||||||
btRigidBody.o \
|
btRigidBody.o \
|
||||||
btSimpleDynamicsWorld.o \
|
btSimpleDynamicsWorld.o \
|
||||||
btRaycastVehicle.o \
|
btRaycastVehicle.o \
|
||||||
btWheelInfo.o
|
btWheelInfo.o
|
||||||
#### Install directories
|
#### Install directories
|
||||||
INSTALL_DIR = $(ROOT)/lib/ibmsdk
|
INSTALL_DIR = $(ROOT)/lib/ibmsdk
|
||||||
INSTALL_FILES = $(LIBRARY_ppu)
|
INSTALL_FILES = $(LIBRARY_ppu)
|
||||||
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
||||||
|
|
||||||
include $(CELL_TOP)/make.footer
|
include $(CELL_TOP)/make.footer
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ subject to the following restrictions:
|
|||||||
#define _BT_POOL_ALLOCATOR_H
|
#define _BT_POOL_ALLOCATOR_H
|
||||||
|
|
||||||
#include "btScalar.h"
|
#include "btScalar.h"
|
||||||
|
#include "btAlignedAllocator.h"
|
||||||
|
|
||||||
class btPoolAllocator
|
class btPoolAllocator
|
||||||
{
|
{
|
||||||
@@ -32,7 +33,7 @@ public:
|
|||||||
:m_elemSize(elemSize),
|
:m_elemSize(elemSize),
|
||||||
m_maxElements(maxElements)
|
m_maxElements(maxElements)
|
||||||
{
|
{
|
||||||
m_pool = new unsigned char[m_elemSize*m_maxElements];
|
m_pool = (unsigned char*) btAlignedAlloc(m_elemSize*m_maxElements,16);
|
||||||
|
|
||||||
unsigned char* p = m_pool;
|
unsigned char* p = m_pool;
|
||||||
m_firstFree = p;
|
m_firstFree = p;
|
||||||
@@ -47,7 +48,7 @@ public:
|
|||||||
|
|
||||||
~btPoolAllocator()
|
~btPoolAllocator()
|
||||||
{
|
{
|
||||||
delete m_pool;
|
btAlignedFree( m_pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* allocate(int size)
|
void* allocate(int size)
|
||||||
|
|||||||
@@ -25,11 +25,13 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
#if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)
|
#if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)
|
||||||
#define SIMD_FORCE_INLINE inline
|
#define SIMD_FORCE_INLINE inline
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a
|
#define ATTRIBUTE_ALIGNED16(a) a
|
||||||
|
#define ATTRIBUTE_ALIGNED128(a) a
|
||||||
#else
|
#else
|
||||||
#define BT_HAS_ALIGNED_ALOCATOR
|
#define BT_HAS_ALIGNED_ALOCATOR
|
||||||
#pragma warning(disable:4530)
|
#pragma warning(disable:4530)
|
||||||
@@ -37,6 +39,7 @@ subject to the following restrictions:
|
|||||||
#pragma warning(disable:4786)
|
#pragma warning(disable:4786)
|
||||||
#define SIMD_FORCE_INLINE __forceinline
|
#define SIMD_FORCE_INLINE __forceinline
|
||||||
#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
#define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
|
||||||
|
#define ATTRIBUTE_ALIGNED128(a) __declspec (align(128)) a
|
||||||
#ifdef _XBOX
|
#ifdef _XBOX
|
||||||
#define BT_USE_VMX128
|
#define BT_USE_VMX128
|
||||||
|
|
||||||
@@ -52,29 +55,61 @@ subject to the following restrictions:
|
|||||||
#define btAssert assert
|
#define btAssert assert
|
||||||
//btFullAssert is optional, slows down a lot
|
//btFullAssert is optional, slows down a lot
|
||||||
#define btFullAssert(x)
|
#define btFullAssert(x)
|
||||||
|
|
||||||
|
#define btLikely(_c) _c
|
||||||
|
#define btUnlikely(_c) _c
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#if defined (__CELLOS_LV2__)
|
#if defined (__CELLOS_LV2__)
|
||||||
#define SIMD_FORCE_INLINE inline
|
#define SIMD_FORCE_INLINE inline
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||||
|
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||||
#ifndef assert
|
#ifndef assert
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
#define btAssert assert
|
#define btAssert assert
|
||||||
//btFullAssert is optional, slows down a lot
|
//btFullAssert is optional, slows down a lot
|
||||||
#define btFullAssert(x)
|
#define btFullAssert(x)
|
||||||
|
|
||||||
|
#define btLikely(_c) _c
|
||||||
|
#define btUnlikely(_c) _c
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#ifdef USE_LIBSPE2
|
||||||
|
|
||||||
|
#define SIMD_FORCE_INLINE __inline
|
||||||
|
#define ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
|
||||||
|
#define ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
|
||||||
|
#ifndef assert
|
||||||
|
#include <assert.h>
|
||||||
|
#endif
|
||||||
|
#define btAssert assert
|
||||||
|
//btFullAssert is optional, slows down a lot
|
||||||
|
#define btFullAssert(x)
|
||||||
|
|
||||||
|
|
||||||
|
#define btLikely(_c) __builtin_expect((_c), 1)
|
||||||
|
#define btUnlikely(_c) __builtin_expect((_c), 0)
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
//non-windows systems
|
//non-windows systems
|
||||||
|
|
||||||
#define SIMD_FORCE_INLINE inline
|
#define SIMD_FORCE_INLINE inline
|
||||||
#define ATTRIBUTE_ALIGNED16(a) a
|
#define ATTRIBUTE_ALIGNED16(a) a
|
||||||
|
#define ATTRIBUTE_ALIGNED128(a) a
|
||||||
#ifndef assert
|
#ifndef assert
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#endif
|
#endif
|
||||||
#define btAssert assert
|
#define btAssert assert
|
||||||
//btFullAssert is optional, slows down a lot
|
//btFullAssert is optional, slows down a lot
|
||||||
#define btFullAssert(x)
|
#define btFullAssert(x)
|
||||||
|
|
||||||
|
|
||||||
|
#endif // LIBSPE2
|
||||||
|
|
||||||
#endif //__CELLOS_LV2__
|
#endif //__CELLOS_LV2__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -94,6 +129,14 @@ typedef float btScalar;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define BT_DECLARE_ALIGNED_ALLOCATOR() \
|
||||||
|
SIMD_FORCE_INLINE void* operator new(size_t sizeInBytes) { return btAlignedAlloc(sizeInBytes,16); } \
|
||||||
|
SIMD_FORCE_INLINE void operator delete(void* ptr) { btAlignedFree(ptr); } \
|
||||||
|
SIMD_FORCE_INLINE void* operator new(size_t, void* ptr) { return ptr; } \
|
||||||
|
SIMD_FORCE_INLINE void operator delete(void*, void*) { } \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)
|
#if defined(BT_USE_DOUBLE_PRECISION) || defined(BT_FORCE_DOUBLE_FUNCTIONS)
|
||||||
|
|
||||||
SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); }
|
SIMD_FORCE_INLINE btScalar btSqrt(btScalar x) { return sqrt(x); }
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Nov.2006
|
|||||||
#define BT_STACK_ALLOC
|
#define BT_STACK_ALLOC
|
||||||
|
|
||||||
#include "btScalar.h" //for btAssert
|
#include "btScalar.h" //for btAssert
|
||||||
|
#include "btAlignedAllocator.h"
|
||||||
|
|
||||||
struct btBlock
|
struct btBlock
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,7 @@ public:
|
|||||||
inline void create(unsigned int size)
|
inline void create(unsigned int size)
|
||||||
{
|
{
|
||||||
destroy();
|
destroy();
|
||||||
data = new unsigned char[size];
|
data = (unsigned char*) btAlignedAlloc(size,16);
|
||||||
totalsize = size;
|
totalsize = size;
|
||||||
}
|
}
|
||||||
inline void destroy()
|
inline void destroy()
|
||||||
@@ -49,7 +50,9 @@ public:
|
|||||||
|
|
||||||
if(usedsize==0)
|
if(usedsize==0)
|
||||||
{
|
{
|
||||||
if(!ischild) delete[] data;
|
if(!ischild)
|
||||||
|
btAlignedFree(data);
|
||||||
|
|
||||||
data = 0;
|
data = 0;
|
||||||
usedsize = 0;
|
usedsize = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#### Visit Bullet library ibmsdk dirs and build code
|
#### Visit Bullet library ibmsdk dirs and build code
|
||||||
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
CELL_TOP ?= /opt/ibm/cell-sdk/prototype
|
||||||
|
|
||||||
DIRS := \
|
DIRS := \
|
||||||
../BulletCollision/ibmsdk \
|
../BulletCollision/ibmsdk \
|
||||||
../BulletDynamics/ibmsdk \
|
../BulletDynamics/ibmsdk \
|
||||||
../LinearMath/ibmsdk
|
../LinearMath/ibmsdk
|
||||||
|
|
||||||
|
|
||||||
include $(CELL_TOP)/make.footer
|
include $(CELL_TOP)/make.footer
|
||||||
|
|||||||
Reference in New Issue
Block a user