From 77b18a7c738ddd6cc8cca87327ae9ee51b6dfaf3 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Thu, 13 Jul 2006 00:24:48 +0000 Subject: [PATCH] we can now choose a particular Physical upon which to run physics processing instead of having to run through the entire scene --- panda/src/physics/physicsManager.cxx | 30 ++++++++++++++++++++++++++++ panda/src/physics/physicsManager.h | 1 + 2 files changed, 31 insertions(+) diff --git a/panda/src/physics/physicsManager.cxx b/panda/src/physics/physicsManager.cxx index 759f2426d3..a8b83b9c54 100644 --- a/panda/src/physics/physicsManager.cxx +++ b/panda/src/physics/physicsManager.cxx @@ -171,6 +171,36 @@ do_physics(float dt) { } } +//////////////////////////////////////////////////////////////////// +// Function : DoPhysics +// Access : Public +// Description : This is the main high-level API call. Performs +// integration on every attached Physical. +//////////////////////////////////////////////////////////////////// +void PhysicsManager:: +do_physics(float dt, Physical *physical) { + nassertv(physical); + + // do linear + //if (_linear_integrator.is_null() == false) { + if (_linear_integrator) { + _linear_integrator->integrate(physical, _linear_forces, dt); + } + + // do angular + //if (_angular_integrator.is_null() == false) { + if (_angular_integrator) { + _angular_integrator->integrate(physical, _angular_forces, dt); + } + + // if it's an actor node, tell it to update itself. + PhysicalNode *pn = physical->get_physical_node(); + if (pn && pn->is_of_type(ActorNode::get_class_type())) { + ActorNode *an = (ActorNode *) pn; + an->update_transform(); + } +} + //////////////////////////////////////////////////////////////////// // Function : output // Access : Public diff --git a/panda/src/physics/physicsManager.h b/panda/src/physics/physicsManager.h index 593373d445..b8b58f0af0 100644 --- a/panda/src/physics/physicsManager.h +++ b/panda/src/physics/physicsManager.h @@ -76,6 +76,7 @@ PUBLISHED: void remove_linear_force(LinearForce *f); void remove_angular_force(AngularForce *f); void do_physics(float dt); + void do_physics(float dt, Physical *p); void init_random_seed(); virtual void output(ostream &out) const;