Apple contribution for OSX SSE and iOS NEON optimizations unit tests, thanks to Jordan Hubbard, Ian Ollmann and Hristo Hristov.

For OSX:
cd build
./premake_osx xcode4
for iOS:
cd build
./ios_build.sh
./ios_run.sh

Also integrated the branches/StackAllocation to make it easier to multi-thread collision detection in the near future. It avoids changing the btCollisionObject while performing collision detection.

As this is a large patch, some stuff might be temporarily broken, I'll keep an eye out on issues.
This commit is contained in:
erwin.coumans
2012-06-07 00:56:30 +00:00
parent 777b92a2ad
commit 73b217fb07
323 changed files with 30730 additions and 13635 deletions

View File

@@ -57,7 +57,7 @@ SET(AllBulletDemos_SRCS
IF (WIN32)
ADD_EXECUTABLE(AppAllBulletDemos
${AllBulletDemos_SRCS}
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppAllBulletDemos

View File

@@ -27,7 +27,7 @@ ADD_EXECUTABLE(AppBasicDemo
main.cpp
BasicDemo.cpp
BasicDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBasicDemo
@@ -74,7 +74,7 @@ ELSE (USE_GLUT)
Win32BasicDemo.cpp
BasicDemo.cpp
BasicDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)

View File

@@ -1252,21 +1252,24 @@ void BenchmarkDemo::exitPhysics()
RagDoll* doll = m_ragdolls[i];
delete doll;
}
m_ragdolls.clear();
//cleanup in the reverse order of creation/initialization
//remove the rigidbodies from the dynamics world and delete them
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
if (m_dynamicsWorld)
{
//remove the rigidbodies from the dynamics world and delete them
for (i=m_dynamicsWorld->getNumCollisionObjects()-1; i>=0 ;i--)
{
btCollisionObject* obj = m_dynamicsWorld->getCollisionObjectArray()[i];
btRigidBody* body = btRigidBody::upcast(obj);
if (body && body->getMotionState())
{
delete body->getMotionState();
}
m_dynamicsWorld->removeCollisionObject( obj );
delete obj;
}
}
//delete collision shapes
for (int j=0;j<m_collisionShapes.size();j++)
@@ -1274,20 +1277,26 @@ void BenchmarkDemo::exitPhysics()
btCollisionShape* shape = m_collisionShapes[j];
delete shape;
}
m_collisionShapes.clear();
//delete dynamics world
delete m_dynamicsWorld;
m_dynamicsWorld=0;
//delete solver
delete m_solver;
m_solver=0;
//delete broadphase
delete m_overlappingPairCache;
m_overlappingPairCache=0;
//delete dispatcher
delete m_dispatcher;
m_dispatcher=0;
delete m_collisionConfiguration;
m_collisionConfiguration=0;
}

View File

@@ -27,7 +27,7 @@ IF (USE_GLUT)
main.cpp
BenchmarkDemo.cpp
BenchmarkDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBenchmarks
@@ -83,7 +83,7 @@ ELSE (USE_GLUT)
BenchmarkDemo.cpp
BenchmarkDemo.h
Win32BenchmarkDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)
ELSE (USE_GRAPHICAL_BENCHMARK)

View File

@@ -22,12 +22,12 @@ subject to the following restrictions:
#include "GlutStuff.h"
#include "GLDebugDrawer.h"
GLDebugDrawer gDebugDrawer;
#define benchmarkDemo benchmarkDemo4
#define benchmarkDemo benchmarkDemo2
#endif //USE_GRAPHICAL_BENCHMARK
#define NUM_DEMOS 7
#define NUM_TESTS 650
#define NUM_TESTS 200
extern bool gDisableDeactivation;
@@ -75,6 +75,7 @@ int main(int argc,char** argv)
}
demoArray[d]->exitPhysics();
}
for (d=0;d<NUM_DEMOS;d++)

View File

@@ -0,0 +1,22 @@
project "AppBenchmarks"
if _OPTIONS["ios"] then
kind "WindowedApp"
else
kind "ConsoleApp"
end
includedirs {"../../src"}
links {
"BulletDynamics","BulletCollision", "LinearMath"
}
language "C++"
files {
"**.cpp",
"**.h",
}

View File

@@ -25,7 +25,7 @@ IF (USE_GLUT)
main.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppBox2dDemo
@@ -63,7 +63,7 @@ ELSE (USE_GLUT)
Win32Box2dDemo.cpp
Box2dDemo.cpp
Box2dDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)

View File

