2
Bullet Continuous Collision Detection and Physics Library
3
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
5
This software is provided 'as-is', without any express or implied warranty.
6
In no event will the authors be held liable for any damages arising from the use of this software.
7
Permission is granted to anyone to use this software for any purpose,
8
including commercial applications, and to alter it and redistribute it freely,
9
subject to the following restrictions:
11
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.
12
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13
3. This notice may not be removed or altered from any source distribution.
1
16
#ifndef CCDPHYSICSENVIRONMENT
2
17
#define CCDPHYSICSENVIRONMENT
11
class Point2PointConstraint;
12
class ToiContactDispatcher;
26
class TypedConstraint;
28
class CollisionDispatcher;
14
30
//#include "BroadphaseInterface.h"
32
//switch on/off new vehicle support
33
#define NEW_BULLET_VEHICLE_SUPPORT 1
35
#include "ConstraintSolver/ContactSolverInfo.h"
17
38
class PersistentManifold;
18
39
class BroadphaseInterface;
42
/// CcdPhysicsEnvironment is experimental mainloop for physics simulation using optional continuous collision detection.
21
43
/// Physics Environment takes care of stepping the simulation and is a container for physics entities.
22
44
/// It stores rigidbodies,constraints, materials etc.
23
45
/// A derived class may be able to 'construct' entities by loading and/or converting
24
46
class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
26
48
SimdVector3 m_gravity;
27
BroadphaseInterface* m_broadphase;
28
50
IDebugDraw* m_debugDrawer;
29
52
int m_numIterations;
54
//timestep subdivisions
55
int m_numTimeSubSteps;
59
bool m_enableSatCollisionDetection;
61
ContactSolverInfo m_solverInfo;
34
CcdPhysicsEnvironment(ToiContactDispatcher* dispatcher=0, BroadphaseInterface* broadphase=0);
65
CcdPhysicsEnvironment(CollisionDispatcher* dispatcher=0, BroadphaseInterface* broadphase=0);
36
67
virtual ~CcdPhysicsEnvironment();
49
80
virtual void setNumIterations(int numIter);
81
virtual void setNumTimeSubSteps(int numTimeSubSteps)
83
m_numTimeSubSteps = numTimeSubSteps;
50
85
virtual void setDeactivationTime(float dTime);
51
86
virtual void setDeactivationLinearTreshold(float linTresh) ;
52
87
virtual void setDeactivationAngularTreshold(float angTresh) ;
78
113
float pivotX,float pivotY,float pivotZ,
79
114
float axisX,float axisY,float axisZ);
80
115
virtual void removeConstraint(int constraintid);
116
virtual float getAppliedImpulse(int constraintid);
119
virtual void CallbackTriggers();
122
#ifdef NEW_BULLET_VEHICLE_SUPPORT
123
//complex constraint for vehicles
124
virtual PHY_IVehicle* getVehicleConstraint(int constraintId);
126
virtual class PHY_IVehicle* getVehicleConstraint(int constraintId)
130
#endif //NEW_BULLET_VEHICLE_SUPPORT
132
TypedConstraint* getConstraintById(int constraintId);
83
134
virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
84
135
float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
87
138
//Methods for gamelogic collision/physics callbacks
89
virtual void addSensor(PHY_IPhysicsController* ctrl) {};
90
virtual void removeSensor(PHY_IPhysicsController* ctrl){};
91
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user){};
92
virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl){};
93
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;};
94
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight){ return 0;};
139
virtual void addSensor(PHY_IPhysicsController* ctrl);
140
virtual void removeSensor(PHY_IPhysicsController* ctrl);
141
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
142
virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl);
143
virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl);
145
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
146
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
97
149
virtual int getNumContactPoints();
107
159
void removeCcdPhysicsController(CcdPhysicsController* ctrl);
109
BroadphaseInterface* GetBroadphase() { return m_broadphase; }
111
Dispatcher* GetDispatcher();
161
BroadphaseInterface* GetBroadphase();
163
CollisionDispatcher* GetDispatcher();
165
const CollisionDispatcher* GetDispatcher() const;
167
bool IsSatCollisionDetectionEnabled() const
169
return m_enableSatCollisionDetection;
172
void EnableSatCollisionDetection(bool enableSat)
174
m_enableSatCollisionDetection = enableSat;
177
void UpdateAabbs(float timeStep);
113
179
int GetNumControllers();
119
185
const PersistentManifold* GetManifold(int index) const;
187
std::vector<TypedConstraint*> m_constraints;
123
void UpdateActivationState();
124
192
void SyncMotionStates(float timeStep);
126
194
std::vector<CcdPhysicsController*> m_controllers;
128
std::vector<Point2PointConstraint*> m_p2pConstraints;
130
std::vector<Vehicle*> m_vehicles;
132
class ToiContactDispatcher* m_dispatcher;
196
std::vector<CcdPhysicsController*> m_triggerControllers;
198
PHY_ResponseCallback m_triggerCallbacks[PHY_NUM_RESPONSE];
199
void* m_triggerCallbacksUserPtrs[PHY_NUM_RESPONSE];
201
std::vector<WrapperVehicle*> m_wrapperVehicles;
203
class CollisionWorld* m_collisionWorld;
205
class ConstraintSolver* m_solver;
134
207
bool m_scalingPropagated;