Просмотр исходного кода

Add config var "show-portal-debug" to allow turning off the debug lines

rdb 16 лет назад
Родитель
Сommit
4271960b92

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

@@ -121,6 +121,12 @@ ConfigVariableBool allow_portal_cull
           "renderer to cull more objects that are clipped if not in the "
           "current list of portals.  This is still somewhat experimental."));
 
+ConfigVariableBool show_portal_debug
+("show-portal-debug", true,
+ PRC_DESC("Set this true to show debug lines for portals.  This will draw "
+          "lines from the screen corners to the portal corners, this can "
+          "be useful when debugging."));
+
 ConfigVariableBool unambiguous_graph
 ("unambiguous-graph", false,
  PRC_DESC("Set this true to make ambiguous path warning messages generate an "

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

@@ -34,6 +34,7 @@ NotifyCategoryDecl(portal, EXPCL_PANDA_PGRAPH, EXPTP_PANDA_PGRAPH);
 extern ConfigVariableBool fake_view_frustum_cull;
 extern ConfigVariableBool clip_plane_cull;
 extern ConfigVariableBool allow_portal_cull;
+extern ConfigVariableBool show_portal_debug;
 extern ConfigVariableBool unambiguous_graph;
 extern ConfigVariableBool detect_graph_cycles;
 extern ConfigVariableBool no_unsupported_copy;

+ 9 - 4
panda/src/pgraph/cullTraverser.cxx

@@ -12,6 +12,7 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+#include "config_pgraph.h"
 #include "cullTraverser.h"
 #include "cullTraverserData.h"
 #include "transformState.h"
@@ -132,9 +133,11 @@ traverse(const NodePath &root) {
       
     // This local_frustum is in camera space
     PortalClipper portal_viewer(local_frustum, _scene_setup);
-    portal_viewer.draw_camera_frustum();
+    if (show_portal_debug) {
+      portal_viewer.draw_camera_frustum();
+    }
     
-    // store this pointer in this
+    // Store this pointer in this
     set_portal_clipper(&portal_viewer);
 
     CullTraverserData data(root, TransformState::make_identity(),
@@ -143,8 +146,10 @@ traverse(const NodePath &root) {
     
     traverse(data);
     
-    // finally add the lines to be drawn
-    portal_viewer.draw_lines();
+    // Finally add the lines to be drawn
+    if (show_portal_debug) {
+      portal_viewer.draw_lines();
+    }
     
     // Render the frustum relative to the cull center.
     NodePath cull_center = _scene_setup->get_cull_center();