more pgraph refinements

This commit is contained in:
David Rose 2002-03-21 00:45:03 +00:00
parent d210511b8b
commit 3559ab5380

View File

@ -33,23 +33,27 @@ TypeHandle PandaNode::_type_handle;
// must enforce the following rules: // must enforce the following rules:
// //
// 1) Each NodePath (i.e. chain of NodePathComponents) represents a // 1) Each NodePath (i.e. chain of NodePathComponents) represents a
// complete unbroken chain from a PandaNode to the root of the graph. // complete unbroken chain from a PandaNode to the root of the
// graph.
// //
// 2) Each NodePathComponent chain is unique. There are no two // 2) Each NodePathComponent chain is unique. There are no two
// different NodePathComponents that reference the same path to the // different NodePathComponents that reference the same path to the
// root. // root.
// //
// 3) If a PandaNode with no parents is attached to a new parent, all // The following rules all follow from rules (1) and (2):
// NodePaths that previously indicated this node as the root of graph //
// must now be updated to include the complete chain to the new root. // 3) If a PandaNode with no parents is attached to a new parent,
// all NodePaths that previously indicated this node as the root of
// graph must now be updated to include the complete chain to the
// new root.
// //
// 4) If a PandaNode with other parents is attached to a new parent, // 4) If a PandaNode with other parents is attached to a new parent,
// any previously existing NodePaths are not affected. // any previously existing NodePaths are not affected.
// //
// 5) If a PandaNode is disconnected from its parent, and it has no // 5) If a PandaNode is disconnected from its parent, and it has no
// other parents, all NodePaths that previously passed through this // other parents, all NodePaths that previously passed through this
// node to the old parent must now be updated to indicate this node is // node to the old parent must now be updated to indicate this node
// now the root. // is now the root.
// //
// 6) If a PandaNode is disconnected from its parent, and it has at // 6) If a PandaNode is disconnected from its parent, and it has at
// least one other parent, all NodePaths that previously passed // least one other parent, all NodePaths that previously passed
@ -89,7 +93,7 @@ TypeHandle PandaNode::_type_handle;
// The NodePath support interface functions are strictly called from // The NodePath support interface functions are strictly called from
// within the NodePath class, and are used to implement // within the NodePath class, and are used to implement
// NodePath::reparent_to() and NodePath::remove_node(), etc. The // NodePath::reparent_to() and NodePath::remove_node(), etc. The
// fundamental interface, on the other hand, is designed to be called // fundamental interface, on the other hand, is intended to be called
// directly by the user. // directly by the user.
// //
// The fundamental interface has a slightly lower overhead because it // The fundamental interface has a slightly lower overhead because it
@ -1354,8 +1358,13 @@ detach(qpNodePathComponent *child) {
nassertv(child != (qpNodePathComponent *)NULL); nassertv(child != (qpNodePathComponent *)NULL);
nassertv(!child->is_top_node()); nassertv(!child->is_top_node());
PandaNode *child_node = child->get_node(); PT(PandaNode) child_node = child->get_node();
PandaNode *parent_node = child->get_next()->get_node(); PT(PandaNode) parent_node = child->get_next()->get_node();
// We should actually have a parent-child relationship, since this
// came from a qpNodePathComponent that ought to know about this
// sort of thing.
nassertv(child_node->find_parent(parent_node) >= 0);
// Break the qpNodePathComponent connection. // Break the qpNodePathComponent connection.
child->set_top_node(); child->set_top_node();