@@ -23,7 +23,7 @@ IF (WIN32)
ADD_EXECUTABLE(AppCcdPhysicsDemo
main.cpp
CcdPhysicsDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCcdPhysicsDemo

View File

@@ -32,7 +32,7 @@ SET(CharacterDemo_SRCS
IF (WIN32)
ADD_EXECUTABLE(AppCharacterDemo
${CharacterDemo_SRCS}
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCharacterDemo

View File

@@ -21,7 +21,7 @@ OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY}
IF (WIN32)
ADD_EXECUTABLE(AppCollisionDemo
CollisionDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCollisionDemo

View File

@@ -167,7 +167,7 @@ void CollisionDemo::displayCallback(void) {
convexConvex.getClosestPoints(input, gjkOutput, 0);
}
btScalar m[16];
ATTRIBUTE_ALIGNED16(btScalar) m[16];
int i;
//m_ele = 21.2;
@@ -257,7 +257,7 @@ void CollisionDemo::displayCallback(void) {
if (mystate!=2 || i==myiter)
{
btScalar m[16];
ATTRIBUTE_ALIGNED16(btScalar) m[16];
input.m_transformA.getOpenGLMatrix( m );
//m_shapeDrawer->drawOpenGL(m,shapePtr[0],btVector3(108./255.,131./255.,158./255),btIDebugDraw::DBG_FastWireframe,worldBoundsMin,worldBoundsMax);

View File

@@ -24,7 +24,7 @@ IF (USE_GLUT)
CollisionInterfaceDemo.cpp
CollisionInterfaceDemo.h
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppCollisionInterfaceDemo
@@ -65,7 +65,7 @@ ELSE (USE_GLUT)
CollisionInterfaceDemo.h
Win32CollisionInterfaceDemo.cpp
../OpenGL/Win32AppMain.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)

View File

@@ -104,7 +104,7 @@ btSimplexSolverInterface& gGjkSimplexSolver = sGjkSimplexSolver;
struct btDrawingResult : public btCollisionWorld::ContactResultCallback
{
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
glBegin(GL_LINES);

View File

@@ -198,7 +198,7 @@ public:
void drawCube (const btTransform& T)
{
btScalar m[16];
ATTRIBUTE_ALIGNED16(btScalar) m[16];
T.getOpenGLMatrix (&m[0]);
glPushMatrix ();
#ifdef BT_USE_DOUBLE_PRECISION

View File

@@ -25,7 +25,7 @@ IF (USE_GLUT)
ADD_EXECUTABLE(AppConcaveDemo
ConcavePhysicsDemo.cpp
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppConcaveDemo
@@ -68,7 +68,7 @@ ELSE (USE_GLUT)
ConcavePhysicsDemo.cpp
ConcaveDemo.h
Win32ConcaveDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)

View File

@@ -75,20 +75,20 @@ inline btScalar calculateCombinedRestitution(float restitution0,float restitutio
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
float friction0 = colObj0->getFriction();
float friction1 = colObj1->getFriction();
float restitution0 = colObj0->getRestitution();
float restitution1 = colObj1->getRestitution();
float friction0 = colObj0Wrap->getCollisionObject()->getFriction();
float friction1 = colObj1Wrap->getCollisionObject()->getFriction();
float restitution0 = colObj0Wrap->getCollisionObject()->getRestitution();
float restitution1 = colObj1Wrap->getCollisionObject()->getRestitution();
if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
if (colObj0Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
friction0 = 1.0;//partId0,index0
restitution0 = 0.f;
}
if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
if (colObj1Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
if (index1&1)
{

View File

@@ -22,7 +22,7 @@ IF (WIN32)
ADD_EXECUTABLE(AppConcaveRayCastDemo
ConcaveRaycastDemo.cpp
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppConcaveRayCastDemo

View File

@@ -60,7 +60,7 @@ LINK_LIBRARIES(
ConvexDecompositionDemo.cpp
ConvexDecompositionDemo.h
Win32ConvexDecompositionDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)

View File

@@ -80,24 +80,24 @@ void ConvexDecompositionDemo::initPhysics()
///MyContactCallback is just an example to show how to get access to the child shape that collided
bool MyContactCallback (
btManifoldPoint& cp,
const btCollisionObject* colObj0,
const btCollisionObjectWrapper* colObj0Wrap,
int partId0,
int index0,
const btCollisionObject* colObj1,
const btCollisionObjectWrapper* colObj1Wrap,
int partId1,
int index1)
{
if (colObj0->getRootCollisionShape()->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
if (colObj0Wrap->getCollisionObject()->getCollisionShape()->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
{
btCompoundShape* compound = (btCompoundShape*)colObj0->getRootCollisionShape();
btCompoundShape* compound = (btCompoundShape*)colObj0Wrap->getCollisionObject()->getCollisionShape();
btCollisionShape* childShape;
childShape = compound->getChildShape(index0);
}
if (colObj1->getRootCollisionShape()->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
if (colObj1Wrap->getCollisionObject()->getCollisionShape()->getShapeType()==COMPOUND_SHAPE_PROXYTYPE)
{
btCompoundShape* compound = (btCompoundShape*)colObj1->getRootCollisionShape();
btCompoundShape* compound = (btCompoundShape*)colObj1Wrap->getCollisionObject()->getCollisionShape();
btCollisionShape* childShape;
childShape = compound->getChildShape(index1);
}

View File

@@ -36,13 +36,14 @@ class btDefaultCollisionConfiguration;
class btTriangleMesh;
///ConvexDecompositionDemo shows automatic convex decomposition of a concave mesh
class ConvexDecompositionDemo : public PlatformDemoApplication
ATTRIBUTE_ALIGNED16(class) ConvexDecompositionDemo : public PlatformDemoApplication
{
void setupEmptyDynamicsWorld();
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
//keep the collision shapes, for deletion/cleanup
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;

View File

@@ -26,7 +26,7 @@ IF (WIN32)
ADD_EXECUTABLE(AppConvexHullDistanceDemo
ConvexHullDistanceDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppConvexHullDistanceDemo
@@ -69,7 +69,7 @@ ELSE (USE_GLUT)
WIN32
../OpenGL/Win32AppMain.cpp
ConvexHullDistanceDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)

View File

@@ -276,7 +276,7 @@ void clientDisplay(void) {
//GL_ShapeDrawer::drawCoordSystem();
btScalar m[16];
ATTRIBUTE_ALIGNED16(btScalar) m[16];
int i;
#ifdef USE_GJK
btGjkEpaPenetrationDepthSolver epa;
@@ -309,7 +309,7 @@ void clientDisplay(void) {
struct MyContactResultCallback : public btCollisionWorld::ContactResultCallback
{
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
glBegin(GL_LINES);
glColor3f(1, 0, 0);

View File

@@ -132,8 +132,8 @@ void DoublePrecisionDemo::displayCallback(void)
for (i=0;i<numManifolds;i++)
{
btPersistentManifold* contactManifold = collisionWorld->getDispatcher()->getManifoldByIndexInternal(i);
btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
const btCollisionObject* obA = static_cast<const btCollisionObject*>(contactManifold->getBody0());
const btCollisionObject* obB = static_cast<const btCollisionObject*>(contactManifold->getBody1());
contactManifold->refreshContactPoints(obA->getWorldTransform(),obB->getWorldTransform());
int numContacts = contactManifold->getNumContacts();

View File

@@ -210,7 +210,8 @@ void MyConvex::Render(bool only_wireframe, const btVector3& wire_color) const
const float Scale = 1.0f;
glPushMatrix();
btScalar glmat[16]; //4x4 column major matrix for OpenGL.
ATTRIBUTE_ALIGNED16(btScalar) glmat[16]; //4x4 column major matrix for OpenGL.
mTransform.getOpenGLMatrix(glmat);
#ifndef BT_USE_DOUBLE_PRECISION
glMultMatrixf(&(glmat[0]));

View File

@@ -23,7 +23,7 @@ IF (WIN32)
ADD_EXECUTABLE(AppForkLiftDemo
ForkLiftDemo.cpp
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
IF (WIN32)

View File

@@ -31,7 +31,7 @@ ADD_EXECUTABLE(AppFractureDemo
btFractureBody.cpp
btFractureDynamicsWorld.cpp
btFractureDynamicsWorld.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppFractureDemo
@@ -82,7 +82,7 @@ ELSE (USE_GLUT)
Win32FractureDemo.cpp
FractureDemo.cpp
FractureDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)

View File

@@ -25,7 +25,7 @@ void btFractureBody::recomputeConnectivity(btCollisionWorld* world)
MyContactResultCallback() :m_connected(false)
{
}
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
if (cp.getDistance()<=0)
m_connected = true;

View File

@@ -25,7 +25,7 @@ IF (USE_GLUT)
GenericJointDemo.h
Ragdoll.cpp
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppGenericJointDemo
@@ -70,7 +70,7 @@ ELSE(USE_GLUT)
GenericJointDemo.cpp
GenericJointDemo.h
Ragdoll.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)

View File

@@ -149,7 +149,10 @@ void LinearConvexCastDemo::displayCallback(void)
convexCaster.calcTimeOfImpact( tr[ 0 ], toA, tr[ 1 ], toB, result );
btScalar m1[16], m2[16],m3[16];
ATTRIBUTE_ALIGNED16(btScalar) m1[16];
ATTRIBUTE_ALIGNED16(btScalar) m2[16];
ATTRIBUTE_ALIGNED16(btScalar) m3[16];
tr[ 0 ].getOpenGLMatrix( m1 );
tr[ 1 ].getOpenGLMatrix( m2 );

View File

@@ -31,7 +31,10 @@ public:
~btHfFluidBuoyantConvexShape ();
void generateShape (btScalar radius, btScalar gap);
btConvexShape* getConvexShape () { return m_convexShape; }
const btConvexShape* getConvexShape () const
{
return m_convexShape;
}
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
virtual void setMargin(btScalar margin);

View File

@@ -25,50 +25,50 @@ Experimental Buoyancy fluid demo written by John McCutchan
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "btHfFluid.h"
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
btHfFluidBuoyantShapeCollisionAlgorithm::btHfFluidBuoyantShapeCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
: btCollisionAlgorithm(ci), m_convexConvexAlgorithm(NULL, ci, col0, col1, simplexSolver, pdSolver,0,0)
btHfFluidBuoyantShapeCollisionAlgorithm::btHfFluidBuoyantShapeCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap,btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver)
: btCollisionAlgorithm(ci), m_convexConvexAlgorithm(NULL, ci, col0Wrap, col1Wrap, simplexSolver, pdSolver,0,0)
{
m_collisionObject0 = col0;
m_collisionObject1 = col1;
m_collisionObject0 = col0Wrap->getCollisionObject();
m_collisionObject1 = col1Wrap->getCollisionObject();
}
btHfFluidBuoyantShapeCollisionAlgorithm::~btHfFluidBuoyantShapeCollisionAlgorithm()
{
}
void btHfFluidBuoyantShapeCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
void btHfFluidBuoyantShapeCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
{
btHfFluidBuoyantConvexShape* tmpShape0 = (btHfFluidBuoyantConvexShape*)body0->getCollisionShape();
btHfFluidBuoyantConvexShape* tmpShape1 = (btHfFluidBuoyantConvexShape*)body1->getCollisionShape();
btConvexShape* convexShape0 = tmpShape0->getConvexShape();
btConvexShape* convexShape1 = tmpShape1->getConvexShape();
const btHfFluidBuoyantConvexShape* tmpShape0 = (const btHfFluidBuoyantConvexShape*)body0Wrap->getCollisionShape();
const btHfFluidBuoyantConvexShape* tmpShape1 = (const btHfFluidBuoyantConvexShape*)body1Wrap->getCollisionShape();
const btConvexShape* convexShape0 = tmpShape0->getConvexShape();
const btConvexShape* convexShape1 = tmpShape1->getConvexShape();
body0->setCollisionShape (convexShape0);
body1->setCollisionShape (convexShape1);
//body0->setCollisionShape (convexShape0);
//body1->setCollisionShape (convexShape1);
m_convexConvexAlgorithm.processCollision (body0, body1, dispatchInfo,resultOut);
btCollisionObjectWrapper ob0(body0Wrap,convexShape0,body0Wrap->getCollisionObject(),body0Wrap->getWorldTransform());
btCollisionObjectWrapper ob1(body1Wrap,convexShape1,body1Wrap->getCollisionObject(),body1Wrap->getWorldTransform());
m_convexConvexAlgorithm.processCollision (&ob0, &ob1, dispatchInfo,resultOut);
body0->setCollisionShape (tmpShape0);
body1->setCollisionShape (tmpShape1);
}
btScalar btHfFluidBuoyantShapeCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
{
btAssert(0);
btHfFluidBuoyantConvexShape* tmpShape0 = (btHfFluidBuoyantConvexShape*)body0->getCollisionShape();
btHfFluidBuoyantConvexShape* tmpShape1 = (btHfFluidBuoyantConvexShape*)body1->getCollisionShape();
btConvexShape* convexShape0 = tmpShape0->getConvexShape();
btConvexShape* convexShape1 = tmpShape1->getConvexShape();
body0->setCollisionShape (convexShape0);
body1->setCollisionShape (convexShape1);
const btConvexShape* convexShape0 = tmpShape0->getConvexShape();
const btConvexShape* convexShape1 = tmpShape1->getConvexShape();
btScalar toi = btScalar(0.0f);
toi = m_convexConvexAlgorithm.calculateTimeOfImpact (body0, body1, dispatchInfo, resultOut);
body0->setCollisionShape (tmpShape0);
body1->setCollisionShape (tmpShape1);
return toi;
}

View File

@@ -38,17 +38,17 @@ class btSimplexSolverInterface;
/// btHfFluidBuoyantShapeCollisionAlgorithm provides collision detection between btHfFluidBuoyantConvexShape and btHfFluidBuoyantConvexShape
class btHfFluidBuoyantShapeCollisionAlgorithm : public btCollisionAlgorithm
{
btCollisionObject* m_collisionObject0;
btCollisionObject* m_collisionObject1;
const btCollisionObject* m_collisionObject0;
const btCollisionObject* m_collisionObject1;
btConvexConvexAlgorithm m_convexConvexAlgorithm;
public:
btHfFluidBuoyantShapeCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
btHfFluidBuoyantShapeCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
virtual ~btHfFluidBuoyantShapeCollisionAlgorithm();
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
@@ -70,15 +70,15 @@ public:
}
virtual ~CreateFunc() {}
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
{
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btHfFluidBuoyantShapeCollisionAlgorithm));
if (!m_swapped)
{
return new(mem) btHfFluidBuoyantShapeCollisionAlgorithm(ci,body0,body1, m_simplexSolver, m_pdSolver);
return new(mem) btHfFluidBuoyantShapeCollisionAlgorithm(ci,body0Wrap,body1Wrap, m_simplexSolver, m_pdSolver);
} else
{
return new(mem) btHfFluidBuoyantShapeCollisionAlgorithm(ci,body0,body1, m_simplexSolver, m_pdSolver);
return new(mem) btHfFluidBuoyantShapeCollisionAlgorithm(ci,body0Wrap,body1Wrap, m_simplexSolver, m_pdSolver);
}
}
};

View File

@@ -25,54 +25,69 @@ Experimental Buoyancy fluid demo written by John McCutchan
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "btHfFluid.h"
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
btHfFluidRigidCollisionAlgorithm::~btHfFluidRigidCollisionAlgorithm()
{
}
btHfFluidRigidCollisionAlgorithm::btHfFluidRigidCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped)
btHfFluidRigidCollisionAlgorithm::btHfFluidRigidCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap, bool isSwapped)
: btCollisionAlgorithm(ci), m_isSwapped(isSwapped),
m_convexTrianglecallback(ci.m_dispatcher1, col0, col1, !isSwapped) // we flip the isSwapped because we are hf fluid vs. convex and callback expects convex vs. concave
m_convexTrianglecallback(ci.m_dispatcher1, col0Wrap, col1Wrap, !isSwapped) // we flip the isSwapped because we are hf fluid vs. convex and callback expects convex vs. concave
{
m_manifoldPtr = m_convexTrianglecallback.m_manifoldPtr;
if (m_isSwapped)
{
m_hfFluid = static_cast<btHfFluid*>(col1);
m_rigidCollisionObject = static_cast<btCollisionObject*>(col0);
m_hfFluid = static_cast<const btHfFluid*>(col1Wrap->getCollisionObject());
m_rigidCollisionObject = static_cast<const btCollisionObject*>(col0Wrap->getCollisionObject());
m_manifoldPtr->setBodies(m_hfFluid,m_rigidCollisionObject);
} else {
m_hfFluid = static_cast<btHfFluid*>(col0);
m_rigidCollisionObject = static_cast<btCollisionObject*>(col1);
m_hfFluid = static_cast<const btHfFluid*>(col0Wrap->getCollisionObject());
m_rigidCollisionObject = static_cast<const btCollisionObject*>(col1Wrap->getCollisionObject());
m_manifoldPtr->setBodies(m_rigidCollisionObject,m_hfFluid);
}
}
void btHfFluidRigidCollisionAlgorithm::processGround (const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
{
btAssert(0);
//needs fixing after btCollisionObjectWrapper introduction
#if 0
btScalar triangleMargin = m_rigidCollisionObject->getCollisionShape()->getMargin();
resultOut->setPersistentManifold(m_manifoldPtr);
// to perform the convex shape vs. ground terrain:
// we pull the convex shape out of the buoyant shape and replace it temporarily
btHfFluidBuoyantConvexShape* tmpShape = (btHfFluidBuoyantConvexShape*)m_rigidCollisionObject->getCollisionShape();
btConvexShape* convexShape = ((btHfFluidBuoyantConvexShape*)tmpShape)->getConvexShape();
m_rigidCollisionObject->setCollisionShape (convexShape);
const btConvexShape* convexShape = ((const btHfFluidBuoyantConvexShape*)tmpShape)->getConvexShape();
//m_rigidCollisionObject->setCollisionShape (convexShape);
m_convexTrianglecallback.setTimeStepAndCounters (triangleMargin, dispatchInfo, resultOut);
m_hfFluid->foreachGroundTriangle (&m_convexTrianglecallback, m_convexTrianglecallback.getAabbMin(),m_convexTrianglecallback.getAabbMax());
resultOut->refreshContactPoints();
#endif
// restore the buoyant shape
m_rigidCollisionObject->setCollisionShape (tmpShape);
//m_rigidCollisionObject->setCollisionShape (tmpShape);
}
btScalar btHfFluidRigidCollisionAlgorithm::processFluid (const btDispatcherInfo& dispatchInfo, btScalar density, btScalar floatyness)
{
btAssert(0);
//needs fixing after btCollisionObjectWrapper introduction
#if 0
btRigidBody* rb = btRigidBody::upcast(m_rigidCollisionObject);
btHfFluidColumnRigidBodyCallback columnCallback (rb, dispatchInfo.m_debugDraw, density, floatyness);
m_hfFluid->foreachFluidColumn (&columnCallback, m_convexTrianglecallback.getAabbMin(), m_convexTrianglecallback.getAabbMax());
return columnCallback.getVolume ();
#endif
return 0.f;
}
void btHfFluidRigidCollisionAlgorithm::applyFluidFriction (btScalar mu, btScalar submerged_percentage)
{
btAssert(0);
//needs fixing after btCollisionObjectWrapper introduction
#if 0
btRigidBody* rb = btRigidBody::upcast(m_rigidCollisionObject);
btScalar dt = btScalar(1.0f/60.0f);
@@ -103,10 +118,15 @@ void btHfFluidRigidCollisionAlgorithm::applyFluidFriction (btScalar mu, btScalar
rb->applyCentralImpulse (dt * scaled_mu * -rb->getLinearVelocity());
rb->applyTorqueImpulse (dt * scaled_mu * -rb->getAngularVelocity());
#endif
#endif
}
void btHfFluidRigidCollisionAlgorithm::processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
void btHfFluidRigidCollisionAlgorithm::processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
{
btAssert(0);
//needs fixing after btCollisionObjectWrapper introduction
#if 0
processGround (dispatchInfo, resultOut);
btHfFluidBuoyantConvexShape* buoyantShape = (btHfFluidBuoyantConvexShape*)m_rigidCollisionObject->getCollisionShape();
btRigidBody* rb = btRigidBody::upcast(m_rigidCollisionObject);
@@ -125,6 +145,8 @@ void btHfFluidRigidCollisionAlgorithm::processCollision (btCollisionObject* body
applyFluidFriction (mu, submerged_percentage);
}
}
#endif
}
btScalar btHfFluidRigidCollisionAlgorithm::calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)

View File

@@ -35,8 +35,8 @@ class btHfFluidRigidCollisionAlgorithm : public btCollisionAlgorithm
{
btPersistentManifold* m_manifoldPtr;
btHfFluid* m_hfFluid;
btCollisionObject* m_rigidCollisionObject;
const btHfFluid* m_hfFluid;
const btCollisionObject* m_rigidCollisionObject;
///for rigid versus fluid (instead of fluid versus rigid), we use this swapped boolean
bool m_isSwapped;
@@ -48,11 +48,11 @@ class btHfFluidRigidCollisionAlgorithm : public btCollisionAlgorithm
btScalar processFluid (const btDispatcherInfo& dispatchInfo, btScalar density, btScalar floatyness);
public:
btHfFluidRigidCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* col0,btCollisionObject* col1, bool isSwapped);
btHfFluidRigidCollisionAlgorithm(const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* col0Wrap,const btCollisionObjectWrapper* col1Wrap, bool isSwapped);
virtual ~btHfFluidRigidCollisionAlgorithm();
virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
@@ -64,15 +64,15 @@ public:
struct CreateFunc :public btCollisionAlgorithmCreateFunc
{
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
{
void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btHfFluidRigidCollisionAlgorithm));
if (!m_swapped)
{
return new(mem) btHfFluidRigidCollisionAlgorithm(ci,body0,body1,false);
return new(mem) btHfFluidRigidCollisionAlgorithm(ci,body0Wrap,body1Wrap,false);
} else
{
return new(mem) btHfFluidRigidCollisionAlgorithm(ci,body0,body1,true);
return new(mem) btHfFluidRigidCollisionAlgorithm(ci,body0Wrap,body1Wrap,true);
}
}
};

View File

@@ -190,7 +190,7 @@ void btHfFluidRigidDynamicsWorld::drawHfFluidBuoyantConvexShape (btIDebugDraw* d
}
};
btConvexShape* convexShape = ((btHfFluidBuoyantConvexShape*)object->getCollisionShape())->getConvexShape();
const btConvexShape* convexShape = ((const btHfFluidBuoyantConvexShape*)object->getCollisionShape())->getConvexShape();
debugDrawObject(object->getWorldTransform(),(btCollisionShape*)convexShape,color);
}
}

View File

@@ -162,7 +162,7 @@ void HfFluidDemo_GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape*
if (shape->getShapeType() == HFFLUID_BUOYANT_CONVEX_SHAPE_PROXYTYPE)
{
btConvexShape* convexShape = ((btHfFluidBuoyantConvexShape*)shape)->getConvexShape();
const btConvexShape* convexShape = ((btHfFluidBuoyantConvexShape*)shape)->getConvexShape();
btTransform I;
I.setIdentity();
btScalar mat[16];

View File

@@ -11,7 +11,7 @@ LINK_LIBRARIES(
IF (WIN32)
ADD_EXECUTABLE(AppHelloWorld
HelloWorld.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppHelloWorld
@@ -22,8 +22,8 @@ ENDIF()
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppHelloWorld PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppHelloWorld PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppHelloWorld PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppHelloWorld PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(AppHelloWorld PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(AppHelloWorld PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)

View File

@@ -0,0 +1,22 @@
project "AppHelloWorld"
if _OPTIONS["ios"] then
kind "WindowedApp"
else
kind "ConsoleApp"
end
includedirs {"../../src"}
links {
"BulletDynamics","BulletCollision", "LinearMath"
}
language "C++"
files {
"**.cpp",
"**.h",
}

View File

@@ -73,27 +73,27 @@ inline btScalar calculateCombinedRestitution(float restitution0,float restitutio
///////////////////////////////////////////////////////////////
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
if (enable)
{
btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1);
btAdjustInternalEdgeContacts(cp,colObj1Wrap,colObj0Wrap, partId1,index1);
//btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1, BT_TRIANGLE_CONVEX_BACKFACE_MODE);
//btAdjustInternalEdgeContacts(cp,colObj1,colObj0, partId1,index1, BT_TRIANGLE_CONVEX_DOUBLE_SIDED+BT_TRIANGLE_CONCAVE_DOUBLE_SIDED);
}
float friction0 = colObj0->getFriction();
float friction1 = colObj1->getFriction();
float restitution0 = colObj0->getRestitution();
float restitution1 = colObj1->getRestitution();
float friction0 = colObj0Wrap->getCollisionObject()->getFriction();
float friction1 = colObj1Wrap->getCollisionObject()->getFriction();
float restitution0 = colObj0Wrap->getCollisionObject()->getRestitution();
float restitution1 = colObj1Wrap->getCollisionObject()->getRestitution();
if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
if (colObj0Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
friction0 = 1.0;//partId0,index0
restitution0 = 0.f;
}
if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
if (colObj1Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
if (index1&1)
{

View File

@@ -1,29 +1,48 @@
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppMovingConcaveDemo
ConcavePhysicsDemo.cpp
)
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
# For every executable you have with a main method you should have an add_executable line below.
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
# This is the variable for Windows. I use this to define the root of my directory structure.
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
# You shouldn't have to modify anything below this line
########################################################
INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
ADD_EXECUTABLE(AppMovingConcaveDemo
ConcavePhysicsDemo.cpp
)
IF (WIN32)
IF (NOT INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
IF (CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppMovingConcaveDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
)
ELSE(CMAKE_CL_64)
ADD_CUSTOM_COMMAND(
TARGET AppMovingConcaveDemo
POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
)
ENDIF(CMAKE_CL_64)
ENDIF (NOT INTERNAL_CREATE_MSVC_RELATIVE_PATH_PROJECTFILES)
ENDIF(WIN32)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(AppMovingConcaveDemo PROPERTIES DEBUG_POSTFIX "_Debug")

View File

@@ -16,6 +16,7 @@ subject to the following restrictions:
#include "btBulletDynamicsCommon.h"
#include "ConcaveDemo.h"
#include "LinearMath/btDefaultMotionState.h"
#include "LinearMath/btIDebugDraw.h"
#include "LinearMath/btQuickprof.h"
@@ -32,7 +33,7 @@ subject to the following restrictions:
#include "GlutStuff.h"
GLDebugDrawer debugDrawer;
GLDebugDrawer debugDrawer1;
//***************************THE FAMOUS BUNNY TRIMESH********************************************//
@@ -1431,20 +1432,20 @@ inline btScalar calculateCombinedRestitution(float restitution0,float restitutio
bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
float friction0 = colObj0->getFriction();
float friction1 = colObj1->getFriction();
float restitution0 = colObj0->getRestitution();
float restitution1 = colObj1->getRestitution();
float friction0 = colObj0Wrap->getCollisionObject()->getFriction();
float friction1 = colObj1Wrap->getCollisionObject()->getFriction();
float restitution0 = colObj0Wrap->getCollisionObject()->getRestitution();
float restitution1 = colObj1Wrap->getCollisionObject()->getRestitution();
if (colObj0->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
if (colObj0Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
friction0 = 1.0;//partId0,index0
restitution0 = 0.f;
}
if (colObj1->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
if (colObj1Wrap->getCollisionObject()->getCollisionFlags() & btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK)
{
if (index1&1)
{

View File

@@ -24,6 +24,7 @@ subject to the following restrictions:
#include "BulletCollision/CollisionShapes/btTriangleIndexVertexMaterialArray.h"
#include "BulletCollision/CollisionShapes/btMultimaterialTriangleMeshShape.h"
#include "BulletCollision/CollisionShapes/btMaterial.h"
#include "BulletCollision/CollisionDispatch/btCollisionObjectWrapper.h"
// Create a custom material, just because we can
class CustomMaterial : public btMaterial
@@ -72,30 +73,30 @@ inline btScalar calculateCombinedRestitution(float restitution0,float restitutio
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1)
static bool CustomMaterialCombinerCallback(btManifoldPoint& cp, const btCollisionObjectWrapper* colObj0Wrap,int partId0,int index0,const btCollisionObjectWrapper* colObj1Wrap,int partId1,int index1)
{
// Apply material properties
if (colObj0->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE)
if (colObj0Wrap->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE)
{
const btCollisionShape* parent0 = colObj0->getRootCollisionShape();
const btCollisionShape* parent0 = colObj0Wrap->getCollisionObject()->getCollisionShape();
if(parent0 != 0 && parent0->getShapeType() == MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE)
{
btMultimaterialTriangleMeshShape* shape = (btMultimaterialTriangleMeshShape*)parent0;
const btMaterial * props = shape->getMaterialProperties(partId0, index0);
cp.m_combinedFriction = calculateCombinedFriction(props->m_friction, colObj1->getFriction());
cp.m_combinedRestitution = props->m_restitution * colObj1->getRestitution();
cp.m_combinedFriction = calculateCombinedFriction(props->m_friction, colObj1Wrap->getCollisionObject()->getFriction());
cp.m_combinedRestitution = props->m_restitution * colObj1Wrap->getCollisionObject()->getRestitution();
}
}
else if (colObj1->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE)
else if (colObj1Wrap->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE)
{
const btCollisionShape* parent1 = colObj1->getRootCollisionShape();
const btCollisionShape* parent1 = colObj1Wrap->getCollisionObject()->getCollisionShape();
if(parent1 != 0 && parent1->getShapeType() == MULTIMATERIAL_TRIANGLE_MESH_PROXYTYPE)
{
btMultimaterialTriangleMeshShape* shape = (btMultimaterialTriangleMeshShape*)parent1;
const btMaterial * props = shape->getMaterialProperties(partId1, index1);
cp.m_combinedFriction = calculateCombinedFriction(props->m_friction, colObj0->getFriction());
cp.m_combinedRestitution = props->m_restitution * colObj0->getRestitution();
cp.m_combinedFriction = calculateCombinedFriction(props->m_friction, colObj0Wrap->getCollisionObject()->getFriction());
cp.m_combinedRestitution = props->m_restitution * colObj0Wrap->getCollisionObject()->getRestitution();
}
}

View File

@@ -75,7 +75,7 @@ struct btDebugCastResult : public btConvexCast::CastResult
btVector3 worldBoundsMax(1000,1000,1000);
btScalar m[16];
ATTRIBUTE_ALIGNED16(btScalar) m[16];
btTransform hitTrans;
btTransformUtil::integrateTransform(m_fromTrans,m_linVel,m_angVel,fraction,hitTrans);
hitTrans.getOpenGLMatrix(m);

View File

@@ -755,7 +755,7 @@ void DemoApplication::mouseFunc(int button, int state, int x, int y)
{
btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
btRigidBody* body = (btRigidBody*)btRigidBody::upcast(rayCallback.m_collisionObject);
if (body)
{
//other exclusions?

View File

@@ -460,7 +460,7 @@ bool GL_DialogDynamicsWorld::mouseFunc(int button, int state, int x, int y)
btScalar maxPickingClamp = mousePickClamping;
btRigidBody* body = btRigidBody::upcast(rayCallback.m_collisionObject);
btRigidBody* body = (btRigidBody*)btRigidBody::upcast(rayCallback.m_collisionObject);
if (body)
{
bool doPick = true;

View File

@@ -719,7 +719,7 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
{
btSphereShape sc(multiSphereShape->getSphereRadius(i));
childTransform.setOrigin(multiSphereShape->getSpherePosition(i));
btScalar childMat[16];
ATTRIBUTE_ALIGNED16(btScalar) childMat[16];
childTransform.getOpenGLMatrix(childMat);
drawOpenGL(childMat,&sc,color,debugMode,worldBoundsMin,worldBoundsMax);
}

View File

@@ -19,10 +19,12 @@ subject to the following restrictions:
#include "DemoApplication.h"
class GlutDemoApplication : public DemoApplication
ATTRIBUTE_ALIGNED16(class) GlutDemoApplication : public DemoApplication
{
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
void specialKeyboard(int key, int x, int y);
virtual void swapBuffers();

View File

@@ -20,13 +20,14 @@ subject to the following restrictions:
#include "DemoApplication.h"
class Win32DemoApplication : public DemoApplication
ATTRIBUTE_ALIGNED16(class) Win32DemoApplication : public DemoApplication
{
protected:
public:
BT_DECLARE_ALIGNED_ALLOCATOR();
virtual void swapBuffers();

View File

@@ -48,7 +48,7 @@ IF (USE_GLUT)
../main.cpp
../SerializeDemo.cpp
../SerializeDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOpenCLUtils.cpp
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOpenCLUtils.h
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOpenCLInclude.h
@@ -109,7 +109,7 @@ ELSE (USE_GLUT)
../Win32SerializeDemo.cpp
../SerializeDemo.cpp
../SerializeDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOpenCLUtils.cpp
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOpenCLUtils.h
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOpenCLInclude.h

View File

@@ -34,7 +34,7 @@ IF (USE_GLUT)
main.cpp
SerializeDemo.cpp
SerializeDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppSerializeDemo
@@ -73,7 +73,7 @@ ELSE (USE_GLUT)
Win32SerializeDemo.cpp
SerializeDemo.cpp
SerializeDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ENDIF (USE_GLUT)

View File

@@ -24,7 +24,7 @@ IF (USE_GLUT)
ADD_EXECUTABLE(AppSoftBodyDemo
main.cpp
SoftDemo.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppSoftBodyDemo

View File

@@ -52,7 +52,7 @@ static btRigidBody* staticBody = 0;
static float waveheight = 5.f;
const float TRIANGLE_SIZE=8.f;
unsigned int current_demo=7;
unsigned int current_demo=20;
#define DEMO_MODE_TIMEOUT 15.f //15 seconds for each demo

View File

@@ -26,7 +26,7 @@ BulletMultiThreaded BulletDynamics BulletCollision LinearMath
IF (WIN32)
ADD_EXECUTABLE(AppThreadingDemo
main.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppThreadingDemo

View File

@@ -59,7 +59,12 @@ btThreadSupportInterface* createThreadSupport(int numThreads)
struct SampleArgs
{
SampleArgs()
:m_fakeWork(1)
{
}
btCriticalSection* m_cs;
float m_fakeWork;
};
struct SampleThreadLocalStorage
@@ -86,6 +91,9 @@ void SampleThreadFunc(void* userPtr,void* lsMemory)
{
printf("thread %d processed number %d\n",localStorage->threadId, count);
}
//do some fake work
for (int i=0;i<1000000;i++)
args->m_fakeWork = 1.21*args->m_fakeWork;
workLeft = count>0;
}
printf("finished\n");
@@ -110,7 +118,7 @@ void* SamplelsMemoryFunc()
int main(int argc,char** argv)
{
int numThreads = 4;
int numThreads = 8;
btThreadSupportInterface* threadSupport = createThreadSupport(numThreads);

View File

@@ -22,7 +22,7 @@ LINK_LIBRARIES(
IF (WIN32)
ADD_EXECUTABLE(AppUserCollisionAlgorithm
UserCollisionAlgorithm.cpp
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppUserCollisionAlgorithm

View File

@@ -27,7 +27,7 @@ ADD_EXECUTABLE(AppVoronoiFractureDemo
main.cpp
VoronoiFractureDemo.cpp
VoronoiFractureDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)
ELSE()
ADD_EXECUTABLE(AppVoronoiFractureDemo
@@ -74,7 +74,7 @@ ELSE (USE_GLUT)
Win32VoronoiFractureDemo.cpp
VoronoiFractureDemo.cpp
VoronoiFractureDemo.h
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
${BULLET_PHYSICS_SOURCE_DIR}/build/bullet.rc
)

View File

@@ -16,7 +16,7 @@ function createDemos( demos, incdirs, linknames)
links { "opengl32" }
includedirs{ "../Glut" }
libdirs {"../Glut"}
files { "../msvc/bullet.rc" }
files { "../build/bullet.rc" }
configuration {"Windows", "x32"}
links {"glew32s","glut32"}
@@ -65,7 +65,6 @@ end
"GenericJointDemo",
"GimpactTestDemo",
"GjkConvexCastDemo",
"HelloWorld",
"InternalEdgeDemo",
"MovingConcaveDemo",
"MultiMaterialDemo",