Replaced most STL std::vector with btAlignedObjectArray.
Same interface but less features (push_back, pop_back, clear, size, [] etc). To prepare for SIMD/SSE code: Added #define ATTRIBUTE_ALIGNED16(a) __declspec(align(16)) a
This commit is contained in:
@@ -29,13 +29,33 @@ float gCollisionMargin = 0.05f;
|
||||
#include "BasicDemo.h"
|
||||
#include "GL_ShapeDrawer.h"
|
||||
#include "GlutStuff.h"
|
||||
|
||||
#include <LinearMath/btAlignedObjectArray.h>
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
GLDebugDrawer debugDrawer;
|
||||
|
||||
class myTest
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
|
||||
{
|
||||
///btAlignedObjectArray works the same as std::vector but
|
||||
///allows 16-byte aligned objects like SIMD vectors etc.
|
||||
btAlignedObjectArray<btVector3> m_points;
|
||||
m_points.push_back(btVector3(1,2,3));
|
||||
const btVector3& ref = m_points[0];
|
||||
m_points[0] = btVector3(2,3,4);
|
||||
m_points.pop_back();
|
||||
}
|
||||
|
||||
BasicDemo ccdDemo;
|
||||
ccdDemo.initPhysics();
|
||||
ccdDemo.setCameraDistance(50.f);
|
||||
|
||||
@@ -53,7 +53,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
|
||||
for (int b=0;b<leaf.numLeafBrushes;b++)
|
||||
{
|
||||
std::vector<btVector3> planeEquations;
|
||||
btAlignedObjectArray<btVector3> planeEquations;
|
||||
|
||||
int brushid = bspLoader.m_dleafbrushes[leaf.firstLeafBrush+b];
|
||||
|
||||
@@ -83,7 +83,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
if (isValidBrush)
|
||||
{
|
||||
|
||||
std::vector<btVector3> vertices;
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
btGeometryUtil::getVerticesFromPlaneEquations(planeEquations,vertices);
|
||||
|
||||
bool isEntity = false;
|
||||
@@ -134,7 +134,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
const BSPModel& model = bspLoader.m_dmodels[modelnr];
|
||||
for (int n=0;n<model.numBrushes;n++)
|
||||
{
|
||||
std::vector<btVector3> planeEquations;
|
||||
btAlignedObjectArray<btVector3> planeEquations;
|
||||
bool isValidBrush = false;
|
||||
|
||||
//convert brush
|
||||
@@ -158,7 +158,7 @@ void BspConverter::convertBsp(BspLoader& bspLoader,float scaling)
|
||||
if (isValidBrush)
|
||||
{
|
||||
|
||||
std::vector<btVector3> vertices;
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
btGeometryUtil::getVerticesFromPlaneEquations(planeEquations,vertices);
|
||||
|
||||
bool isEntity=true;
|
||||
|
||||
@@ -19,6 +19,7 @@ subject to the following restrictions:
|
||||
class BspLoader;
|
||||
#include <vector>
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "LinearMath/btAlignedObjectArray.h"
|
||||
|
||||
///BspConverter turns a loaded bsp level into convex parts (vertices)
|
||||
class BspConverter
|
||||
@@ -31,7 +32,7 @@ class BspConverter
|
||||
}
|
||||
|
||||
///this callback is called for each brush that succesfully converted into vertices
|
||||
virtual void addConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0;
|
||||
virtual void addConvexVerticesCollider(btAlignedObjectArray<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void addConvexVerticesCollider(std::vector<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation)
|
||||
virtual void addConvexVerticesCollider(btAlignedObjectArray<btVector3>& vertices, bool isEntity, const btVector3& entityTargetLocation)
|
||||
{
|
||||
///perhaps we can do something special with entities (isEntity)
|
||||
///like adding a collision Triggering (as example)
|
||||
|
||||
@@ -91,7 +91,7 @@ void CollisionInterfaceDemo::initPhysics()
|
||||
//SimpleBroadphase* broadphase = new btSimpleBroadphase;
|
||||
|
||||
collisionWorld = new btCollisionWorld(dispatcher,broadphase);
|
||||
|
||||
|
||||
collisionWorld->addCollisionObject(&objects[0]);
|
||||
collisionWorld->addCollisionObject(&objects[1]);
|
||||
|
||||
@@ -117,12 +117,10 @@ void CollisionInterfaceDemo::displayCallback(void) {
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
|
||||
btDispatcherInfo dispatchInfo;
|
||||
dispatchInfo.m_debugDraw = &debugDrawer;
|
||||
collisionWorld->getDispatchInfo().m_debugDraw = &debugDrawer;
|
||||
|
||||
if (collisionWorld)
|
||||
collisionWorld->performDiscreteCollisionDetection(dispatchInfo);
|
||||
collisionWorld->performDiscreteCollisionDetection();
|
||||
|
||||
int i;
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
||||
|
||||
//calc centroid, to shift vertices around center of mass
|
||||
centroid.setValue(0,0,0);
|
||||
std::vector<btVector3> vertices;
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
if ( 1 )
|
||||
{
|
||||
//const unsigned int *src = result.mHullIndices;
|
||||
|
||||
Reference in New Issue
Block a user