diff --git a/panda/src/graph/Sources.pp b/panda/src/graph/Sources.pp index 6ed3595e01..c4b85cab3f 100644 --- a/panda/src/graph/Sources.pp +++ b/panda/src/graph/Sources.pp @@ -49,7 +49,7 @@ pt_NamedNode.cxx pt_NamedNode.h pt_Node.N pt_Node.cxx pt_Node.h \ setTransitionHelpers.I setTransitionHelpers.h \ traverserVisitor.I traverserVisitor.h \ - vector_PT_Node.cxx vector_PT_Node.h wrt.I wrt.h + vector_PT_Node.cxx vector_PT_Node.h wrt.I wrt.h wrt.cxx #define INSTALL_HEADERS \ allAttributesWrapper.I allAttributesWrapper.h \ diff --git a/panda/src/graph/wrt.I b/panda/src/graph/wrt.I index ded1ad41d1..f9cd945064 100644 --- a/panda/src/graph/wrt.I +++ b/panda/src/graph/wrt.I @@ -3,6 +3,68 @@ // //////////////////////////////////////////////////////////////////// +#ifndef NDEBUG +//////////////////////////////////////////////////////////////////// +// Function: describe_ambiguous_wrt +// Description: Writes an error message to wrt_cat describing an +// attempt to compute an ambiguous wrt() without +// specifying enough arcs to resolve the ambiguity. +//////////////////////////////////////////////////////////////////// +template +void +describe_ambiguous_wrt(const Node *node, + InputIterator arc_list_begin, + InputIterator arc_list_end, + const UpRelationPointers &urp) { + if (wrt_cat.is_warning()) { + wrt_cat.warning() + << *node << " has " << urp.size() << " parents; wrt() ambiguous.\n" + << " parents are: "; + UpRelationPointers::const_iterator urpi; + urpi = urp.begin(); + wrt_cat.warning(false) << *(*urpi)->get_parent(); + urpi++; + while (urpi != urp.end()) { + wrt_cat.warning(false) << ", " << *(*urpi)->get_parent(); + urpi++; + } + wrt_cat.warning(false) << "\n"; + + // Show the chain of arcs specified. + if (arc_list_begin == arc_list_end) { + wrt_cat.warning(false) + << " no arcs specified.\n"; + } else { + wrt_cat.warning(false) + << " arcs specified:\n"; + InputIterator ri = arc_list_begin; + wrt_cat.warning(false) + << " " << *(*ri)->get_parent() << "/" + << *(*ri)->get_child(); + + InputIterator ri_last = ri; + ++ri; + while (ri != arc_list_end) { + if ((*ri)->get_parent() == (*ri_last)->get_child()) { + wrt_cat.warning(false) + << "/" << *(*ri)->get_child(); + } else { + wrt_cat.warning(false) + << "\n " << *(*ri)->get_parent() << "/" + << *(*ri)->get_child(); + } + ++ri; + } + wrt_cat.warning(false) << "\n"; + } + } + if (ambiguous_wrt_abort) { + abort(); + } +} +#endif + + //////////////////////////////////////////////////////////////////// // Function: get_cached_net_transition // Description: Returns the net transition from the root of the @@ -212,23 +274,7 @@ get_cached_net_transition(const Node *node, #ifndef NDEBUG // No, it wasn't mentioned. Issue a warning and use the first // one. - if (wrt_cat.is_warning()) { - wrt_cat.warning() - << *node << " has " << urp.size() << " parents; wrt() ambiguous.\n" - << " parents are: "; - UpRelationPointers::const_iterator urpi; - urpi = urp.begin(); - wrt_cat.warning(false) << *(*urpi)->get_parent(); - urpi++; - while (urpi != urp.end()) { - wrt_cat.warning(false) << ", " << *(*urpi)->get_parent(); - urpi++; - } - wrt_cat.warning(false) << "\n"; - } - if (ambiguous_wrt_abort) { - abort(); - } + describe_ambiguous_wrt(node, arc_list_begin, arc_list_end, urp); #endif parent_arc = *(urp.begin()); } @@ -332,23 +378,7 @@ get_uncached_net_transition(const Node *node, #ifndef NDEBUG // No, it wasn't mentioned. Issue a warning and use the first // one. - if (wrt_cat.is_warning()) { - wrt_cat.warning() - << *node << " has " << urp.size() << " parents; wrt() ambiguous.\n" - << " parents are:"; - UpRelationPointers::const_iterator urpi; - urpi = urp.begin(); - wrt_cat.warning(false) << *(*urpi)->get_parent(); - urpi++; - while (urpi != urp.end()) { - wrt_cat.warning(false) << ", " << *(*urpi)->get_parent(); - urpi++; - } - wrt_cat.warning(false) << "\n"; - } - if (ambiguous_wrt_abort) { - abort(); - } + describe_ambiguous_wrt(node, arc_list_begin, arc_list_end, urp); #endif parent_arc = *(urp.begin()); } diff --git a/panda/src/graph/wrt.cxx b/panda/src/graph/wrt.cxx new file mode 100644 index 0000000000..83252f51d3 --- /dev/null +++ b/panda/src/graph/wrt.cxx @@ -0,0 +1,10 @@ +// Filename: wrt.cxx +// Created by: drose (16Apr01) +// +//////////////////////////////////////////////////////////////////// + +#include "wrt.h" + +// There's no real need to have this file, but it's sometimes a little +// cleaner to guarantee that every .h file gets scanned when this +// directory is built. diff --git a/panda/src/switchnode/LODNode.cxx b/panda/src/switchnode/LODNode.cxx index e0711e09cc..8787127b88 100644 --- a/panda/src/switchnode/LODNode.cxx +++ b/panda/src/switchnode/LODNode.cxx @@ -81,8 +81,8 @@ sub_render(const AllAttributesWrapper &attrib, AllTransitionsWrapper &trans, LPoint3f LOD_pos; NodeTransitionWrapper ntw(TransformTransition::get_class_type()); - wrt(this, camera, trav->begin(), trav->end(), - ntw, RenderRelation::get_class_type()); + wrt(this, trav->begin(), trav->end(), + camera, ntw, RenderRelation::get_class_type()); const TransformTransition *tt; if (get_transition_into(tt, ntw)) { LOD_pos = _lod._center * tt->get_matrix();