23 (
"physics_manager_random_seed", 139);
30 _linear_integrator.clear();
31 _angular_integrator.clear();
40 PhysicalsVector::iterator pi;
41 for (pi = _physicals.begin(); pi != _physicals.end(); ++pi) {
42 nassertv((*pi)->_physics_manager ==
this);
43 (*pi)->_physics_manager =
nullptr;
64 LinearForceVector::iterator found;
67 found = find(_linear_forces.begin(), _linear_forces.end(), ptbf);
69 if (found == _linear_forces.end()) {
72 _linear_forces.erase(found);
81 AngularForceVector::iterator found;
84 found = find(_angular_forces.begin(), _angular_forces.end(), ptbf);
86 if (found == _angular_forces.end()) {
89 _angular_forces.erase(found);
100 found = find(_physicals.begin(), _physicals.end(), p);
101 if (found == _physicals.end()) {
104 nassertv(p->_physics_manager ==
this);
105 p->_physics_manager =
nullptr;
106 _physicals.erase(found);
115 for (
size_t i = 0; i < p->get_num_physicals(); ++i) {
127 PhysicalsVector::iterator p_cur = _physicals.begin();
128 for (; p_cur != _physicals.end(); ++p_cur) {
133 if (_linear_integrator) {
134 _linear_integrator->integrate(physical, _linear_forces, dt);
138 if (_angular_integrator) {
139 _angular_integrator->integrate(physical, _angular_forces, dt);
144 if (pn && pn->
is_of_type(ActorNode::get_class_type())) {
160 if (_linear_integrator) {
161 _linear_integrator->integrate(physical, _linear_forces, dt);
165 if (_angular_integrator) {
166 _angular_integrator->integrate(physical, _angular_forces, dt);
171 if (pn && pn->
is_of_type(ActorNode::get_class_type())) {
183 out<<
""<<
"PhysicsManager";
197 out<<
""<<
"_physicals ("<<_physicals.size()<<
" physicals)\n";
200 i != _physicals.end();
202 (*i)->write(out,
indent+2);
214 out<<
""<<
"_linear_forces ("<<_linear_forces.size()<<
" forces)\n";
215 for (LinearForceVector::const_iterator i=_linear_forces.begin();
216 i != _linear_forces.end();
218 (*i)->write(out,
indent+2);
230 out<<
""<<
"_angular_forces ("<<_angular_forces.size()<<
" forces)\n";
231 for (AngularForceVector::const_iterator i=_angular_forces.begin();
232 i != _angular_forces.end();
234 (*i)->write(out,
indent+2);
245 out.width(
indent); out<<
""<<
"PhysicsManager:\n";
248 out.width(
indent+2); out<<
""<<
"...\n";
254 out.width(
indent+2); out<<
""<<
"_linear_integrator:\n";
255 if (_linear_integrator) {
256 _linear_integrator->write(out,
indent+4);
258 out.width(
indent+4); out<<
""<<
"null\n";
260 out.width(
indent+2); out<<
""<<
"_angular_integrator:\n";
261 if (_angular_integrator) {
262 _angular_integrator->write(out,
indent+4);
264 out.width(
indent+4); out<<
""<<
"null\n";
275 out.width(
indent); out<<
""<<
"PhysicsManager li"<<(_linear_integrator?1:0)<<
" ai"<<(_angular_integrator?1:0)<<
"\n";
276 out<<
" _physicals "<<_physicals.size()<<
"\n";
281 out<<
""<<
"_linear_forces ("<<_linear_forces.size()<<
" forces)\n";
282 LinearForceVector::const_iterator li;
283 for (li=_linear_forces.begin();
284 li != _linear_forces.end();
286 (*li)->write(out,
indent+2);
290 out<<
""<<
" _angular_forces "<<_angular_forces.size()<<
"\n";
291 AngularForceVector::const_iterator ai;
292 for (ai=_angular_forces.begin();
293 ai != _angular_forces.end();
295 (*ai)->write(out,
indent+2);
virtual void write_angular_forces(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
virtual void write_physicals(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
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
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
virtual void write_linear_forces(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
void remove_linear_force(LinearForce *f)
takes a linear force out of the physics list
Defines a set of physically modeled attributes.
virtual void debug_output(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
virtual ~PhysicsManager()
Simple Destructor.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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
bool is_of_type(TypeHandle handle) const
Returns true if the current object is or derives from the indicated type.
virtual void write(std::ostream &out, 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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.