Browse Source

don't crash when clipping collision vizzes

David Rose 20 years ago
parent
commit
71cbcb72d7
2 changed files with 14 additions and 5 deletions
  1. 9 5
      panda/src/pgraph/cullPlanes.cxx
  2. 5 0
      panda/src/pgraph/cullTraverser.cxx

+ 9 - 5
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;
 

+ 5 - 0
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();