Browse Source

copying characters was not copying transforms

David Rose 23 years ago
parent
commit
d3e7579bf0
3 changed files with 17 additions and 9 deletions
  1. 12 5
      panda/src/chan/partBundleNode.I
  2. 1 1
      panda/src/chan/partBundleNode.h
  3. 4 3
      panda/src/char/character.cxx

+ 12 - 5
panda/src/chan/partBundleNode.I

@@ -47,14 +47,21 @@ PartBundleNode() : PandaNode("") {
 //     Function: PartBundleNode::Copy Constructor
 //       Access: Protected
 //  Description: Use make_copy() or copy_subgraph() to copy one of
-//               these.  Copying a PartBundleNode will always force a
-//               deep copy of the PartGroup hierarchy.
+//               these.  
+//
+//               If the supplied PartBundle is non-null, it is
+//               assigned to the new node; otherwise, a copy is made
+//               of the complete PartGroup hierarchy.
 ////////////////////////////////////////////////////////////////////
 INLINE PartBundleNode::
-PartBundleNode(const PartBundleNode &copy) :
-  PandaNode(copy),
-  _bundle(DCAST(PartBundle, copy._bundle->copy_subgraph()))
+PartBundleNode(const PartBundleNode &copy, PartBundle *bundle) :
+  PandaNode(copy)
 {
+  if (bundle != (PartBundle *)NULL) {
+    _bundle = bundle;
+  } else {
+    _bundle = DCAST(PartBundle, copy._bundle->copy_subgraph());
+  }
   _bundle->_node = this;
 }
 

+ 1 - 1
panda/src/chan/partBundleNode.h

@@ -38,7 +38,7 @@ public:
 
 protected:
   INLINE PartBundleNode();
-  INLINE PartBundleNode(const PartBundleNode &copy);
+  INLINE PartBundleNode(const PartBundleNode &copy, PartBundle *bundle = NULL);
 
 public:
   virtual bool safe_to_flatten() const;

+ 4 - 3
panda/src/char/character.cxx

@@ -44,15 +44,16 @@ PStatCollector Character::_anim_pcollector("App:Animation");
 ////////////////////////////////////////////////////////////////////
 Character::
 Character(const Character &copy) :
-  PartBundleNode(copy.get_name(), new CharacterJointBundle(copy.get_bundle()->get_name())),
+  PartBundleNode(copy, new CharacterJointBundle(copy.get_bundle()->get_name())),
   _cv(DynamicVertices::deep_copy(copy._cv)),
   _computed_vertices(copy._computed_vertices),
   _parts(copy._parts),
   _char_pcollector(copy._char_pcollector)
 {
   // Now make a copy of the joint/slider hierarchy.  We could just use
-  // the PartBundleNode's copy constructor, but if we do it ourselves
-  // we can simultaneously update our _parts list.
+  // the copy_subgraph feature of the PartBundleNode's copy
+  // constructor, but if we do it ourselves we can simultaneously
+  // update our _parts list.
 
   copy_joints(get_bundle(), copy.get_bundle());
 }