From bd86134b1576879b1a97508842acd8b2a592072f Mon Sep 17 00:00:00 2001 From: David Rose Date: Sun, 27 May 2007 16:22:49 +0000 Subject: [PATCH] improve copy_subgraph: quick_add_new_child() --- panda/src/pgraph/pandaNode.cxx | 26 +++++++++++++++++++++++++- panda/src/pgraph/pandaNode.h | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 0c1f1bece7..a155ea8563 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -2499,7 +2499,7 @@ r_copy_children(const PandaNode *from, PandaNode::InstanceMap &inst_map, inst_map[source_child] = dest_child; } - add_child(dest_child, sort, current_thread); + quick_add_new_child(dest_child, sort, current_thread); } } @@ -2646,6 +2646,30 @@ stage_replace_child(PandaNode *orig_child, PandaNode *new_child, return true; } +//////////////////////////////////////////////////////////////////// +// Function: PandaNode::quick_add_new_child +// Access: Private +// Description: Similar to add_child(), but performs fewer checks. +// The purpose of this method is to add a child node +// that was newly constructed, to a parent node that was +// newly constructed, so we know we have to make fewer +// sanity checks. This is a private method; do not call +// it directly. +//////////////////////////////////////////////////////////////////// +void PandaNode:: +quick_add_new_child(PandaNode *child_node, int sort, Thread *current_thread) { + // Apply this operation to the current stage as well as to all + // upstream stages. + OPEN_ITERATE_CURRENT_AND_UPSTREAM(_cycler, current_thread) { + CDStageWriter cdata(_cycler, pipeline_stage, current_thread); + CDStageWriter cdata_child(child_node->_cycler, pipeline_stage, current_thread); + + cdata->modify_down()->insert(DownConnection(child_node, sort)); + cdata_child->modify_up()->insert(UpConnection(this)); + } + CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); +} + //////////////////////////////////////////////////////////////////// // Function: PandaNode::report_cycle // Access: Private diff --git a/panda/src/pgraph/pandaNode.h b/panda/src/pgraph/pandaNode.h index 92ee576031..2b6ac012e8 100644 --- a/panda/src/pgraph/pandaNode.h +++ b/panda/src/pgraph/pandaNode.h @@ -307,6 +307,9 @@ private: bool stage_replace_child(PandaNode *orig_child, PandaNode *new_child, int pipeline_stage, Thread *current_thread); + void quick_add_new_child(PandaNode *child_node, int sort, + Thread *current_thread); + INLINE bool verify_child_no_cycles(PandaNode *child_node); void report_cycle(PandaNode *node); bool find_node_above(PandaNode *node);