2013-05-01 01:17:44 +00:00
|
|
|
#ifndef B3_GPU_DYNAMICS_WORLD_H
|
|
|
|
#define B3_GPU_DYNAMICS_WORLD_H
|
|
|
|
|
|
|
|
#include "LinearMath/btVector3.h"
|
|
|
|
|
|
|
|
class btRigidBody;
|
|
|
|
class btCollisionObject;
|
|
|
|
struct b3GpuInternalData;//use this struct to avoid 'leaking' all OpenCL headers into clients code base
|
|
|
|
class CLPhysicsDemo;
|
|
|
|
class btActionInterface;
|
2013-06-17 20:47:35 +00:00
|
|
|
class btTypedConstraint;
|
2013-05-01 01:17:44 +00:00
|
|
|
|
|
|
|
#include "LinearMath/btAlignedObjectArray.h"
|
|
|
|
#include "BulletDynamics/Dynamics/btDynamicsWorld.h"
|
|
|
|
|
|
|
|
|
|
|
|
class b3GpuDynamicsWorld : public btDynamicsWorld
|
|
|
|
{
|
|
|
|
|
|
|
|
btAlignedObjectArray<const class btCollisionShape*> m_uniqueShapes;
|
|
|
|
btAlignedObjectArray<int> m_uniqueShapeMapping;
|
2013-06-17 20:47:35 +00:00
|
|
|
btAlignedObjectArray<btTypedConstraint*> m_constraints;
|
2013-05-01 01:17:44 +00:00
|
|
|
|
|
|
|
class b3GpuRigidBodyPipeline* m_rigidBodyPipeline;
|
|
|
|
class b3GpuNarrowPhase* m_np;
|
|
|
|
class b3GpuSapBroadphase* m_bp;
|
|
|
|
|
|
|
|
|
|
|
|
btVector3 m_gravity;
|
2013-05-02 16:49:16 +00:00
|
|
|
bool m_cpuGpuSync;
|
2013-06-07 05:01:06 +00:00
|
|
|
float m_localTime;
|
2013-05-01 01:17:44 +00:00
|
|
|
|
|
|
|
int findOrRegisterCollisionShape(const btCollisionShape* colShape);
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
b3GpuDynamicsWorld(class b3GpuSapBroadphase* bp,class b3GpuNarrowPhase* np, class b3GpuRigidBodyPipeline* rigidBodyPipeline);
|
|
|
|
|
|
|
|
virtual ~b3GpuDynamicsWorld();
|
|
|
|
|
|
|
|
virtual int stepSimulation( btScalar timeStep,int maxSubSteps=1, btScalar fixedTimeStep=btScalar(1.)/btScalar(60.));
|
|
|
|
|
2013-06-07 05:01:06 +00:00
|
|
|
virtual void synchronizeMotionStates();
|
|
|
|
|
2013-05-01 01:17:44 +00:00
|
|
|
|
|
|
|
void debugDrawWorld() {}
|
|
|
|
|
|
|
|
void setGravity(const btVector3& gravity);
|
|
|
|
|
|
|
|
void addRigidBody(btRigidBody* body);
|
|
|
|
|
|
|
|
void removeCollisionObject(btCollisionObject* colObj);
|
|
|
|
|
2013-06-07 05:01:06 +00:00
|
|
|
virtual void removeRigidBody(btRigidBody* body);
|
|
|
|
|
2013-06-17 20:47:35 +00:00
|
|
|
virtual void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
|
|
|
|
|
|
|
|
virtual void removeConstraint(btTypedConstraint* constraint);
|
|
|
|
|
2013-05-02 16:49:16 +00:00
|
|
|
void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const;
|
2013-05-01 01:17:44 +00:00
|
|
|
|
|
|
|
btAlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray();
|
|
|
|
|
|
|
|
const btAlignedObjectArray<class btCollisionObject*>& getCollisionObjectArray() const;
|
|
|
|
|
|
|
|
|
|
|
|
btVector3 getGravity () const
|
|
|
|
{
|
|
|
|
return m_gravity;
|
|
|
|
}
|
|
|
|
|
2013-06-03 22:17:06 +00:00
|
|
|
virtual void addRigidBody(btRigidBody* body, short group, short mask)
|
|
|
|
{
|
|
|
|
addRigidBody(body);
|
|
|
|
}
|
|
|
|
|
2013-06-07 05:01:06 +00:00
|
|
|
|
2013-06-03 22:17:06 +00:00
|
|
|
|
|
|
|
virtual void addAction(btActionInterface* action)
|
|
|
|
{
|
|
|
|
btAssert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void removeAction(btActionInterface* action)
|
|
|
|
{
|
|
|
|
btAssert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void setConstraintSolver(btConstraintSolver* solver)
|
|
|
|
{
|
|
|
|
btAssert(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual btConstraintSolver* getConstraintSolver()
|
|
|
|
{
|
|
|
|
btAssert(0);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-05-01 01:17:44 +00:00
|
|
|
|
|
|
|
|
2013-06-07 05:01:06 +00:00
|
|
|
virtual void clearForces();
|
2013-05-01 01:17:44 +00:00
|
|
|
|
2013-06-03 22:17:06 +00:00
|
|
|
virtual btDynamicsWorldType getWorldType() const
|
|
|
|
{
|
|
|
|
return BT_GPU_DYNAMICS_WORLD;
|
|
|
|
}
|
2013-05-01 01:17:44 +00:00
|
|
|
|
2013-06-03 22:17:06 +00:00
|
|
|
///this can be useful to synchronize a single rigid body -> graphics object
|
|
|
|
void synchronizeSingleMotionState(btRigidBody* body);
|
2013-05-01 01:17:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //B3_GPU_DYNAMICS_WORLD_H
|