copying characters was not copying transforms

This commit is contained in:
David Rose 2002-09-17 20:53:58 +00:00
parent af5c5c55b7
commit d3e7579bf0
3 changed files with 17 additions and 9 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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());
}