added some comments, to clarify unit-test/brute force implementations.
This commit is contained in:
@@ -199,7 +199,7 @@ void BasicDemo::initPhysics()
|
|||||||
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
|
localCreateRigidBody(btScalar(0.),groundTransform,groundShape);
|
||||||
|
|
||||||
//create a few dynamic sphere rigidbodies (re-using the same sphere shape)
|
//create a few dynamic sphere rigidbodies (re-using the same sphere shape)
|
||||||
//btCollisionShape* sphereShape = new btBoxShape(btVector3(1,1,1));
|
//btCollisionShape* colShape = new btBoxShape(btVector3(1,1,1));
|
||||||
btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||||
m_collisionShapes.push_back(colShape);
|
m_collisionShapes.push_back(colShape);
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ void ConvexDecompositionDemo::initPhysics(const char* filename)
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (0)//tcount)
|
if (tcount)
|
||||||
{
|
{
|
||||||
btTriangleMesh* trimesh = new btTriangleMesh();
|
btTriangleMesh* trimesh = new btTriangleMesh();
|
||||||
|
|
||||||
|
|||||||
@@ -333,14 +333,17 @@ void RagdollDemo::initPhysics()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spawn one ragdoll
|
// Spawn one ragdoll
|
||||||
spawnRagdoll();
|
btVector3 startOffset(1,0.5,0);
|
||||||
|
spawnRagdoll(startOffset);
|
||||||
|
startOffset.setValue(-1,0.5,0);
|
||||||
|
spawnRagdoll(startOffset);
|
||||||
|
|
||||||
clientResetScene();
|
clientResetScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RagdollDemo::spawnRagdoll(bool random)
|
void RagdollDemo::spawnRagdoll(const btVector3& startOffset)
|
||||||
{
|
{
|
||||||
RagDoll* ragDoll = new RagDoll (m_dynamicsWorld, btVector3 (0,1,0));
|
RagDoll* ragDoll = new RagDoll (m_dynamicsWorld, startOffset);
|
||||||
m_ragdolls.push_back(ragDoll);
|
m_ragdolls.push_back(ragDoll);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,8 +386,11 @@ void RagdollDemo::keyboardCallback(unsigned char key, int x, int y)
|
|||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case 'e':
|
case 'e':
|
||||||
spawnRagdoll(true);
|
{
|
||||||
|
btVector3 startOffset(0,2,0);
|
||||||
|
spawnRagdoll(startOffset);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
DemoApplication::keyboardCallback(key, x, y);
|
DemoApplication::keyboardCallback(key, x, y);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,39 +1,39 @@
|
|||||||
/*
|
/*
|
||||||
Bullet Continuous Collision Detection and Physics Library
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
RagdollDemo
|
RagdollDemo
|
||||||
Copyright (c) 2007 Starbreeze Studios
|
Copyright (c) 2007 Starbreeze Studios
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty.
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
In no event will the authors be held liable for any damages arising from the use of this software.
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute it freely,
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
subject to the following restrictions:
|
subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
||||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
3. This notice may not be removed or altered from any source distribution.
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
Written by: Marten Svanfeldt
|
Written by: Marten Svanfeldt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RAGDOLLDEMO_H
|
#ifndef RAGDOLLDEMO_H
|
||||||
#define RAGDOLLDEMO_H
|
#define RAGDOLLDEMO_H
|
||||||
|
|
||||||
#include "DemoApplication.h"
|
#include "DemoApplication.h"
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
class btBroadphaseInterface;
|
class btBroadphaseInterface;
|
||||||
class btCollisionShape;
|
class btCollisionShape;
|
||||||
class btOverlappingPairCache;
|
class btOverlappingPairCache;
|
||||||
class btCollisionDispatcher;
|
class btCollisionDispatcher;
|
||||||
class btConstraintSolver;
|
class btConstraintSolver;
|
||||||
struct btCollisionAlgorithmCreateFunc;
|
struct btCollisionAlgorithmCreateFunc;
|
||||||
class btDefaultCollisionConfiguration;
|
class btDefaultCollisionConfiguration;
|
||||||
|
|
||||||
class RagdollDemo : public DemoApplication
|
class RagdollDemo : public DemoApplication
|
||||||
{
|
{
|
||||||
|
|
||||||
btAlignedObjectArray<class RagDoll*> m_ragdolls;
|
btAlignedObjectArray<class RagDoll*> m_ragdolls;
|
||||||
|
|
||||||
//keep the collision shapes, for deletion/cleanup
|
//keep the collision shapes, for deletion/cleanup
|
||||||
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
|
||||||
|
|
||||||
@@ -43,35 +43,35 @@ class RagdollDemo : public DemoApplication
|
|||||||
|
|
||||||
btConstraintSolver* m_solver;
|
btConstraintSolver* m_solver;
|
||||||
|
|
||||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initPhysics();
|
void initPhysics();
|
||||||
|
|
||||||
void exitPhysics();
|
void exitPhysics();
|
||||||
|
|
||||||
virtual ~RagdollDemo()
|
virtual ~RagdollDemo()
|
||||||
{
|
{
|
||||||
exitPhysics();
|
exitPhysics();
|
||||||
}
|
}
|
||||||
|
|
||||||
void spawnRagdoll(bool random = false);
|
void spawnRagdoll(const btVector3& startOffset);
|
||||||
|
|
||||||
virtual void clientMoveAndDisplay();
|
virtual void clientMoveAndDisplay();
|
||||||
|
|
||||||
virtual void displayCallback();
|
virtual void displayCallback();
|
||||||
|
|
||||||
virtual void keyboardCallback(unsigned char key, int x, int y);
|
virtual void keyboardCallback(unsigned char key, int x, int y);
|
||||||
|
|
||||||
static DemoApplication* Create()
|
static DemoApplication* Create()
|
||||||
{
|
{
|
||||||
RagdollDemo* demo = new RagdollDemo();
|
RagdollDemo* demo = new RagdollDemo();
|
||||||
demo->myinit();
|
demo->myinit();
|
||||||
demo->initPhysics();
|
demo->initPhysics();
|
||||||
return demo;
|
return demo;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ struct btSimpleBroadphaseProxy : public btBroadphaseProxy
|
|||||||
};
|
};
|
||||||
|
|
||||||
///SimpleBroadphase is a brute force aabb culling broadphase based on O(n^2) aabb checks
|
///SimpleBroadphase is a brute force aabb culling broadphase based on O(n^2) aabb checks
|
||||||
|
///btSimpleBroadphase is just a unit-test implementation to verify and test other broadphases.
|
||||||
|
///So please don't use this class, but use bt32BitAxisSweep3 or btAxisSweep3 instead!
|
||||||
class btSimpleBroadphase : public btBroadphaseInterface
|
class btSimpleBroadphase : public btBroadphaseInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -597,7 +597,6 @@ void btOptimizedBvh::reportAabbOverlappingNodex(btNodeOverlapCallback* nodeCallb
|
|||||||
{
|
{
|
||||||
//either choose recursive traversal (walkTree) or stackless (walkStacklessTree)
|
//either choose recursive traversal (walkTree) or stackless (walkStacklessTree)
|
||||||
|
|
||||||
|
|
||||||
if (m_useQuantization)
|
if (m_useQuantization)
|
||||||
{
|
{
|
||||||
///quantize query AABB
|
///quantize query AABB
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ const btVector3& btTriangleMeshShape::getLocalScaling() const
|
|||||||
//#define DEBUG_TRIANGLE_MESH
|
//#define DEBUG_TRIANGLE_MESH
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
void btTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
void btTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const
|
||||||
{
|
{
|
||||||
struct FilteredCallback : public btInternalTriangleIndexCallback
|
struct FilteredCallback : public btInternalTriangleIndexCallback
|
||||||
@@ -171,8 +171,6 @@ void btTriangleMeshShape::processAllTriangles(btTriangleCallback* callback,const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ protected:
|
|||||||
btVector3 m_localAabbMin;
|
btVector3 m_localAabbMin;
|
||||||
btVector3 m_localAabbMax;
|
btVector3 m_localAabbMax;
|
||||||
btStridingMeshInterface* m_meshInterface;
|
btStridingMeshInterface* m_meshInterface;
|
||||||
|
|
||||||
|
///btTriangleMeshShape constructor has been disabled/protected, so that users will not mistakenly use this class.
|
||||||
|
///Don't use btTriangleMeshShape but use btBvhTriangleMeshShape instead!
|
||||||
|
btTriangleMeshShape(btStridingMeshInterface* meshInterface);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
btTriangleMeshShape(btStridingMeshInterface* meshInterface);
|
|
||||||
|
|
||||||
virtual ~btTriangleMeshShape();
|
virtual ~btTriangleMeshShape();
|
||||||
|
|
||||||
@@ -51,12 +53,7 @@ public:
|
|||||||
|
|
||||||
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
|
||||||
|
|
||||||
//this is a brute force processAllTriangles implementation to compare/unit test the btBvhTriangleMeshShape.
|
|
||||||
//it has been disabled, so that users will not mistakenly use this class.
|
|
||||||
//Don't use btTriangleMeshShape but use btBvhTriangleMeshShape instead!
|
|
||||||
/*
|
|
||||||
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
|
||||||
*/
|
|
||||||
|
|
||||||
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
|
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
///btContinuousDynamicsWorld adds optional (per object) continuous collision detection for fast moving objects to the btDiscreteDynamicsWorld.
|
///btContinuousDynamicsWorld adds optional (per object) continuous collision detection for fast moving objects to the btDiscreteDynamicsWorld.
|
||||||
///This copes with fast moving objects that otherwise would tunnel/miss collisions.
|
///This copes with fast moving objects that otherwise would tunnel/miss collisions.
|
||||||
///Under construction, don't use yet!
|
///Under construction, don't use yet! Please use btDiscreteDynamicsWorld instead.
|
||||||
class btContinuousDynamicsWorld : public btDiscreteDynamicsWorld
|
class btContinuousDynamicsWorld : public btDiscreteDynamicsWorld
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,8 @@ class btDispatcher;
|
|||||||
class btOverlappingPairCache;
|
class btOverlappingPairCache;
|
||||||
class btConstraintSolver;
|
class btConstraintSolver;
|
||||||
|
|
||||||
///btSimpleDynamicsWorld demonstrates very basic usage of Bullet rigid body dynamics
|
///btSimpleDynamicsWorld serves as unit-test and to verify more complicated and optimized dynamics worlds.
|
||||||
///It can be used for basic simulations, and as a starting point for porting Bullet
|
///Please use btDiscreteDynamicsWorld instead (or btContinuousDynamicsWorld once it is finished).
|
||||||
///btSimpleDynamicsWorld lacks object deactivation, island management and other concepts.
|
|
||||||
///For more complicated simulations, btDiscreteDynamicsWorld and btContinuousDynamicsWorld are recommended
|
|
||||||
///those classes replace the obsolete CcdPhysicsEnvironment/CcdPhysicsController
|
|
||||||
class btSimpleDynamicsWorld : public btDynamicsWorld
|
class btSimpleDynamicsWorld : public btDynamicsWorld
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
Reference in New Issue
Block a user