15 #ifndef __BULLET_WORLD_H__
16 #define __BULLET_WORLD_H__
18 #include "pandabase.h"
20 #include "bullet_includes.h"
21 #include "bullet_utils.h"
23 #include "bulletClosestHitRayResult.h"
24 #include "bulletAllHitsRayResult.h"
25 #include "bulletClosestHitSweepResult.h"
26 #include "bulletContactResult.h"
27 #include "bulletDebugNode.h"
28 #include "bulletBaseCharacterControllerNode.h"
29 #include "bulletConstraint.h"
30 #include "bulletGhostNode.h"
31 #include "bulletRigidBodyNode.h"
32 #include "bulletSoftBodyNode.h"
33 #include "bulletVehicle.h"
35 #include "typedReferenceCount.h"
36 #include "transformState.h"
37 #include "pandaNode.h"
38 #include "callbackObject.h"
39 #include "collideMask.h"
58 void set_gravity(
const LVector3 &gravity);
59 void set_gravity(PN_stdfloat gx, PN_stdfloat gy, PN_stdfloat gz);
62 int do_physics(PN_stdfloat dt,
int max_substeps=1, PN_stdfloat stepsize=1.0f/60.0f);
68 INLINE
void clear_debug_node();
73 void attach_constraint(
BulletConstraint *constraint,
bool linked_collision=
false);
78 INLINE
int get_num_ghosts()
const;
80 MAKE_SEQ(get_ghosts, get_num_ghosts, get_ghost);
83 INLINE
int get_num_rigid_bodies()
const;
85 MAKE_SEQ(get_rigid_bodies, get_num_rigid_bodies, get_rigid_body);
88 INLINE
int get_num_soft_bodies()
const;
90 MAKE_SEQ(get_soft_bodies, get_num_soft_bodies, get_soft_body);
93 INLINE
int get_num_characters()
const;
95 MAKE_SEQ(get_characters, get_num_characters, get_character);
101 INLINE
int get_num_vehicles()
const;
103 MAKE_SEQ(get_vehicles, get_num_vehicles, get_vehicle);
106 INLINE
int get_num_constraints()
const;
108 MAKE_SEQ(get_constraints, get_num_constraints, get_constraint);
123 const TransformState &from_ts,
124 const TransformState &to_ts,
126 PN_stdfloat penetration=0.0f)
const;
134 INLINE
int get_num_manifolds()
const;
136 MAKE_SEQ(get_manifolds, get_num_manifolds, get_manifold);
139 void set_group_collision_flag(
unsigned int group1,
unsigned int group2,
bool enable);
140 bool get_group_collision_flag(
unsigned int group1,
unsigned int group2)
const;
144 void clear_contact_added_callback();
146 void set_tick_callback(
CallbackObject *obj,
bool is_pretick=
false);
147 void clear_tick_callback();
150 void clear_filter_callback();
153 enum BroadphaseAlgorithm {
155 BA_dynamic_aabb_tree,
158 enum FilterAlgorithm {
180 static btCollisionObject *get_collision_object(
PandaNode *node);
182 INLINE btDynamicsWorld *get_world()
const;
183 INLINE btBroadphaseInterface *get_broadphase()
const;
184 INLINE btDispatcher *get_dispatcher()
const;
187 void sync_p2b(PN_stdfloat dt,
int num_substeps);
190 static void tick_callback(btDynamicsWorld *world, btScalar timestep);
205 struct btFilterCallback1 :
public btOverlapFilterCallback {
206 virtual bool needBroadphaseCollision(
207 btBroadphaseProxy* proxy0,
208 btBroadphaseProxy* proxy1)
const;
211 struct btFilterCallback2 :
public btOverlapFilterCallback {
212 virtual bool needBroadphaseCollision(
213 btBroadphaseProxy* proxy0,
214 btBroadphaseProxy* proxy1)
const;
219 struct btFilterCallback3 :
public btOverlapFilterCallback {
220 virtual bool needBroadphaseCollision(
221 btBroadphaseProxy* proxy0,
222 btBroadphaseProxy* proxy1)
const;
227 btBroadphaseInterface *_broadphase;
228 btCollisionConfiguration *_configuration;
229 btCollisionDispatcher *_dispatcher;
230 btConstraintSolver *_solver;
231 btSoftRigidDynamicsWorld *_world;
233 btGhostPairCallback _ghost_cb;
235 btFilterCallback1 _filter_cb1;
236 btFilterCallback2 _filter_cb2;
237 btFilterCallback3 _filter_cb3;
238 btOverlapFilterCallback *_filter_cb;
244 btSoftBodyWorldInfo _info;
246 BulletRigidBodies _bodies;
247 BulletSoftBodies _softbodies;
248 BulletGhosts _ghosts;
249 BulletCharacterControllers _characters;
250 BulletVehicles _vehicles;
251 BulletConstraints _constraints;
258 static void init_type() {
259 TypedReferenceCount::init_type();
260 register_type(_type_handle,
"BulletWorld",
261 TypedReferenceCount::get_class_type());
264 return get_class_type();
268 return get_class_type();
275 EXPCL_PANDABULLET ostream &
276 operator << (ostream &out, BulletWorld::BroadphaseAlgorithm algorithm);
277 EXPCL_PANDABULLET istream &
278 operator >> (istream &in, BulletWorld::BroadphaseAlgorithm &algorithm);
280 EXPCL_PANDABULLET ostream &
281 operator << (ostream &out, BulletWorld::FilterAlgorithm algorithm);
282 EXPCL_PANDABULLET istream &
283 operator >> (istream &in, BulletWorld::FilterAlgorithm &algorithm);
285 #include "bulletWorld.I"
287 #endif // __BULLET_WORLD_H__
A basic node of the scene graph or data graph.
static BitMask< WType, nbits > all_on()
Returns a BitMask whose bits are all on.
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
This is an abstract class that all classes which use TypeHandle, and also provide virtual functions t...
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Simulates a raycast vehicle which casts a ray per wheel at the ground as a cheap replacement for comp...
A lightweight class that represents a single element that may be timed and/or counted via stats...
This is a generic object that can be assigned to a callback at various points in the rendering proces...
TypeHandle is the identifier used to differentiate C++ class types.