Browse Source

add remove_physical_node()

David Rose 21 years ago
parent
commit
ec6fab321c

+ 11 - 1
panda/src/physics/physicsManager.I

@@ -51,10 +51,20 @@ add_linear_force(LinearForce *f) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //    Function : attach_physicalnode
 //    Function : attach_physicalnode
 //      Access : Public
 //      Access : Public
-// Description : Registers an physicalnode with the manager
+// Description : Registers a physicalnode with the manager
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE void PhysicsManager::
 INLINE void PhysicsManager::
 attach_physicalnode(PhysicalNode *p) {
 attach_physicalnode(PhysicalNode *p) {
+  attach_physical_node(p);
+}
+
+////////////////////////////////////////////////////////////////////
+//    Function : attach_physical_node
+//      Access : Public
+// Description : Registers a physicalnode with the manager
+////////////////////////////////////////////////////////////////////
+INLINE void PhysicsManager::
+attach_physical_node(PhysicalNode *p) {
   nassertv(p);
   nassertv(p);
   for (int i = 0; i < p->get_num_physicals(); i++) {
   for (int i = 0; i < p->get_num_physicals(); i++) {
     attach_physical(p->get_physical(i));
     attach_physical(p->get_physical(i));

+ 13 - 0
panda/src/physics/physicsManager.cxx

@@ -100,6 +100,19 @@ remove_physical(Physical *p) {
   _physicals.erase(found);
   _physicals.erase(found);
 }
 }
 
 
+////////////////////////////////////////////////////////////////////
+//    Function : remove_physical_node
+//      Access : Public
+// Description : Removes a physicalnode from the manager
+////////////////////////////////////////////////////////////////////
+void PhysicsManager::
+remove_physical_node(PhysicalNode *p) {
+  nassertv(p);
+  for (int i = 0; i < p->get_num_physicals(); i++) {
+    remove_physical(p->get_physical(i));
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function : DoPhysics
 //     Function : DoPhysics
 //       Access : Public
 //       Access : Public

+ 2 - 0
panda/src/physics/physicsManager.h

@@ -59,6 +59,7 @@ PUBLISHED:
   INLINE void attach_angular_integrator(AngularIntegrator *i);
   INLINE void attach_angular_integrator(AngularIntegrator *i);
   INLINE void attach_physical(Physical *p);
   INLINE void attach_physical(Physical *p);
   INLINE void attach_physicalnode(PhysicalNode *p);
   INLINE void attach_physicalnode(PhysicalNode *p);
+  INLINE void attach_physical_node(PhysicalNode *p);
   INLINE void add_linear_force(LinearForce *f);
   INLINE void add_linear_force(LinearForce *f);
   INLINE void add_angular_force(AngularForce *f);
   INLINE void add_angular_force(AngularForce *f);
   INLINE void clear_linear_forces();
   INLINE void clear_linear_forces();
@@ -69,6 +70,7 @@ PUBLISHED:
   INLINE float get_viscosity() const;
   INLINE float get_viscosity() const;
   
   
   void remove_physical(Physical *p);
   void remove_physical(Physical *p);
+  void remove_physical_node(PhysicalNode *p);
   void remove_linear_force(LinearForce *f);
   void remove_linear_force(LinearForce *f);
   void remove_angular_force(AngularForce *f);
   void remove_angular_force(AngularForce *f);
   void do_physics(float dt);
   void do_physics(float dt);