diff --git a/panda/src/pgraph/lodNode.I b/panda/src/pgraph/lodNode.I index 24efe46453..6bbcd6f554 100644 --- a/panda/src/pgraph/lodNode.I +++ b/panda/src/pgraph/lodNode.I @@ -491,4 +491,5 @@ clear_ring_viz() { _ring_viz.clear(); _spindle_viz.clear(); _viz_model_state.clear(); + _bounds_seq = UpdateSeq::old(); } diff --git a/panda/src/pgraph/lodNode.cxx b/panda/src/pgraph/lodNode.cxx index 9c61850c4b..f1577dd75a 100644 --- a/panda/src/pgraph/lodNode.cxx +++ b/panda/src/pgraph/lodNode.cxx @@ -561,13 +561,32 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, suggested_radius = 0.0f; if (index < get_num_children()) { + const Switch &sw = cdata->_switch_vector[index]; PandaNode *child = get_child(index); if (child != (PandaNode *)NULL) { - CPT(BoundingVolume) bv = child->get_bounds(); + UpdateSeq seq; + CPT(BoundingVolume) bv = child->get_bounds(seq); + + if (seq == sw._bounds_seq) { + // We previously verified this child, and it hasn't changed + // since then. + return sw._verify_ok; + } + + ((Switch &)sw)._bounds_seq = seq; + ((Switch &)sw)._verify_ok = true; + if (bv->is_empty()) { // This child has no geometry, so no one cares anyway. return true; } + if (bv->is_infinite()) { + // To be strict, we ought to look closer if the child has an + // infinite bounding volume, but in practice this is probably + // just a special case (e.g. the child contains the camera) + // that we don't really want to check. + return true; + } const Switch &sw = cdata->_switch_vector[index]; @@ -589,6 +608,7 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, nassertr(!gbv->is_infinite(), false); sphere.extend_by(gbv); suggested_radius = sphere.get_radius(); + ((Switch &)sw)._verify_ok = false; return false; } @@ -630,6 +650,7 @@ do_verify_child_bounds(const LODNode::CData *cdata, int index, sphere.extend_by(gbv); } suggested_radius = sphere.get_radius(); + ((Switch &)sw)._verify_ok = false; return false; } } diff --git a/panda/src/pgraph/lodNode.h b/panda/src/pgraph/lodNode.h index 2c6418c0f5..1d731e0824 100644 --- a/panda/src/pgraph/lodNode.h +++ b/panda/src/pgraph/lodNode.h @@ -140,6 +140,10 @@ protected: PT(PandaNode) _ring_viz; PT(PandaNode) _spindle_viz; CPT(RenderState) _viz_model_state; + + public: + UpdateSeq _bounds_seq; + bool _verify_ok; }; typedef pvector SwitchVector;