From 71cbcb72d7140ebf010599ca47ab0eb73a11dbf1 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 14 Mar 2006 01:20:44 +0000 Subject: [PATCH] don't crash when clipping collision vizzes --- panda/src/pgraph/cullPlanes.cxx | 14 +++++++++----- panda/src/pgraph/cullTraverser.cxx | 5 +++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/panda/src/pgraph/cullPlanes.cxx b/panda/src/pgraph/cullPlanes.cxx index b34a3641bd..9ff4b4871f 100644 --- a/panda/src/pgraph/cullPlanes.cxx +++ b/panda/src/pgraph/cullPlanes.cxx @@ -136,14 +136,18 @@ apply_state(const CullTraverser *trav, const CullTraverserData *data, CPT(CullPlanes) CullPlanes:: do_cull(int &result, CPT(RenderState) &state, const GeometricBoundingVolume *node_gbv) const { - // We should have a ClipPlaneAttrib in the state if we've called - // this method. - CPT(ClipPlaneAttrib) orig_cpa = state->get_clip_plane(); - nassertr(orig_cpa != (ClipPlaneAttrib *)NULL, this); - result = BoundingVolume::IF_all | BoundingVolume::IF_possible | BoundingVolume::IF_some; + CPT(ClipPlaneAttrib) orig_cpa = state->get_clip_plane(); + + // If there are no clip planes in the state, the node is completely + // in front of all zero of the clip planes. (This can happen if + // someone directly changes the state during the traversal.) + if (orig_cpa == (ClipPlaneAttrib *)NULL) { + return new CullPlanes; + } + CPT(CullPlanes) new_planes = this; CPT(ClipPlaneAttrib) new_cpa = orig_cpa; diff --git a/panda/src/pgraph/cullTraverser.cxx b/panda/src/pgraph/cullTraverser.cxx index f2412791b8..c542a093d3 100644 --- a/panda/src/pgraph/cullTraverser.cxx +++ b/panda/src/pgraph/cullTraverser.cxx @@ -208,6 +208,11 @@ traverse_below(CullTraverserData &data) { if (node->is_geom_node()) { _geom_nodes_pcollector.add_level(1); GeomNode *geom_node = DCAST(GeomNode, node); + + if (pgraph_cat.is_spam()) { + pgraph_cat.spam() + << "Found " << *geom_node << " in state " << *data._state << "\n"; + } // Get all the Geoms, with no decalling. int num_geoms = geom_node->get_num_geoms();