Browse Source

update pointers properly when flattening characters

David Rose 19 years ago
parent
commit
62d290fd00

+ 12 - 1
panda/src/chan/partBundle.cxx

@@ -318,7 +318,18 @@ control_activated(AnimControl *control) {
   }
 }
 
-
+////////////////////////////////////////////////////////////////////
+//     Function: PartBundle::set_node
+//       Access: Protected, Virtual
+//  Description: Changes the PartBundleNode pointer associated with
+//               the PartBundle.  Normally called only by the
+//               PartBundleNode itself, for instance when the bundle
+//               is flattened with another node.
+////////////////////////////////////////////////////////////////////
+void PartBundle::
+set_node(PartBundleNode *node) {
+  _node = node;
+}
 
 ////////////////////////////////////////////////////////////////////
 //     Function: PartBundle::do_set_control_effect

+ 3 - 0
panda/src/chan/partBundle.h

@@ -127,6 +127,9 @@ public:
   // bunch of friends.
   virtual void control_activated(AnimControl *control);
 
+protected:
+  virtual void set_node(PartBundleNode *node);
+
 private:
   class CData;
 

+ 2 - 2
panda/src/chan/partBundleNode.cxx

@@ -76,7 +76,7 @@ void PartBundleNode::
 add_bundle(PartBundle *bundle) {
   nassertv(bundle->_node == NULL);
   _bundles.push_back(bundle);
-  bundle->_node = this;
+  bundle->set_node(this);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -91,7 +91,7 @@ steal_bundles(PartBundleNode *other) {
   for (bi = other->_bundles.begin(); bi != other->_bundles.end(); ++bi) {
     PartBundle *bundle = (*bi);
     _bundles.push_back(bundle);
-    bundle->_node = this;
+    bundle->set_node(this);
   }
   other->_bundles.clear();
 }

+ 1 - 0
panda/src/chan/partGroup.h

@@ -140,6 +140,7 @@ private:
   static TypeHandle _type_handle;
 
   friend class Character;
+  friend class CharacterJointBundle;
 };
 
 #include "partGroup.I"