Panda3D
config_bullet.cxx
1 // Filename: config_bullet.cxx
2 // Created by: enn0x (23Jan10)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_bullet.h"
16 
17 #include "bulletBaseCharacterControllerNode.h"
18 #include "bulletBodyNode.h"
19 #include "bulletBoxShape.h"
20 #include "bulletCapsuleShape.h"
21 #include "bulletCharacterControllerNode.h"
22 #include "bulletConeShape.h"
23 #include "bulletConeTwistConstraint.h"
24 #include "bulletContactCallbackData.h"
25 #include "bulletConstraint.h"
26 #include "bulletConvexHullShape.h"
27 #include "bulletConvexPointCloudShape.h"
28 #include "bulletCylinderShape.h"
29 #include "bulletMinkowskiSumShape.h"
30 #include "bulletDebugNode.h"
31 #include "bulletFilterCallbackData.h"
32 #include "bulletGenericConstraint.h"
33 #include "bulletGhostNode.h"
34 #include "bulletHeightfieldShape.h"
35 #include "bulletHingeConstraint.h"
36 #include "bulletMultiSphereShape.h"
37 #include "bulletPlaneShape.h"
38 #include "bulletRigidBodyNode.h"
39 #include "bulletShape.h"
40 #include "bulletSliderConstraint.h"
41 #include "bulletSphereShape.h"
42 #include "bulletSphericalConstraint.h"
43 #include "bulletSoftBodyNode.h"
44 #include "bulletSoftBodyShape.h"
45 #include "bulletTickCallbackData.h"
46 #include "bulletTriangleMesh.h"
47 #include "bulletTriangleMeshShape.h"
48 #include "bulletVehicle.h"
49 #include "bulletWorld.h"
50 
51 #include "bulletContactCallbacks.h"
52 
53 extern ContactAddedCallback gContactAddedCallback;
54 extern ContactProcessedCallback gContactProcessedCallback;
55 extern ContactDestroyedCallback gContactDestroyedCallback;
56 
57 #include "dconfig.h"
58 #include "pandaSystem.h"
59 
60 Configure(config_bullet);
61 NotifyCategoryDef(bullet, "");
62 
63 ConfigureFn(config_bullet) {
64  init_libbullet();
65 }
66 
67 ConfigVariableInt bullet_max_objects
68 ("bullet-max-objects", 1024,
69 PRC_DESC("Specifies the maximum number of individual objects within a "
70  "bullet physics world. Default value is 1024."));
71 
72 ConfigVariableInt bullet_gc_lifetime
73 ("bullet-gc-lifetime", 256,
74 PRC_DESC("Specifies the lifetime of data clean up be the soft body world "
75  "info garbage collector. Default value is 256."));
76 
78 ("bullet-broadphase-algorithm", BulletWorld::BA_dynamic_aabb_tree,
79 PRC_DESC("Specifies the broadphase algorithm to be used by the physics "
80  "engine. Default value is 'aabb' (dynamic aabb tree)."));
81 
83 ("bullet-filter-algorithm", BulletWorld::FA_mask,
84 PRC_DESC("Specifies the algorithm to be used by the physics engine for "
85  "collision filtering. Default value is 'mask'."));
86 
87 ConfigVariableDouble bullet_sap_extents
88 ("bullet-sap-extents", 1000.0,
89 PRC_DESC("Specifies the world extent in all directions. The config variable "
90  "is only used if bullet-broadphase-algorithm is set to 'sap' "
91  "(sweep and prune). Default value is 1000.0."));
92 
93 ConfigVariableBool bullet_enable_contact_events
94 ("bullet-enable-contact-events", false,
95 PRC_DESC("Specifies if events should be send when new contacts are "
96  "created or existing contacts get remove. Warning: enabling "
97  "contact events might create more load on the event queue "
98  "then you might want! Default value is FALSE."));
99 
100 ConfigVariableInt bullet_solver_iterations
101 ("bullet-solver-iterations", 10,
102 PRC_DESC("Specifies the number of iterations for the Bullet contact "
103  "solver. This is the native Bullet property "
104  "btContactSolverInfo::m_numIterations. Default value is 10."));
105 
106 ConfigVariableBool bullet_additional_damping
107 ("bullet-additional-damping", false,
108 PRC_DESC("Enables additional damping on eachrigid body, in order to reduce "
109  "jitter. Default value is FALSE. Additional damping is an "
110  "experimental feature of the Bullet physics engine. Use with "
111  "care."));
112 
113 ConfigVariableDouble bullet_additional_damping_linear_factor
114 ("bullet-additional-damping-linear-factor", 0.005,
115 PRC_DESC("Only used when bullet-additional-damping is set to TRUE. "
116  "Default value is 0.005"));
117 
118 ConfigVariableDouble bullet_additional_damping_angular_factor
119 ("bullet-additional-damping-angular-factor", 0.01,
120 PRC_DESC("Only used when bullet-additional-damping is set to TRUE. "
121  "Default value is 0.01"));
122 
123 ConfigVariableDouble bullet_additional_damping_linear_threshold
124 ("bullet-additional-damping-linear-threshold", 0.01,
125 PRC_DESC("Only used when bullet-additional-damping is set to TRUE. "
126  "Default value is 0.01"));
127 
128 ConfigVariableDouble bullet_additional_damping_angular_threshold
129 ("bullet-additional-damping-angular-threshold", 0.01,
130 PRC_DESC("Only used when bullet-additional-damping is set to TRUE. "
131  "Default value is 0.01."));
132 
133 ////////////////////////////////////////////////////////////////////
134 // Function: init_libbullet
135 // Description: Initializes the library. This must be called at
136 // least once before any of the functions or classes in
137 // this library can be used. Normally it will be
138 // called by the static initializers and need not be
139 // called explicitly, but special cases exist.
140 ////////////////////////////////////////////////////////////////////
141 void
142 init_libbullet() {
143 
144  static bool initialized = false;
145  if (initialized) {
146  return;
147  }
148  initialized = true;
149 
150  // Initialize types
151  BulletBaseCharacterControllerNode::init_type();
152  BulletBodyNode::init_type();
153  BulletBoxShape::init_type();
154  BulletCapsuleShape::init_type();
155  BulletCharacterControllerNode::init_type();
156  BulletConeShape::init_type();
157  BulletConeTwistConstraint::init_type();
158  BulletContactCallbackData::init_type();
159  BulletConstraint::init_type();
160  BulletConvexHullShape::init_type();
161  BulletConvexPointCloudShape::init_type();
162  BulletCylinderShape::init_type();
163  BulletMinkowskiSumShape::init_type();
164  BulletDebugNode::init_type();
165  BulletFilterCallbackData::init_type();
166  BulletGenericConstraint::init_type();
167  BulletGhostNode::init_type();
168  BulletHeightfieldShape::init_type();
169  BulletHingeConstraint::init_type();
170  BulletMultiSphereShape::init_type();
171  BulletPlaneShape::init_type();
172  BulletRigidBodyNode::init_type();
173  BulletShape::init_type();
174  BulletSliderConstraint::init_type();
175  BulletSphereShape::init_type();
176  BulletSphericalConstraint::init_type();
177  BulletSoftBodyNode::init_type();
178  BulletSoftBodyShape::init_type();
179  BulletTickCallbackData::init_type();
180  BulletTriangleMesh::init_type();
181  BulletTriangleMeshShape::init_type();
182  BulletVehicle::init_type();
183  BulletWorld::init_type();
184 
185  // Custom contact callbacks
186  gContactAddedCallback = contact_added_callback;
187  gContactProcessedCallback = contact_processed_callback;
188  gContactDestroyedCallback = contact_destroyed_callback;
189 
190  // Initialize notification category
191  bullet_cat.init();
192  bullet_cat.debug() << "initialize module" << endl;
193 
194  // Register the Bullet system
196  ps->add_system("Bullet");
197 }
198 
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
This class is used as a namespace to group several global properties of Panda.
Definition: pandaSystem.h:29
This is a convenience class to specialize ConfigVariable as a boolean type.
void add_system(const string &system)
Intended for use by each subsystem to register itself at startup.
This is a convenience class to specialize ConfigVariable as a floating-point type.
This class specializes ConfigVariable as an enumerated type.
This is a convenience class to specialize ConfigVariable as an integer type.