Browse Source

add clip-plane-cull

David Rose 18 years ago
parent
commit
e5d2c00879

+ 6 - 0
panda/src/pgraph/config_pgraph.cxx

@@ -115,6 +115,12 @@ ConfigVariableBool fake_view_frustum_cull
           "object in red wireframe, rather than actually culling it.  This "
           "object in red wireframe, rather than actually culling it.  This "
           "helps make culling errors obvious."));
           "helps make culling errors obvious."));
 
 
+ConfigVariableBool clip_plane_cull
+("clip-plane-cull", true,
+ PRC_DESC("This is normally true; set it false to disable culling of objects "
+          "that are completely behind one or more clip planes (primarily "
+          "useful for debugging)."));
+
 
 
 ConfigVariableBool allow_portal_cull
 ConfigVariableBool allow_portal_cull
 ("allow-portal-cull", false,
 ("allow-portal-cull", false,

+ 1 - 0
panda/src/pgraph/config_pgraph.h

@@ -35,6 +35,7 @@ NotifyCategoryDecl(loader, EXPCL_PANDA, EXPTP_PANDA);
 NotifyCategoryDecl(portal, EXPCL_PANDA, EXPTP_PANDA);
 NotifyCategoryDecl(portal, EXPCL_PANDA, EXPTP_PANDA);
 
 
 extern ConfigVariableBool fake_view_frustum_cull;
 extern ConfigVariableBool fake_view_frustum_cull;
+extern ConfigVariableBool clip_plane_cull;
 extern ConfigVariableBool allow_portal_cull;
 extern ConfigVariableBool allow_portal_cull;
 extern ConfigVariableBool unambiguous_graph;
 extern ConfigVariableBool unambiguous_graph;
 extern ConfigVariableBool detect_graph_cycles;
 extern ConfigVariableBool detect_graph_cycles;

+ 6 - 48
panda/src/pgraph/cullTraverserData.cxx

@@ -117,9 +117,12 @@ apply_transform_and_state(CullTraverser *trav,
   }
   }
 
 
   _state = _state->compose(node_state);
   _state = _state->compose(node_state);
-  _cull_planes = _cull_planes->apply_state(trav, this, 
-                                           _state->get_clip_plane(),
-                                           DCAST(ClipPlaneAttrib, off_clip_planes));
+
+  if (clip_plane_cull) {
+    _cull_planes = _cull_planes->apply_state(trav, this, 
+                                             _state->get_clip_plane(),
+                                             DCAST(ClipPlaneAttrib, off_clip_planes));
+  }
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -209,51 +212,6 @@ is_in_view_impl() {
   return true;
   return true;
 }
 }
 
 
-////////////////////////////////////////////////////////////////////
-//     Function: CullTraverserData::test_within_clip_planes_impl
-//       Access: Private
-//  Description: The private implementation of test_within_clip_planes().
-////////////////////////////////////////////////////////////////////
-int CullTraverserData::
-test_within_clip_planes_impl(const CullTraverser *trav,
-                             const ClipPlaneAttrib *cpa) const {
-  int result = BoundingVolume::IF_all | BoundingVolume::IF_possible | BoundingVolume::IF_some;
-
-
-  const BoundingVolume *node_volume = _node_reader.get_bounds();
-  nassertr(node_volume->is_of_type(GeometricBoundingVolume::get_class_type()), result);
-  const GeometricBoundingVolume *node_gbv =
-    DCAST(GeometricBoundingVolume, node_volume);
-
-  CPT(TransformState) net_transform = get_net_transform(trav);
-
-  cerr << "considering " << _node_path << ", bv = " << *node_gbv << "\n";
-  cerr << "  net_transform = " << *net_transform << "\n";
-
-  int num_planes = cpa->get_num_on_planes();
-  for (int i = 0; 
-       i < num_planes && result != BoundingVolume::IF_no_intersection; 
-       ++i) {
-    NodePath plane_path = cpa->get_on_plane(i);
-    PlaneNode *plane_node = DCAST(PlaneNode, plane_path.node());
-    CPT(TransformState) new_transform = 
-      net_transform->invert_compose(plane_path.get_net_transform());
-
-    Planef plane = plane_node->get_plane() * new_transform->get_mat();
-    BoundingPlane bplane(-plane);
-    cerr << "  " << bplane << " -> " << bplane.contains(node_gbv) << "\n";
-    result &= bplane.contains(node_gbv);
-  }
-
-  if (pgraph_cat.is_spam()) {
-    pgraph_cat.spam()
-      << _node_path << " test_within_clip_planes result = "
-      << hex << result << dec << "\n";
-  }
-
-  return result;
-}
-
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CullTraverserData::get_fake_view_frustum_cull_state
 //     Function: CullTraverserData::get_fake_view_frustum_cull_state
 //       Access: Private, Static
 //       Access: Private, Static

+ 0 - 2
panda/src/pgraph/cullTraverserData.h

@@ -85,8 +85,6 @@ public:
 
 
 private:
 private:
   bool is_in_view_impl();
   bool is_in_view_impl();
-  int test_within_clip_planes_impl(const CullTraverser *trav,
-                                   const ClipPlaneAttrib *cpa) const;
 
 
   static CPT(RenderState) get_fake_view_frustum_cull_state();
   static CPT(RenderState) get_fake_view_frustum_cull_state();
 };
 };