more bt* to b3*
This commit is contained in:
@@ -23,7 +23,7 @@ subject to the following restrictions:
|
||||
#define START_POS_Y 10
|
||||
#define START_POS_Z -3
|
||||
|
||||
#include "LinearMath/btVector3.h"
|
||||
#include "LinearMath/b3Vector3.h"
|
||||
|
||||
#include "GpuDemo.h"
|
||||
//#include "GlutStuff.h"
|
||||
@@ -41,7 +41,7 @@ subject to the following restrictions:
|
||||
|
||||
#include "BulletDynamics/Dynamics/btRigidBody.h"
|
||||
#include "LinearMath/btDefaultMotionState.h"
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/b3Quickprof.h"
|
||||
|
||||
|
||||
#include <stdio.h> //printf debugging
|
||||
@@ -90,7 +90,7 @@ void GpuDemo::clientMoveAndDisplay()
|
||||
|
||||
|
||||
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
b3AlignedObjectArray<b3Vector3> vertices;
|
||||
|
||||
void EmptyDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
@@ -107,7 +107,7 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
m_collisionShapes.push_back(sphere);
|
||||
|
||||
/// Create Dynamic Objects
|
||||
btTransform startTransform;
|
||||
b3Transform startTransform;
|
||||
startTransform.setIdentity();
|
||||
|
||||
|
||||
@@ -134,21 +134,21 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
btCollisionShape* shape = sphere;
|
||||
|
||||
|
||||
btScalar mass = 1;
|
||||
b3Scalar mass = 1;
|
||||
if (!ci.m_useConcaveMesh && k==0)
|
||||
mass = k==0? 0.f : 1.f;
|
||||
|
||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||
bool isDynamic = (mass != 0.f);
|
||||
|
||||
btVector3 localInertia(0,0,0);
|
||||
b3Vector3 localInertia(0,0,0);
|
||||
if (isDynamic)
|
||||
shape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
startTransform.setOrigin(SCALING*btVector3(
|
||||
btScalar(gapX*i + start_x),
|
||||
btScalar(ci.gapY*k + start_y),
|
||||
btScalar(gapZ*j + start_z)));
|
||||
startTransform.setOrigin(SCALING*b3Vector3(
|
||||
b3Scalar(gapX*i + start_x),
|
||||
b3Scalar(ci.gapY*k + start_y),
|
||||
b3Scalar(gapZ*j + start_z)));
|
||||
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
@@ -164,24 +164,24 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
}
|
||||
|
||||
{
|
||||
btVector3 planeNormal(0,1,0);
|
||||
btScalar planeConstant=0;
|
||||
b3Vector3 planeNormal(0,1,0);
|
||||
b3Scalar planeConstant=0;
|
||||
|
||||
btCollisionShape* shape = new btStaticPlaneShape(planeNormal,planeConstant);
|
||||
//btBoxShape* plane = new btBoxShape(btVector3(100,1,100));
|
||||
//btBoxShape* plane = new btBoxShape(b3Vector3(100,1,100));
|
||||
//plane->initializePolyhedralFeatures();
|
||||
//btSphereShape* shape = new btSphereShape(1000);
|
||||
|
||||
btScalar mass(0.);
|
||||
b3Scalar mass(0.);
|
||||
|
||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||
bool isDynamic = (mass != 0.f);
|
||||
|
||||
btVector3 localInertia(0,0,0);
|
||||
btTransform groundTransform;
|
||||
b3Vector3 localInertia(0,0,0);
|
||||
b3Transform groundTransform;
|
||||
groundTransform.setIdentity();
|
||||
groundTransform.setRotation(btQuaternion(btVector3(1,0,0),0.3));
|
||||
groundTransform.setOrigin(btVector3(0,0,0));
|
||||
groundTransform.setRotation(b3Quaternion(b3Vector3(1,0,0),0.3));
|
||||
groundTransform.setOrigin(b3Vector3(0,0,0));
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
|
||||
@@ -198,18 +198,18 @@ void SpheresDemo::setupScene(const ConstructionInfo& ci)
|
||||
void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
btCollisionShape* groundShape =0;
|
||||
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
||||
// btCollisionShape* groundShape = new btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
|
||||
if (ci.m_useConcaveMesh)
|
||||
{
|
||||
btTriangleMesh* meshInterface = new btTriangleMesh();
|
||||
|
||||
btAlignedObjectArray<btVector3> concaveVertices;
|
||||
concaveVertices.push_back(btVector3(0,-20,0));
|
||||
concaveVertices.push_back(btVector3(80,10,80));
|
||||
concaveVertices.push_back(btVector3(80,10,-80));
|
||||
concaveVertices.push_back(btVector3(-80,10,-80));
|
||||
concaveVertices.push_back(btVector3(-80,10,80));
|
||||
b3AlignedObjectArray<b3Vector3> concaveVertices;
|
||||
concaveVertices.push_back(b3Vector3(0,-20,0));
|
||||
concaveVertices.push_back(b3Vector3(80,10,80));
|
||||
concaveVertices.push_back(b3Vector3(80,10,-80));
|
||||
concaveVertices.push_back(b3Vector3(-80,10,-80));
|
||||
concaveVertices.push_back(b3Vector3(-80,10,80));
|
||||
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[1],concaveVertices[2],true);
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[2],concaveVertices[3],true);
|
||||
@@ -217,33 +217,33 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[4],concaveVertices[1],true);
|
||||
|
||||
#if 0
|
||||
groundShape = new btBvhTriangleMeshShape(meshInterface,true);//btStaticPlaneShape(btVector3(0,1,0),50);
|
||||
groundShape = new btBvhTriangleMeshShape(meshInterface,true);//btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
#else
|
||||
btBoxShape* shape =new btBoxShape(btVector3(btScalar(250.),btScalar(10.),btScalar(250.)));
|
||||
btBoxShape* shape =new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(10.),b3Scalar(250.)));
|
||||
shape->initializePolyhedralFeatures();
|
||||
groundShape = shape;
|
||||
#endif
|
||||
|
||||
} else
|
||||
{
|
||||
groundShape = new btBoxShape(btVector3(btScalar(250.),btScalar(50.),btScalar(250.)));
|
||||
groundShape = new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(50.),b3Scalar(250.)));
|
||||
}
|
||||
|
||||
m_collisionShapes.push_back(groundShape);
|
||||
|
||||
btTransform groundTransform;
|
||||
b3Transform groundTransform;
|
||||
groundTransform.setIdentity();
|
||||
groundTransform.setOrigin(btVector3(0,0,0));
|
||||
groundTransform.setOrigin(b3Vector3(0,0,0));
|
||||
|
||||
//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
|
||||
if (ci.m_useConcaveMesh)
|
||||
{
|
||||
btScalar mass(0.);
|
||||
b3Scalar mass(0.);
|
||||
|
||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||
bool isDynamic = (mass != 0.f);
|
||||
|
||||
btVector3 localInertia(0,0,0);
|
||||
b3Vector3 localInertia(0,0,0);
|
||||
if (isDynamic)
|
||||
groundShape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
@@ -261,15 +261,15 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
//create a few dynamic rigidbodies
|
||||
// Re-using the same collision is better for memory usage and performance
|
||||
|
||||
//vertices.push_back(btVector3(0,1,0));
|
||||
vertices.push_back(btVector3(1,1,1));
|
||||
vertices.push_back(btVector3(1,1,-1));
|
||||
vertices.push_back(btVector3(-1,1,-1));
|
||||
vertices.push_back(btVector3(-1,1,1));
|
||||
vertices.push_back(btVector3(1,-1,1));
|
||||
vertices.push_back(btVector3(1,-1,-1));
|
||||
vertices.push_back(btVector3(-1,-1,-1));
|
||||
vertices.push_back(btVector3(-1,-1,1));
|
||||
//vertices.push_back(b3Vector3(0,1,0));
|
||||
vertices.push_back(b3Vector3(1,1,1));
|
||||
vertices.push_back(b3Vector3(1,1,-1));
|
||||
vertices.push_back(b3Vector3(-1,1,-1));
|
||||
vertices.push_back(b3Vector3(-1,1,1));
|
||||
vertices.push_back(b3Vector3(1,-1,1));
|
||||
vertices.push_back(b3Vector3(1,-1,-1));
|
||||
vertices.push_back(b3Vector3(-1,-1,-1));
|
||||
vertices.push_back(b3Vector3(-1,-1,1));
|
||||
|
||||
#if 0
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
@@ -280,13 +280,13 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
colShape->initializePolyhedralFeatures();
|
||||
compoundShape = new btCompoundShape();
|
||||
btTransform tr;
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(btVector3(0,-1,0));
|
||||
tr.setOrigin(b3Vector3(0,-1,0));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
tr.setOrigin(btVector3(0,0,2));
|
||||
tr.setOrigin(b3Vector3(0,0,2));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
tr.setOrigin(btVector3(2,0,0));
|
||||
tr.setOrigin(b3Vector3(2,0,0));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
}
|
||||
btCollisionShape* colShape = compoundShape;
|
||||
@@ -294,18 +294,18 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
|
||||
btPolyhedralConvexShape* boxShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
btPolyhedralConvexShape* boxShape = new btBoxShape(b3Vector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
boxShape->initializePolyhedralFeatures();
|
||||
|
||||
|
||||
|
||||
|
||||
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||
//btCollisionShape* colShape = new btSphereShape(b3Scalar(1.));
|
||||
m_collisionShapes.push_back(colShape);
|
||||
m_collisionShapes.push_back(boxShape);
|
||||
|
||||
/// Create Dynamic Objects
|
||||
btTransform startTransform;
|
||||
b3Transform startTransform;
|
||||
startTransform.setIdentity();
|
||||
|
||||
|
||||
@@ -334,21 +334,21 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
btCollisionShape* shape = colShape;
|
||||
|
||||
|
||||
btScalar mass = 1;
|
||||
b3Scalar mass = 1;
|
||||
if (!ci.m_useConcaveMesh && k==0)
|
||||
mass = k==0? 0.f : 1.f;
|
||||
|
||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||
bool isDynamic = (mass != 0.f);
|
||||
|
||||
btVector3 localInertia(0,0,0);
|
||||
b3Vector3 localInertia(0,0,0);
|
||||
if (isDynamic)
|
||||
shape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
startTransform.setOrigin(SCALING*btVector3(
|
||||
btScalar(startX+gapX*i + start_x),
|
||||
btScalar(20+ci.gapY*k + start_y),
|
||||
btScalar(startZ+gapZ*j + start_z)));
|
||||
startTransform.setOrigin(SCALING*b3Vector3(
|
||||
b3Scalar(startX+gapX*i + start_x),
|
||||
b3Scalar(20+ci.gapY*k + start_y),
|
||||
b3Scalar(startZ+gapZ*j + start_z)));
|
||||
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
@@ -369,18 +369,18 @@ void GpuCompoundDemo::setupScene(const ConstructionInfo& ci)
|
||||
void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
{
|
||||
btCollisionShape* groundShape =0;
|
||||
// btCollisionShape* groundShape = new btStaticPlaneShape(btVector3(0,1,0),50);
|
||||
// btCollisionShape* groundShape = new btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
|
||||
if (ci.m_useConcaveMesh)
|
||||
{
|
||||
btTriangleMesh* meshInterface = new btTriangleMesh();
|
||||
|
||||
btAlignedObjectArray<btVector3> concaveVertices;
|
||||
concaveVertices.push_back(btVector3(0,-20,0));
|
||||
concaveVertices.push_back(btVector3(80,10,80));
|
||||
concaveVertices.push_back(btVector3(80,10,-80));
|
||||
concaveVertices.push_back(btVector3(-80,10,-80));
|
||||
concaveVertices.push_back(btVector3(-80,10,80));
|
||||
b3AlignedObjectArray<b3Vector3> concaveVertices;
|
||||
concaveVertices.push_back(b3Vector3(0,-20,0));
|
||||
concaveVertices.push_back(b3Vector3(80,10,80));
|
||||
concaveVertices.push_back(b3Vector3(80,10,-80));
|
||||
concaveVertices.push_back(b3Vector3(-80,10,-80));
|
||||
concaveVertices.push_back(b3Vector3(-80,10,80));
|
||||
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[1],concaveVertices[2],true);
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[2],concaveVertices[3],true);
|
||||
@@ -388,33 +388,33 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
meshInterface->addTriangle(concaveVertices[0],concaveVertices[4],concaveVertices[1],true);
|
||||
|
||||
#if 0
|
||||
groundShape = new btBvhTriangleMeshShape(meshInterface,true);//btStaticPlaneShape(btVector3(0,1,0),50);
|
||||
groundShape = new btBvhTriangleMeshShape(meshInterface,true);//btStaticPlaneShape(b3Vector3(0,1,0),50);
|
||||
#else
|
||||
btBoxShape* shape =new btBoxShape(btVector3(btScalar(250.),btScalar(10.),btScalar(250.)));
|
||||
btBoxShape* shape =new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(10.),b3Scalar(250.)));
|
||||
shape->initializePolyhedralFeatures();
|
||||
groundShape = shape;
|
||||
#endif
|
||||
|
||||
} else
|
||||
{
|
||||
groundShape = new btBoxShape(btVector3(btScalar(250.),btScalar(50.),btScalar(250.)));
|
||||
groundShape = new btBoxShape(b3Vector3(b3Scalar(250.),b3Scalar(50.),b3Scalar(250.)));
|
||||
}
|
||||
|
||||
m_collisionShapes.push_back(groundShape);
|
||||
|
||||
btTransform groundTransform;
|
||||
b3Transform groundTransform;
|
||||
groundTransform.setIdentity();
|
||||
groundTransform.setOrigin(btVector3(0,0,0));
|
||||
groundTransform.setOrigin(b3Vector3(0,0,0));
|
||||
|
||||
//We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
|
||||
if (ci.m_useConcaveMesh)
|
||||
{
|
||||
btScalar mass(0.);
|
||||
b3Scalar mass(0.);
|
||||
|
||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||
bool isDynamic = (mass != 0.f);
|
||||
|
||||
btVector3 localInertia(0,0,0);
|
||||
b3Vector3 localInertia(0,0,0);
|
||||
if (isDynamic)
|
||||
groundShape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
@@ -432,15 +432,15 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
//create a few dynamic rigidbodies
|
||||
// Re-using the same collision is better for memory usage and performance
|
||||
|
||||
//vertices.push_back(btVector3(0,1,0));
|
||||
vertices.push_back(btVector3(1,1,1));
|
||||
vertices.push_back(btVector3(1,1,-1));
|
||||
vertices.push_back(btVector3(-1,1,-1));
|
||||
vertices.push_back(btVector3(-1,1,1));
|
||||
vertices.push_back(btVector3(1,-1,1));
|
||||
vertices.push_back(btVector3(1,-1,-1));
|
||||
vertices.push_back(btVector3(-1,-1,-1));
|
||||
vertices.push_back(btVector3(-1,-1,1));
|
||||
//vertices.push_back(b3Vector3(0,1,0));
|
||||
vertices.push_back(b3Vector3(1,1,1));
|
||||
vertices.push_back(b3Vector3(1,1,-1));
|
||||
vertices.push_back(b3Vector3(-1,1,-1));
|
||||
vertices.push_back(b3Vector3(-1,1,1));
|
||||
vertices.push_back(b3Vector3(1,-1,1));
|
||||
vertices.push_back(b3Vector3(1,-1,-1));
|
||||
vertices.push_back(b3Vector3(-1,-1,-1));
|
||||
vertices.push_back(b3Vector3(-1,-1,1));
|
||||
|
||||
#if 1
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
@@ -451,13 +451,13 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
btPolyhedralConvexShape* colShape = new btConvexHullShape(&vertices[0].getX(),vertices.size());
|
||||
colShape->initializePolyhedralFeatures();
|
||||
compoundShape = new btCompoundShape();
|
||||
btTransform tr;
|
||||
b3Transform tr;
|
||||
tr.setIdentity();
|
||||
tr.setOrigin(btVector3(0,-1,0));
|
||||
tr.setOrigin(b3Vector3(0,-1,0));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
tr.setOrigin(btVector3(0,0,2));
|
||||
tr.setOrigin(b3Vector3(0,0,2));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
tr.setOrigin(btVector3(2,0,0));
|
||||
tr.setOrigin(b3Vector3(2,0,0));
|
||||
compoundShape->addChildShape(tr,colShape);
|
||||
}
|
||||
btCollisionShape* colShape = compoundShape;
|
||||
@@ -465,18 +465,18 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
|
||||
|
||||
|
||||
btPolyhedralConvexShape* boxShape = new btBoxShape(btVector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
btPolyhedralConvexShape* boxShape = new btBoxShape(b3Vector3(SCALING*1,SCALING*1,SCALING*1));
|
||||
boxShape->initializePolyhedralFeatures();
|
||||
|
||||
|
||||
|
||||
|
||||
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||
//btCollisionShape* colShape = new btSphereShape(b3Scalar(1.));
|
||||
m_collisionShapes.push_back(colShape);
|
||||
m_collisionShapes.push_back(boxShape);
|
||||
|
||||
/// Create Dynamic Objects
|
||||
btTransform startTransform;
|
||||
b3Transform startTransform;
|
||||
startTransform.setIdentity();
|
||||
|
||||
|
||||
@@ -505,21 +505,21 @@ void GpuBoxDemo::setupScene(const ConstructionInfo& ci)
|
||||
btCollisionShape* shape = colShape;
|
||||
|
||||
|
||||
btScalar mass = 1;
|
||||
b3Scalar mass = 1;
|
||||
if (!ci.m_useConcaveMesh && k==0)
|
||||
mass = k==0? 0.f : 1.f;
|
||||
|
||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||
bool isDynamic = (mass != 0.f);
|
||||
|
||||
btVector3 localInertia(0,0,0);
|
||||
b3Vector3 localInertia(0,0,0);
|
||||
if (isDynamic)
|
||||
shape->calculateLocalInertia(mass,localInertia);
|
||||
|
||||
startTransform.setOrigin(SCALING*btVector3(
|
||||
btScalar(startX+gapX*i + start_x),
|
||||
btScalar(ci.gapY*(k+0.5) + start_y),
|
||||
btScalar(startZ+gapZ*j + start_z)));
|
||||
startTransform.setOrigin(SCALING*b3Vector3(
|
||||
b3Scalar(startX+gapX*i + start_x),
|
||||
b3Scalar(ci.gapY*(k+0.5) + start_y),
|
||||
b3Scalar(startZ+gapZ*j + start_z)));
|
||||
|
||||
|
||||
//using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
|
||||
@@ -541,7 +541,7 @@ void GpuDemo::initPhysics(const ConstructionInfo& ci)
|
||||
// setTexturing(true);
|
||||
//setShadows(false);
|
||||
|
||||
// setCameraDistance(btScalar(SCALING*250.));
|
||||
// setCameraDistance(b3Scalar(SCALING*250.));
|
||||
|
||||
///collision configuration contains default setup for memory, collision setup
|
||||
if (ci.useOpenCL)
|
||||
@@ -553,7 +553,7 @@ void GpuDemo::initPhysics(const ConstructionInfo& ci)
|
||||
}
|
||||
|
||||
|
||||
m_dynamicsWorld->setGravity(btVector3(0,-10,0));
|
||||
m_dynamicsWorld->setGravity(b3Vector3(0,-10,0));
|
||||
|
||||
///create a few basic rigid bodies
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ subject to the following restrictions:
|
||||
#define GPU_DEMO_H
|
||||
|
||||
|
||||
#include "BulletCommon/btAlignedObjectArray.h"
|
||||
#include "BulletCommon/b3AlignedObjectArray.h"
|
||||
|
||||
|
||||
class btBroadphaseInterface;
|
||||
@@ -41,7 +41,7 @@ protected:
|
||||
btDynamicsWorld* m_dynamicsWorld;
|
||||
|
||||
//keep the collision shapes, for deletion/cleanup
|
||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||
b3AlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||
|
||||
float getDeltaTimeInSeconds()
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "OpenGLWindow/ShapeData.h"
|
||||
//#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
|
||||
//#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
|
||||
#include "BulletCommon/btQuickprof.h"
|
||||
#include "BulletCommon/b3Quickprof.h"
|
||||
|
||||
/*#include "BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btConvexPolyhedron.h"
|
||||
@@ -64,20 +64,20 @@ struct GraphicsShape
|
||||
GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilPtr)
|
||||
{
|
||||
|
||||
btAlignedObjectArray<GraphicsVertex>* vertices = new btAlignedObjectArray<GraphicsVertex>;
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
{
|
||||
int numVertices = utilPtr->m_vertices.size();
|
||||
int numIndices = 0;
|
||||
btAlignedObjectArray<int>* indicesPtr = new btAlignedObjectArray<int>;
|
||||
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
|
||||
for (int f=0;f<utilPtr->m_faces.size();f++)
|
||||
{
|
||||
const btFace& face = utilPtr->m_faces[f];
|
||||
btVector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (face.m_indices.size()>2)
|
||||
{
|
||||
|
||||
GraphicsVertex vtx;
|
||||
const btVector3& orgVertex = utilPtr->m_vertices[face.m_indices[0]];
|
||||
const b3Vector3& orgVertex = utilPtr->m_vertices[face.m_indices[0]];
|
||||
vtx.xyzw[0] = orgVertex[0];vtx.xyzw[1] = orgVertex[1];vtx.xyzw[2] = orgVertex[2];vtx.xyzw[3] = 0.f;
|
||||
vtx.normal[0] = normal[0];vtx.normal[1] = normal[1];vtx.normal[2] = normal[2];
|
||||
vtx.uv[0] = 0.5f;vtx.uv[1] = 0.5f;
|
||||
@@ -89,7 +89,7 @@ GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilP
|
||||
indicesPtr->push_back(newvtxindex0);
|
||||
{
|
||||
GraphicsVertex vtx;
|
||||
const btVector3& orgVertex = utilPtr->m_vertices[face.m_indices[j]];
|
||||
const b3Vector3& orgVertex = utilPtr->m_vertices[face.m_indices[j]];
|
||||
vtx.xyzw[0] = orgVertex[0];vtx.xyzw[1] = orgVertex[1];vtx.xyzw[2] = orgVertex[2];vtx.xyzw[3] = 0.f;
|
||||
vtx.normal[0] = normal[0];vtx.normal[1] = normal[1];vtx.normal[2] = normal[2];
|
||||
vtx.uv[0] = 0.5f;vtx.uv[1] = 0.5f;
|
||||
@@ -100,7 +100,7 @@ GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilP
|
||||
|
||||
{
|
||||
GraphicsVertex vtx;
|
||||
const btVector3& orgVertex = utilPtr->m_vertices[face.m_indices[j+1]];
|
||||
const b3Vector3& orgVertex = utilPtr->m_vertices[face.m_indices[j+1]];
|
||||
vtx.xyzw[0] = orgVertex[0];vtx.xyzw[1] = orgVertex[1];vtx.xyzw[2] = orgVertex[2];vtx.xyzw[3] = 0.f;
|
||||
vtx.normal[0] = normal[0];vtx.normal[1] = normal[1];vtx.normal[2] = normal[2];
|
||||
vtx.uv[0] = 0.5f;vtx.uv[1] = 0.5f;
|
||||
@@ -127,8 +127,8 @@ GraphicsShape* createGraphicsShapeFromConvexHull(const btConvexPolyhedron* utilP
|
||||
GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
{
|
||||
GraphicsShape* gfxShape = new GraphicsShape();
|
||||
btAlignedObjectArray<GraphicsVertex>* vertexArray = new btAlignedObjectArray<GraphicsVertex>;
|
||||
btAlignedObjectArray<int>* indexArray = new btAlignedObjectArray<int>;
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertexArray = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
b3AlignedObjectArray<int>* indexArray = new b3AlignedObjectArray<int>;
|
||||
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
if (compound->getChildShape(i)->isPolyhedral())
|
||||
{
|
||||
btPolyhedralConvexShape* convexHull = (btPolyhedralConvexShape*) compound->getChildShape(i);
|
||||
btTransform tr = compound->getChildTransform(i);
|
||||
b3Transform tr = compound->getChildTransform(i);
|
||||
|
||||
const btConvexPolyhedron* polyhedron = convexHull->getConvexPolyhedron();
|
||||
GraphicsShape* childGfxShape = createGraphicsShapeFromConvexHull(polyhedron);
|
||||
@@ -153,7 +153,7 @@ GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
for (int j=0;j<childGfxShape->m_numvertices;j++)
|
||||
{
|
||||
GraphicsVertex vtx;
|
||||
btVector3 pos(orgVerts[j].xyzw[0],orgVerts[j].xyzw[1],orgVerts[j].xyzw[2]);
|
||||
b3Vector3 pos(orgVerts[j].xyzw[0],orgVerts[j].xyzw[1],orgVerts[j].xyzw[2]);
|
||||
pos = tr*pos;
|
||||
vtx.xyzw[0] = childGfxShape->m_scaling[0]*pos.getX();
|
||||
vtx.xyzw[1] = childGfxShape->m_scaling[1]*pos.getY();
|
||||
@@ -163,7 +163,7 @@ GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
vtx.uv[0] = 0.5f;
|
||||
vtx.uv[1] = 0.5f;
|
||||
|
||||
btVector3 normal(orgVerts[j].normal[0],orgVerts[j].normal[1],orgVerts[j].normal[2]);
|
||||
b3Vector3 normal(orgVerts[j].normal[0],orgVerts[j].normal[1],orgVerts[j].normal[2]);
|
||||
normal = tr.getBasis()*normal;
|
||||
vtx.normal[0] = normal.getX();
|
||||
vtx.normal[1] = normal.getY();
|
||||
@@ -192,12 +192,12 @@ GraphicsShape* createGraphicsShapeFromCompoundShape(btCompoundShape* compound)
|
||||
GraphicsShape* createGraphicsShapeFromConcaveMesh(const btBvhTriangleMeshShape* trimesh)
|
||||
{
|
||||
|
||||
btAlignedObjectArray<GraphicsVertex>* vertices = new btAlignedObjectArray<GraphicsVertex>;
|
||||
btAlignedObjectArray<int>* indicesPtr = new btAlignedObjectArray<int>;
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
|
||||
|
||||
const b3StridingMeshInterface* meshInterface = trimesh->getMeshInterface();
|
||||
|
||||
btVector3 trimeshScaling(1,1,1);
|
||||
b3Vector3 trimeshScaling(1,1,1);
|
||||
for (int partId=0;partId<meshInterface->getNumSubParts();partId++)
|
||||
{
|
||||
|
||||
@@ -211,9 +211,9 @@ GraphicsShape* createGraphicsShapeFromConcaveMesh(const btBvhTriangleMeshShape*
|
||||
PHY_ScalarType indicestype = PHY_INTEGER;
|
||||
//PHY_ScalarType indexType=0;
|
||||
|
||||
btVector3 triangleVerts[3];
|
||||
b3Vector3 triangleVerts[3];
|
||||
meshInterface->getLockedReadOnlyVertexIndexBase(&vertexbase,numverts, type,stride,&indexbase,indexstride,numfaces,indicestype,partId);
|
||||
btVector3 aabbMin,aabbMax;
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
|
||||
for (int triangleIndex = 0 ; triangleIndex < numfaces;triangleIndex++)
|
||||
{
|
||||
@@ -226,7 +226,7 @@ GraphicsShape* createGraphicsShapeFromConcaveMesh(const btBvhTriangleMeshShape*
|
||||
if (type == PHY_FLOAT)
|
||||
{
|
||||
float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
|
||||
triangleVerts[j] = btVector3(
|
||||
triangleVerts[j] = b3Vector3(
|
||||
graphicsbase[0]*trimeshScaling.getX(),
|
||||
graphicsbase[1]*trimeshScaling.getY(),
|
||||
graphicsbase[2]*trimeshScaling.getZ());
|
||||
@@ -234,12 +234,12 @@ GraphicsShape* createGraphicsShapeFromConcaveMesh(const btBvhTriangleMeshShape*
|
||||
else
|
||||
{
|
||||
double* graphicsbase = (double*)(vertexbase+graphicsindex*stride);
|
||||
triangleVerts[j] = btVector3( btScalar(graphicsbase[0]*trimeshScaling.getX()),
|
||||
btScalar(graphicsbase[1]*trimeshScaling.getY()),
|
||||
btScalar(graphicsbase[2]*trimeshScaling.getZ()));
|
||||
triangleVerts[j] = b3Vector3( b3Scalar(graphicsbase[0]*trimeshScaling.getX()),
|
||||
b3Scalar(graphicsbase[1]*trimeshScaling.getY()),
|
||||
b3Scalar(graphicsbase[2]*trimeshScaling.getZ()));
|
||||
}
|
||||
}
|
||||
btVector3 normal = (triangleVerts[2]-triangleVerts[0]).cross(triangleVerts[1]-triangleVerts[0]);
|
||||
b3Vector3 normal = (triangleVerts[2]-triangleVerts[0]).cross(triangleVerts[1]-triangleVerts[0]);
|
||||
normal.normalize();
|
||||
|
||||
GraphicsVertex vtx0,vtx1,vtx2;
|
||||
@@ -299,18 +299,18 @@ GraphicsShape* createGraphicsShapeFromConcaveMesh(const btBvhTriangleMeshShape*
|
||||
|
||||
GraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
||||
{
|
||||
btAlignedObjectArray<GraphicsVertex>* vertices = new btAlignedObjectArray<GraphicsVertex>;
|
||||
b3AlignedObjectArray<GraphicsVertex>* vertices = new b3AlignedObjectArray<GraphicsVertex>;
|
||||
{
|
||||
// int numVertices = obj->vertexCount;
|
||||
// int numIndices = 0;
|
||||
btAlignedObjectArray<int>* indicesPtr = new btAlignedObjectArray<int>;
|
||||
b3AlignedObjectArray<int>* indicesPtr = new b3AlignedObjectArray<int>;
|
||||
/*
|
||||
for (int v=0;v<obj->vertexCount;v++)
|
||||
{
|
||||
vtx.xyzw[0] = obj->vertexList[v]->e[0];
|
||||
vtx.xyzw[1] = obj->vertexList[v]->e[1];
|
||||
vtx.xyzw[2] = obj->vertexList[v]->e[2];
|
||||
btVector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
||||
b3Vector3 n(vtx.xyzw[0],vtx.xyzw[1],vtx.xyzw[2]);
|
||||
if (n.length2()>SIMD_EPSILON)
|
||||
{
|
||||
n.normalize();
|
||||
@@ -332,10 +332,10 @@ GraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
||||
for (int f=0;f<obj->faceCount;f++)
|
||||
{
|
||||
obj_face* face = obj->faceList[f];
|
||||
//btVector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
//b3Vector3 normal(face.m_plane[0],face.m_plane[1],face.m_plane[2]);
|
||||
if (face->vertex_count>=3)
|
||||
{
|
||||
btVector3 normal(0,1,0);
|
||||
b3Vector3 normal(0,1,0);
|
||||
int vtxBaseIndex = vertices->size();
|
||||
|
||||
if (face->vertex_count<=4)
|
||||
@@ -366,9 +366,9 @@ GraphicsShape* createGraphicsShapeFromWavefrontObj(objLoader* obj)
|
||||
vtx2.uv[1] = obj->textureList[face->vertex_index[2]]->e[1];
|
||||
|
||||
|
||||
btVector3 v0(vtx0.xyzw[0],vtx0.xyzw[1],vtx0.xyzw[2]);
|
||||
btVector3 v1(vtx1.xyzw[0],vtx1.xyzw[1],vtx1.xyzw[2]);
|
||||
btVector3 v2(vtx2.xyzw[0],vtx2.xyzw[1],vtx2.xyzw[2]);
|
||||
b3Vector3 v0(vtx0.xyzw[0],vtx0.xyzw[1],vtx0.xyzw[2]);
|
||||
b3Vector3 v1(vtx1.xyzw[0],vtx1.xyzw[1],vtx1.xyzw[2]);
|
||||
b3Vector3 v2(vtx2.xyzw[0],vtx2.xyzw[1],vtx2.xyzw[2]);
|
||||
|
||||
normal = (v1-v0).cross(v2-v0);
|
||||
normal.normalize();
|
||||
@@ -446,13 +446,13 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
btCollisionObject* colObj = colObjArray[i];
|
||||
|
||||
btVector3 pos = colObj->getWorldTransform().getOrigin();
|
||||
btQuaternion orn = colObj->getWorldTransform().getRotation();
|
||||
b3Vector3 pos = colObj->getWorldTransform().getOrigin();
|
||||
b3Quaternion orn = colObj->getWorldTransform().getRotation();
|
||||
|
||||
float position[4] = {pos.getX(),pos.getY(),pos.getZ(),0.f};
|
||||
float orientation[4] = {orn.getX(),orn.getY(),orn.getZ(),orn.getW()};
|
||||
float color[4] = {0,0,0,1};
|
||||
btVector3 localScaling = colObj->getCollisionShape()->getLocalScaling();
|
||||
b3Vector3 localScaling = colObj->getCollisionShape()->getLocalScaling();
|
||||
|
||||
|
||||
if (colObj->isStaticOrKinematicObject())
|
||||
@@ -476,7 +476,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
|
||||
prevGraphicsShapeIndex = renderer.registerShape(&gfxShape->m_vertices[0],gfxShape->m_numvertices,gfxShape->m_indices,gfxShape->m_numIndices);
|
||||
prevShape = colObj->getCollisionShape();
|
||||
const btVector3& scaling = prevShape->getLocalScaling();
|
||||
const b3Vector3& scaling = prevShape->getLocalScaling();
|
||||
localScaling[0] = scaling.getX();localScaling[1] = scaling.getY();localScaling[2] = scaling.getZ();
|
||||
} else
|
||||
{
|
||||
@@ -486,7 +486,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
GraphicsShape* gfxShape = createGraphicsShapeFromConcaveMesh(trimesh);
|
||||
prevGraphicsShapeIndex = renderer.registerShape(&gfxShape->m_vertices[0],gfxShape->m_numvertices,gfxShape->m_indices,gfxShape->m_numIndices);
|
||||
prevShape = colObj->getCollisionShape();
|
||||
const btVector3& scaling = prevShape->getLocalScaling();
|
||||
const b3Vector3& scaling = prevShape->getLocalScaling();
|
||||
localScaling[0] = scaling.getX();localScaling[1] = scaling.getY();localScaling[2] = scaling.getZ();
|
||||
} else
|
||||
{
|
||||
@@ -498,7 +498,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
{
|
||||
prevGraphicsShapeIndex = renderer.registerShape(&gfxShape->m_vertices[0],gfxShape->m_numvertices,gfxShape->m_indices,gfxShape->m_numIndices);
|
||||
prevShape = colObj->getCollisionShape();
|
||||
const btVector3& scaling = prevShape->getLocalScaling();
|
||||
const b3Vector3& scaling = prevShape->getLocalScaling();
|
||||
localScaling[0] = scaling.getX();localScaling[1] = scaling.getY();localScaling[2] = scaling.getZ();
|
||||
} else
|
||||
{
|
||||
@@ -509,7 +509,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
if (colObj->getCollisionShape()->getShapeType()==SPHERE_SHAPE_PROXYTYPE)
|
||||
{
|
||||
btSphereShape* sphere = (btSphereShape*) colObj->getCollisionShape();
|
||||
btScalar radius = sphere->getRadius();
|
||||
b3Scalar radius = sphere->getRadius();
|
||||
|
||||
//btConvexHullShape* spherePoly = new btConvexHullShape(
|
||||
//const btConvexPolyhedron* pol = polyShape->getConvexPolyhedron();
|
||||
@@ -589,7 +589,7 @@ void graphics_from_physics(GLInstancingRenderer& renderer, bool syncTransformsOn
|
||||
}
|
||||
}
|
||||
prevShape = sphere;
|
||||
const btVector3& scaling = prevShape->getLocalScaling();
|
||||
const b3Vector3& scaling = prevShape->getLocalScaling();
|
||||
//assume uniform scaling, using X component
|
||||
float sphereScale = radius*scaling.getX();
|
||||
localScaling[0] = sphereScale;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "BulletCollision/CollisionShapes/btSphereShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||
|
||||
#include "LinearMath/btQuickprof.h"
|
||||
#include "LinearMath/b3Quickprof.h"
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
@@ -43,7 +43,7 @@ void btGpuDynamicsWorld::exitOpenCL()
|
||||
|
||||
|
||||
|
||||
int btGpuDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btScalar fixedTimeStep)
|
||||
int btGpuDynamicsWorld::stepSimulation( b3Scalar timeStep,int maxSubSteps, b3Scalar fixedTimeStep)
|
||||
{
|
||||
#ifndef BT_NO_PROFILE
|
||||
// CProfileManager::Reset();
|
||||
@@ -73,10 +73,10 @@ int btGpuDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btSc
|
||||
BT_PROFILE("scatter transforms into rigidbody (CPU)");
|
||||
for (int i=0;i<this->m_collisionObjects.size();i++)
|
||||
{
|
||||
btVector3 pos;
|
||||
btQuaternion orn;
|
||||
b3Vector3 pos;
|
||||
b3Quaternion orn;
|
||||
m_gpuPhysics->getObjectTransformFromCpu(&pos[0],&orn[0],i);
|
||||
btTransform newTrans;
|
||||
b3Transform newTrans;
|
||||
newTrans.setOrigin(pos);
|
||||
newTrans.setRotation(orn);
|
||||
this->m_collisionObjects[i]->setWorldTransform(newTrans);
|
||||
@@ -94,7 +94,7 @@ int btGpuDynamicsWorld::stepSimulation( btScalar timeStep,int maxSubSteps, btSc
|
||||
}
|
||||
|
||||
|
||||
void btGpuDynamicsWorld::setGravity(const btVector3& gravity)
|
||||
void btGpuDynamicsWorld::setGravity(const b3Vector3& gravity)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
btPolyhedralConvexShape* convex = (btPolyhedralConvexShape*)colShape;
|
||||
int numVertices=convex->getNumVertices();
|
||||
|
||||
int strideInBytes=sizeof(btVector3);
|
||||
btAlignedObjectArray<btVector3> tmpVertices;
|
||||
int strideInBytes=sizeof(b3Vector3);
|
||||
b3AlignedObjectArray<b3Vector3> tmpVertices;
|
||||
tmpVertices.resize(numVertices);
|
||||
for (int i=0;i<numVertices;i++)
|
||||
convex->getVertex(i,tmpVertices[i]);
|
||||
@@ -128,10 +128,10 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
|
||||
btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*) colShape;
|
||||
b3StridingMeshInterface* meshInterface = trimesh->getMeshInterface();
|
||||
btAlignedObjectArray<btVector3> vertices;
|
||||
btAlignedObjectArray<int> indices;
|
||||
b3AlignedObjectArray<b3Vector3> vertices;
|
||||
b3AlignedObjectArray<int> indices;
|
||||
|
||||
btVector3 trimeshScaling(1,1,1);
|
||||
b3Vector3 trimeshScaling(1,1,1);
|
||||
for (int partId=0;partId<meshInterface->getNumSubParts();partId++)
|
||||
{
|
||||
|
||||
@@ -145,9 +145,9 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
PHY_ScalarType indicestype = PHY_INTEGER;
|
||||
//PHY_ScalarType indexType=0;
|
||||
|
||||
btVector3 triangleVerts[3];
|
||||
b3Vector3 triangleVerts[3];
|
||||
meshInterface->getLockedReadOnlyVertexIndexBase(&vertexbase,numverts, type,stride,&indexbase,indexstride,numfaces,indicestype,partId);
|
||||
btVector3 aabbMin,aabbMax;
|
||||
b3Vector3 aabbMin,aabbMax;
|
||||
|
||||
for (int triangleIndex = 0 ; triangleIndex < numfaces;triangleIndex++)
|
||||
{
|
||||
@@ -160,7 +160,7 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
if (type == PHY_FLOAT)
|
||||
{
|
||||
float* graphicsbase = (float*)(vertexbase+graphicsindex*stride);
|
||||
triangleVerts[j] = btVector3(
|
||||
triangleVerts[j] = b3Vector3(
|
||||
graphicsbase[0]*trimeshScaling.getX(),
|
||||
graphicsbase[1]*trimeshScaling.getY(),
|
||||
graphicsbase[2]*trimeshScaling.getZ());
|
||||
@@ -168,9 +168,9 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
else
|
||||
{
|
||||
double* graphicsbase = (double*)(vertexbase+graphicsindex*stride);
|
||||
triangleVerts[j] = btVector3( btScalar(graphicsbase[0]*trimeshScaling.getX()),
|
||||
btScalar(graphicsbase[1]*trimeshScaling.getY()),
|
||||
btScalar(graphicsbase[2]*trimeshScaling.getZ()));
|
||||
triangleVerts[j] = b3Vector3( b3Scalar(graphicsbase[0]*trimeshScaling.getX()),
|
||||
b3Scalar(graphicsbase[1]*trimeshScaling.getY()),
|
||||
b3Scalar(graphicsbase[2]*trimeshScaling.getZ()));
|
||||
}
|
||||
}
|
||||
vertices.push_back(triangleVerts[0]);
|
||||
@@ -207,7 +207,7 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
{
|
||||
|
||||
btCompoundShape* compound = (btCompoundShape*) colShape;
|
||||
btAlignedObjectArray<btGpuChildShape> childShapes;
|
||||
b3AlignedObjectArray<btGpuChildShape> childShapes;
|
||||
|
||||
for (int i=0;i<compound->getNumChildShapes();i++)
|
||||
{
|
||||
@@ -215,8 +215,8 @@ int btGpuDynamicsWorld::findOrRegisterCollisionShape(const btCollisionShape* col
|
||||
btAssert(compound->getChildShape(i)->isPolyhedral());
|
||||
btGpuChildShape child;
|
||||
child.m_shapeIndex = findOrRegisterCollisionShape(compound->getChildShape(i));
|
||||
btVector3 pos = compound->getChildTransform(i).getOrigin();
|
||||
btQuaternion orn = compound->getChildTransform(i).getRotation();
|
||||
b3Vector3 pos = compound->getChildTransform(i).getOrigin();
|
||||
b3Quaternion orn = compound->getChildTransform(i).getRotation();
|
||||
for (int v=0;v<4;v++)
|
||||
{
|
||||
child.m_childPosition[v] = pos[v];
|
||||
@@ -283,8 +283,8 @@ void btGpuDynamicsWorld::addRigidBody(btRigidBody* body)
|
||||
{
|
||||
int gpuShapeIndex= m_uniqueShapeMapping[index];
|
||||
float mass = body->getInvMass() ? 1.f/body->getInvMass() : 0.f;
|
||||
btVector3 pos = body->getWorldTransform().getOrigin();
|
||||
btQuaternion orn = body->getWorldTransform().getRotation();
|
||||
b3Vector3 pos = body->getWorldTransform().getOrigin();
|
||||
b3Quaternion orn = body->getWorldTransform().getRotation();
|
||||
|
||||
m_gpuPhysics->registerPhysicsInstance(mass,&pos.getX(),&orn.getX(),gpuShapeIndex,m_collisionObjects.size());
|
||||
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
#ifndef BT_GPU_DYNAMICS_WORLD_H
|
||||
#define BT_GPU_DYNAMICS_WORLD_H
|
||||
|
||||
class btVector3;
|
||||
class b3Vector3;
|
||||
class btRigidBody;
|
||||
class btCollisionObject;
|
||||
struct btGpuInternalData;//use this struct to avoid 'leaking' all OpenCL headers into clients code base
|
||||
class CLPhysicsDemo;
|
||||
|
||||
#include "BulletCommon/btAlignedObjectArray.h"
|
||||
#include "BulletCommon/b3AlignedObjectArray.h"
|
||||
//#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
||||
|
||||
|
||||
class btGpuDynamicsWorld //: public btDynamicsWorld
|
||||
{
|
||||
|
||||
btAlignedObjectArray<const class btCollisionShape*> m_uniqueShapes;
|
||||
btAlignedObjectArray<int> m_uniqueShapeMapping;
|
||||
b3AlignedObjectArray<const class btCollisionShape*> m_uniqueShapes;
|
||||
b3AlignedObjectArray<int> m_uniqueShapeMapping;
|
||||
|
||||
|
||||
CLPhysicsDemo* m_gpuPhysics;
|
||||
btVector3 m_gravity;
|
||||
b3Vector3 m_gravity;
|
||||
bool m_once;
|
||||
|
||||
bool initOpenCL(int preferredDeviceIndex, int preferredPlatformIndex, bool useInterop);
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
|
||||
virtual ~btGpuDynamicsWorld();
|
||||
|
||||
virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
|
||||
virtual int stepSimulation( b3Scalar timeStep,int maxSubSteps=1, b3Scalar fixedTimeStep=b3Scalar(1.)/b3Scalar(60.));
|
||||
|
||||
virtual void synchronizeMotionStates()
|
||||
{
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
void debugDrawWorld() {}
|
||||
|
||||
void setGravity(const btVector3& gravity);
|
||||
void setGravity(const b3Vector3& gravity);
|
||||
|
||||
void addRigidBody(btRigidBody* body);
|
||||
|
||||
@@ -50,9 +50,9 @@ public:
|
||||
|
||||
|
||||
|
||||
btAlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray();
|
||||
b3AlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray();
|
||||
|
||||
const btAlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray() const;
|
||||
const b3AlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray() const;
|
||||
|
||||
virtual void addAction(btActionInterface* action)
|
||||
{
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
btVector3 getGravity () const
|
||||
b3Vector3 getGravity () const
|
||||
{
|
||||
return m_gravity;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user