Panda3D
bulletWorld.I
1 // Filename: bulletWorld.I
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 
16 ////////////////////////////////////////////////////////////////////
17 // Function: BulletWorld::Destructor
18 // Access: Published
19 // Description:
20 ////////////////////////////////////////////////////////////////////
21 INLINE BulletWorld::
22 ~BulletWorld() {
23 
24  while (get_num_characters() > 0) {
25  remove_character(get_character(0));
26  }
27 
28  while (get_num_vehicles() > 0) {
29  remove_vehicle(get_vehicle(0));
30  }
31 
32  while (get_num_constraints() > 0) {
33  remove_constraint(get_constraint(0));
34  }
35 
36  while (get_num_rigid_bodies() > 0) {
37  remove_rigid_body(get_rigid_body(0));
38  }
39 
40  while (get_num_soft_bodies() > 0) {
41  remove_soft_body(get_soft_body(0));
42  }
43 
44  while (get_num_ghosts() > 0) {
45  remove_ghost(get_ghost(0));
46  }
47 
48  _info.m_sparsesdf.Reset();
49 
50  delete _world;
51  delete _solver;
52  delete _configuration;
53  delete _dispatcher;
54  delete _broadphase;
55 }
56 
57 ////////////////////////////////////////////////////////////////////
58 // Function: BulletWorld::set_debug_node
59 // Access: Published
60 // Description:
61 ////////////////////////////////////////////////////////////////////
62 INLINE void BulletWorld::
63 set_debug_node(BulletDebugNode *node) {
64 
65  nassertv(node);
66 
67  _debug = node;
68  _world->setDebugDrawer(&(_debug->_drawer));
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function: BulletWorld::clear_debug_node
73 // Access: Published
74 // Description:
75 ////////////////////////////////////////////////////////////////////
76 INLINE void BulletWorld::
77 clear_debug_node() {
78 
79  _debug = NULL;
80  _world->setDebugDrawer(NULL);
81 }
82 
83 ////////////////////////////////////////////////////////////////////
84 // Function: BulletWorld::get_debug_node
85 // Access: Published
86 // Description:
87 ////////////////////////////////////////////////////////////////////
88 INLINE BulletDebugNode *BulletWorld::
89 get_debug_node() const {
90 
91  return _debug;
92 }
93 
94 ////////////////////////////////////////////////////////////////////
95 // Function: BulletWorld::get_world
96 // Access: Public
97 // Description:
98 ////////////////////////////////////////////////////////////////////
99 INLINE btDynamicsWorld *BulletWorld::
100 get_world() const {
101 
102  return _world;
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: BulletWorld::get_broadphase
107 // Access: Public
108 // Description:
109 ////////////////////////////////////////////////////////////////////
110 INLINE btBroadphaseInterface *BulletWorld::
111 get_broadphase() const {
112 
113  return _broadphase;
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: BulletWorld::get_dispatcher
118 // Access: Public
119 // Description:
120 ////////////////////////////////////////////////////////////////////
121 INLINE btDispatcher *BulletWorld::
122 get_dispatcher() const {
123 
124  return _dispatcher;
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: BulletWorld::get_num_rigid_bodies
129 // Access: Published
130 // Description:
131 ////////////////////////////////////////////////////////////////////
132 INLINE int BulletWorld::
133 get_num_rigid_bodies() const {
134 
135  return _bodies.size();
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: BulletWorld::get_rigid_body
140 // Access: Published
141 // Description:
142 ////////////////////////////////////////////////////////////////////
143 INLINE BulletRigidBodyNode *BulletWorld::
144 get_rigid_body(int idx) const {
145 
146  nassertr(idx >= 0 && idx < (int)_bodies.size(), NULL);
147  return _bodies[idx];
148 }
149 
150 ////////////////////////////////////////////////////////////////////
151 // Function: BulletWorld::get_num_soft_bodies
152 // Access: Published
153 // Description:
154 ////////////////////////////////////////////////////////////////////
155 INLINE int BulletWorld::
156 get_num_soft_bodies() const {
157 
158  return _softbodies.size();
159 }
160 
161 ////////////////////////////////////////////////////////////////////
162 // Function: BulletWorld::get_soft_body
163 // Access: Published
164 // Description:
165 ////////////////////////////////////////////////////////////////////
166 INLINE BulletSoftBodyNode *BulletWorld::
167 get_soft_body(int idx) const {
168 
169  nassertr(idx >= 0 && idx < (int)_softbodies.size(), NULL);
170  return _softbodies[idx];
171 }
172 
173 ////////////////////////////////////////////////////////////////////
174 // Function: BulletWorld::get_num_ghosts
175 // Access: Published
176 // Description:
177 ////////////////////////////////////////////////////////////////////
178 INLINE int BulletWorld::
179 get_num_ghosts() const {
180 
181  return _ghosts.size();
182 }
183 
184 ////////////////////////////////////////////////////////////////////
185 // Function: BulletWorld::get_ghost
186 // Access: Published
187 // Description:
188 ////////////////////////////////////////////////////////////////////
189 INLINE BulletGhostNode *BulletWorld::
190 get_ghost(int idx) const {
191 
192  nassertr(idx >= 0 && idx < (int)_ghosts.size(), NULL);
193  return _ghosts[idx];
194 }
195 
196 ////////////////////////////////////////////////////////////////////
197 // Function: BulletWorld::get_num_characters
198 // Access: Published
199 // Description:
200 ////////////////////////////////////////////////////////////////////
201 INLINE int BulletWorld::
202 get_num_characters() const {
203 
204  return _characters.size();
205 }
206 
207 ////////////////////////////////////////////////////////////////////
208 // Function: BulletWorld::get_character
209 // Access: Published
210 // Description:
211 ////////////////////////////////////////////////////////////////////
212 INLINE BulletBaseCharacterControllerNode *BulletWorld::
213 get_character(int idx) const {
214 
215  nassertr(idx >= 0 && idx < (int)_characters.size(), NULL);
216  return _characters[idx];
217 }
218 
219 ////////////////////////////////////////////////////////////////////
220 // Function: BulletWorld::get_num_vehicles
221 // Access: Published
222 // Description:
223 ////////////////////////////////////////////////////////////////////
224 INLINE int BulletWorld::
225 get_num_vehicles() const {
226 
227  return _vehicles.size();
228 }
229 
230 ////////////////////////////////////////////////////////////////////
231 // Function: BulletWorld::get_vehicle
232 // Access: Published
233 // Description:
234 ////////////////////////////////////////////////////////////////////
235 INLINE BulletVehicle *BulletWorld::
236 get_vehicle(int idx) const {
237 
238  nassertr(idx >= 0 && idx < (int)_vehicles.size(), NULL);
239  return _vehicles[idx];
240 }
241 
242 ////////////////////////////////////////////////////////////////////
243 // Function: BulletWorld::get_num_constraints
244 // Access: Published
245 // Description:
246 ////////////////////////////////////////////////////////////////////
247 INLINE int BulletWorld::
248 get_num_constraints() const {
249 
250  return _constraints.size();
251 }
252 
253 ////////////////////////////////////////////////////////////////////
254 // Function: BulletWorld::get_constraint
255 // Access: Published
256 // Description:
257 ////////////////////////////////////////////////////////////////////
258 INLINE BulletConstraint *BulletWorld::
259 get_constraint(int idx) const {
260 
261  nassertr(idx >= 0 && idx < (int)_constraints.size(), NULL);
262  return _constraints[idx];
263 }
264 
265 ////////////////////////////////////////////////////////////////////
266 // Function: BulletWorld::get_num_manifolds
267 // Access: Published
268 // Description:
269 ////////////////////////////////////////////////////////////////////
270 INLINE int BulletWorld::
271 get_num_manifolds() const {
272 
273  return _world->getDispatcher()->getNumManifolds();
274 }
275 
276 
void remove_soft_body(BulletSoftBodyNode *node)
Deprecated.
void remove_vehicle(BulletVehicle *vehicle)
Deprecated.
void remove_ghost(BulletGhostNode *node)
Deprecated.
void remove_rigid_body(BulletRigidBodyNode *node)
Deprecated.
Simulates a raycast vehicle which casts a ray per wheel at the ground as a cheap replacement for comp...
Definition: bulletVehicle.h:65
void remove_character(BulletBaseCharacterControllerNode *node)
Deprecated.
void remove_constraint(BulletConstraint *constraint)
Deprecated.