15 #include "physicsManager.h" 16 #include "actorNode.h" 22 (
"physics_manager_random_seed", 139);
32 _linear_integrator.clear();
33 _angular_integrator.clear();
44 PhysicalsVector::iterator pi;
45 for (pi = _physicals.begin(); pi != _physicals.end(); ++pi) {
46 nassertv((*pi)->_physics_manager ==
this);
47 (*pi)->_physics_manager = NULL;
73 LinearForceVector::iterator found;
76 found = find(_linear_forces.begin(), _linear_forces.end(), ptbf);
78 if (found == _linear_forces.end()) {
81 _linear_forces.erase(found);
92 AngularForceVector::iterator found;
95 found = find(_angular_forces.begin(), _angular_forces.end(), ptbf);
97 if (found == _angular_forces.end()) {
100 _angular_forces.erase(found);
113 found = find(_physicals.begin(), _physicals.end(), p);
114 if (found == _physicals.end()) {
117 nassertv(p->_physics_manager ==
this);
119 _physicals.erase(found);
130 for (
int i = 0; i < p->get_num_physicals(); ++i) {
144 PhysicalsVector::iterator p_cur = _physicals.begin();
145 for (; p_cur != _physicals.end(); ++p_cur) {
151 if (_linear_integrator) {
152 _linear_integrator->integrate(physical, _linear_forces, dt);
157 if (_angular_integrator) {
158 _angular_integrator->integrate(physical, _angular_forces, dt);
163 if (pn && pn->
is_of_type(ActorNode::get_class_type())) {
183 if (_linear_integrator) {
184 _linear_integrator->integrate(physical, _linear_forces, dt);
189 if (_angular_integrator) {
190 _angular_integrator->integrate(physical, _angular_forces, dt);
195 if (pn && pn->
is_of_type(ActorNode::get_class_type())) {
210 out<<
""<<
"PhysicsManager";
227 out<<
""<<
"_physicals ("<<_physicals.size()<<
" physicals)\n";
230 i != _physicals.end();
232 (*i)->write(out, indent+2);
247 out<<
""<<
"_linear_forces ("<<_linear_forces.size()<<
" forces)\n";
248 for (LinearForceVector::const_iterator i=_linear_forces.begin();
249 i != _linear_forces.end();
251 (*i)->write(out, indent+2);
266 out<<
""<<
"_angular_forces ("<<_angular_forces.size()<<
" forces)\n";
267 for (AngularForceVector::const_iterator i=_angular_forces.begin();
268 i != _angular_forces.end();
270 (*i)->write(out, indent+2);
282 write(ostream &out,
unsigned int indent)
const {
284 out.width(indent); out<<
""<<
"PhysicsManager:\n";
287 out.width(indent+2); out<<
""<<
"...\n";
293 out.width(indent+2); out<<
""<<
"_linear_integrator:\n";
294 if (_linear_integrator) {
295 _linear_integrator->write(out, indent+4);
297 out.width(indent+4); out<<
""<<
"null\n";
299 out.width(indent+2); out<<
""<<
"_angular_integrator:\n";
300 if (_angular_integrator) {
301 _angular_integrator->write(out, indent+4);
303 out.width(indent+4); out<<
""<<
"null\n";
317 out.width(indent); out<<
""<<
"PhysicsManager li"<<(_linear_integrator?1:0)<<
" ai"<<(_angular_integrator?1:0)<<
"\n";
318 out<<
" _physicals "<<_physicals.size()<<
"\n";
323 out<<
""<<
"_linear_forces ("<<_linear_forces.size()<<
" forces)\n";
324 LinearForceVector::const_iterator li;
325 for (li=_linear_forces.begin();
326 li != _linear_forces.end();
328 (*li)->write(out, indent+2);
332 out<<
""<<
" _angular_forces "<<_angular_forces.size()<<
"\n";
333 AngularForceVector::const_iterator ai;
334 for (ai=_angular_forces.begin();
335 ai != _angular_forces.end();
337 (*ai)->write(out, indent+2);
PhysicsManager()
Default Constructor.
void init_random_seed()
One-time config function, sets up the random seed used by the physics and particle systems...
void remove_physical(Physical *p)
takes a physical out of the object list
virtual void write_angular_forces(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
void update_transform()
this sets the transform generated by the contained Physical, moving the node and subsequent geometry...
A force that acts on a PhysicsObject by way of an Integrator.
pure virtual base class for all forces that could POSSIBLY exist.
This is our own Panda specialization on the default STL vector.
Graph node that encapsulated a series of physical objects.
Physics don't get much higher-level than this.
virtual void write_physicals(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
void remove_linear_force(LinearForce *f)
takes a linear force out of the physics list
Defines a set of physically modeled attributes.
virtual ~PhysicsManager()
Simple Destructor.
pure virtual parent of all quat-based forces.
void do_physics(PN_stdfloat dt)
This is the main high-level API call.
This is a convenience class to specialize ConfigVariable as an integer type.
void remove_angular_force(AngularForce *f)
takes an angular force out of the physics list
virtual void write_linear_forces(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
Like a physical node, but with a little more.
void remove_physical_node(PhysicalNode *p)
Removes a physicalnode from the manager.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
virtual void debug_output(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.