From 41210fca9a294169f122a983c4a01ea9b3428d27 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 25 Jul 2001 02:41:23 +0000 Subject: [PATCH] hack to support instancing --- panda/src/sgraphutil/quickRenderLevelState.h | 1 + panda/src/sgraphutil/quickRenderTraverser.I | 1 + panda/src/sgraphutil/quickRenderTraverser.cxx | 34 ++++++++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/panda/src/sgraphutil/quickRenderLevelState.h b/panda/src/sgraphutil/quickRenderLevelState.h index 0fd94e0993..546bfd2108 100644 --- a/panda/src/sgraphutil/quickRenderLevelState.h +++ b/panda/src/sgraphutil/quickRenderLevelState.h @@ -32,6 +32,7 @@ class EXPCL_PANDA QuickRenderLevelState { public: UpdateSeq _as_of; + bool _under_instance; }; #endif diff --git a/panda/src/sgraphutil/quickRenderTraverser.I b/panda/src/sgraphutil/quickRenderTraverser.I index ca3f95b328..a329ccee62 100644 --- a/panda/src/sgraphutil/quickRenderTraverser.I +++ b/panda/src/sgraphutil/quickRenderTraverser.I @@ -27,4 +27,5 @@ backward_arc(NodeRelation *arc, NullTransitionWrapper &, NullAttributeWrapper &, NullAttributeWrapper &, const QuickRenderLevelState &) { mark_backward_arc(arc); + _arc_chain.pop_back(); } diff --git a/panda/src/sgraphutil/quickRenderTraverser.cxx b/panda/src/sgraphutil/quickRenderTraverser.cxx index b9afac372f..b4ae3a7a99 100644 --- a/panda/src/sgraphutil/quickRenderTraverser.cxx +++ b/panda/src/sgraphutil/quickRenderTraverser.cxx @@ -26,6 +26,7 @@ #include "pruneTransition.h" #include "geomNode.h" #include "pStatTimer.h" +#include "wrt.h" TypeHandle QuickRenderTraverser::_type_handle; @@ -73,11 +74,13 @@ traverse(Node *root, _root = root; _initial_state.apply_from(initial_state, net_trans); + _arc_chain = ArcChain(_root); QuickRenderLevelState level_state; level_state._as_of = UpdateSeq::initial(); + level_state._under_instance = false; - df_traverse(root, *this, + df_traverse(_root, *this, NullAttributeWrapper(), level_state, _graph_type); _root = (Node *)NULL; @@ -99,6 +102,7 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, Node *node = arc->get_child(); if (node->get_num_parents(_graph_type) != 1) { + /* const UpRelationPointers &urp = node->find_connection(_graph_type).get_up(); int num_parents = urp.size(); @@ -118,6 +122,8 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, sgraphutil_cat.warning(false) << "\n"; return false; + */ + level_state._under_instance = true; } if (implicit_app_traversal) { @@ -135,6 +141,8 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, } mark_forward_arc(arc); + _arc_chain.push_back(arc); + _gsg->_nodes_pcollector.add_level(1); if (node->is_of_type(GeomNode::get_class_type())) { @@ -143,18 +151,28 @@ forward_arc(NodeRelation *arc, NullTransitionWrapper &, // Determine the net transition to this GeomNode, and render it. GeomNode *gnode = DCAST(GeomNode, node); AllTransitionsWrapper trans; - Node *top_subtree = + + if (level_state._under_instance) { + // If we're under an instance node, we have to use the more + // expensive wrt() operation. + wrt(node, begin(), end(), (Node *)NULL, trans, _graph_type); + + } else { + // Otherwise, we can use wrt_subtree() to get better caching. + + //Node *top_subtree = wrt_subtree(arc, NULL, level_state._as_of, now, trans, _graph_type); - /* - cerr << "top_subtree is " << (void *)top_subtree; - if (top_subtree != (Node *)NULL) { - cerr << " is " << *top_subtree; + /* + cerr << "top_subtree is " << (void *)top_subtree; + if (top_subtree != (Node *)NULL) { + cerr << " is " << *top_subtree; + } + cerr << "\n"; + */ } - cerr << "\n"; - */ AllAttributesWrapper attrib; attrib.apply_from(_initial_state, trans);