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;
|
||||||
|
|
||||||
@@ -245,7 +247,10 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,63 +118,18 @@ 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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -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,6 +35,7 @@ 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];
|
||||||
@@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
@@ -20,12 +20,15 @@ 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.
|
///btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packed to increase cache coherence/performance.
|
||||||
ATTRIBUTE_ALIGNED16 (struct) btSolverBody
|
ATTRIBUTE_ALIGNED16 (struct) btSolverBody
|
||||||
{
|
{
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btVector3 m_centerOfMassPosition;
|
btVector3 m_centerOfMassPosition;
|
||||||
btVector3 m_linearVelocity;
|
btVector3 m_linearVelocity;
|
||||||
btVector3 m_angularVelocity;
|
btVector3 m_angularVelocity;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ class btRigidBody;
|
|||||||
///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
|
||||||
{
|
{
|
||||||
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
||||||
|
|
||||||
btVector3 m_relpos1CrossNormal;
|
btVector3 m_relpos1CrossNormal;
|
||||||
btVector3 m_relpos2CrossNormal;
|
btVector3 m_relpos2CrossNormal;
|
||||||
btVector3 m_contactNormal;
|
btVector3 m_contactNormal;
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user