From c60ab78e2e97dd0d9539a1308cfd456dc2090d39 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 6 Mar 2001 23:55:39 +0000 Subject: [PATCH] *** empty log message *** --- panda/src/sgraphutil/Sources.pp | 5 +- panda/src/sgraphutil/frustumCullTraverser.I | 63 +++++++++++---------- panda/src/sgraphutil/frustumCullTraverser.h | 7 +++ 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/panda/src/sgraphutil/Sources.pp b/panda/src/sgraphutil/Sources.pp index a04a4cabbc..fa57868aca 100644 --- a/panda/src/sgraphutil/Sources.pp +++ b/panda/src/sgraphutil/Sources.pp @@ -10,8 +10,9 @@ #define SOURCES \ appTraverser.I appTraverser.cxx appTraverser.h \ config_sgraphutil.cxx config_sgraphutil.h directRenderTraverser.I \ - directRenderTraverser.cxx directRenderTraverser.h get_rel_pos.I \ - get_rel_pos.cxx get_rel_pos.h sceneGraphAnalyzer.cxx \ + directRenderTraverser.cxx directRenderTraverser.h \ + frustumCullTraverser.I frustumCullTraverser.h \ + get_rel_pos.I get_rel_pos.cxx get_rel_pos.h sceneGraphAnalyzer.cxx \ sceneGraphAnalyzer.h sceneGraphReducer.I sceneGraphReducer.cxx \ sceneGraphReducer.h diff --git a/panda/src/sgraphutil/frustumCullTraverser.I b/panda/src/sgraphutil/frustumCullTraverser.I index 0120cb8b31..4bca7e0ffe 100644 --- a/panda/src/sgraphutil/frustumCullTraverser.I +++ b/panda/src/sgraphutil/frustumCullTraverser.I @@ -3,13 +3,6 @@ // //////////////////////////////////////////////////////////////////// -#include "frustumCullTraverser.h" -#include "config_sgraphutil.h" - -#include -#include -#include -#include //////////////////////////////////////////////////////////////////// // Function: FrustumCullTraverser::Constructor @@ -148,32 +141,42 @@ traverse(NodeRelation *arc, AttributeWrapper render_state, } } - if (carry_on && - arc->has_transition(TransformTransition::get_class_type())) { - // Now apply the transform associated with this arc. We do - // this after the bounding volume test, because the bounding - // volume has already been transformed. + if (carry_on) { + if (arc->has_transition(BillboardTransition::get_class_type())) { + // We can't reliably cull within a billboard, because the + // geometry might get rotated out of its bounding volume. + // So once we get within a billboard, we consider it all + // visible. + all_in = true; + } - local_frustum = - DCAST(GeometricBoundingVolume, _view_frustum->make_copy()); + if (!all_in && + arc->has_transition(TransformTransition::get_class_type())) { + // Now apply the transform associated with this arc. We do + // this after the bounding volume test, because the bounding + // volume has already been transformed. - NodeTransitionWrapper ntw(TransformTransition::get_class_type()); - wrt(_gsg->get_current_projection_node(), - arc->get_child(), _arc_chain.begin(), _arc_chain.end(), - ntw, _graph_type); - - const TransformTransition *tt; - if (get_transition_into(tt, ntw)) { - // This frustum is transformed from the camera. Most will - // be. - nassertv(local_frustum != (GeometricBoundingVolume *)NULL); - local_frustum->xform(tt->get_matrix()); + local_frustum = + DCAST(GeometricBoundingVolume, _view_frustum->make_copy()); - if (sgraphutil_cat.is_spam()) { - sgraphutil_cat.spam() - << "Transforming frustum into local space of " << *arc << ": " << *local_frustum << "\n" - << "Transform is:\n"; - tt->get_matrix().write(sgraphutil_cat.spam(false), 2); + NodeTransitionWrapper ntw(TransformTransition::get_class_type()); + wrt(_gsg->get_current_projection_node(), + arc->get_child(), _arc_chain.begin(), _arc_chain.end(), + ntw, _graph_type); + + const TransformTransition *tt; + if (get_transition_into(tt, ntw)) { + // This frustum is transformed from the camera. Most will + // be. + nassertv(local_frustum != (GeometricBoundingVolume *)NULL); + local_frustum->xform(tt->get_matrix()); + + if (sgraphutil_cat.is_spam()) { + sgraphutil_cat.spam() + << "Transforming frustum into local space of " << *arc << ": " << *local_frustum << "\n" + << "Transform is:\n"; + tt->get_matrix().write(sgraphutil_cat.spam(false), 2); + } } } } diff --git a/panda/src/sgraphutil/frustumCullTraverser.h b/panda/src/sgraphutil/frustumCullTraverser.h index 7fa020f502..a121f66327 100644 --- a/panda/src/sgraphutil/frustumCullTraverser.h +++ b/panda/src/sgraphutil/frustumCullTraverser.h @@ -14,6 +14,13 @@ #include #include #include +#include +#include +#include +#include + +#include "config_sgraphutil.h" + ///////////////////////////////////////////////////////////////////