Browse Source

m-dual-flash

David Rose 23 years ago
parent
commit
ff5e3de5da

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

@@ -96,6 +96,8 @@ const bool m_dual = config_pgraph.GetBool("m-dual", true);
 const bool m_dual_opaque = config_pgraph.GetBool("m-dual-opaque", true);
 const bool m_dual_opaque = config_pgraph.GetBool("m-dual-opaque", true);
 // Set this false to disable just the transparent part of M_dual.
 // Set this false to disable just the transparent part of M_dual.
 const bool m_dual_transparent = config_pgraph.GetBool("m-dual-transparent", true);
 const bool m_dual_transparent = config_pgraph.GetBool("m-dual-transparent", true);
+// Set this true to flash any objects that use M_dual, for debugging.
+const bool m_dual_flash = config_pgraph.GetBool("m-dual-flash", false);
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libpgraph
 //     Function: init_libpgraph

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

@@ -32,6 +32,7 @@ extern const bool unambiguous_graph;
 extern const bool m_dual;
 extern const bool m_dual;
 extern const bool m_dual_opaque;
 extern const bool m_dual_opaque;
 extern const bool m_dual_transparent;
 extern const bool m_dual_transparent;
+extern const bool m_dual_flash;
 
 
 extern EXPCL_PANDA void init_libpgraph();
 extern EXPCL_PANDA void init_libpgraph();
 
 

+ 33 - 0
panda/src/pgraph/cullResult.cxx

@@ -21,6 +21,7 @@
 #include "alphaTestAttrib.h"
 #include "alphaTestAttrib.h"
 #include "transparencyAttrib.h"
 #include "transparencyAttrib.h"
 #include "renderState.h"
 #include "renderState.h"
+#include "clockObject.h"
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CullResult::make_next
 //     Function: CullResult::make_next
@@ -209,6 +210,10 @@ get_binary_state() {
   return state;
   return state;
 }
 }
 
 
+#ifndef NDEBUG
+static const double m_dual_flash_rate = 1.0;  // 1 state change per second
+#endif
+
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 //     Function: CullResult::get_dual_transparent_state
 //     Function: CullResult::get_dual_transparent_state
 //       Access: Private
 //       Access: Private
@@ -223,6 +228,20 @@ get_dual_transparent_state() {
                               TransparencyAttrib::make(TransparencyAttrib::M_alpha),
                               TransparencyAttrib::make(TransparencyAttrib::M_alpha),
                               RenderState::get_max_priority());
                               RenderState::get_max_priority());
   }
   }
+
+#ifndef NDEBUG
+  if (m_dual_flash) {
+    int cycle = (int)(ClockObject::get_global_clock()->get_real_time() * m_dual_flash_rate);
+    if ((cycle & 1) == 0) {
+      static CPT(RenderState) flash_state = NULL;
+      if (flash_state == (const RenderState *)NULL) {
+        flash_state = state->add_attrib(ColorScaleAttrib::make(LVecBase4f(0.8f, 0.2f, 0.2f, 1.0f)));
+      }
+      return flash_state;
+    }
+  }
+#endif  // NDEBUG
+
   return state;
   return state;
 }
 }
 
 
@@ -240,5 +259,19 @@ get_dual_opaque_state() {
                               TransparencyAttrib::make(TransparencyAttrib::M_none),
                               TransparencyAttrib::make(TransparencyAttrib::M_none),
                               RenderState::get_max_priority());
                               RenderState::get_max_priority());
   }
   }
+
+#ifndef NDEBUG
+  if (m_dual_flash) {
+    int cycle = (int)(ClockObject::get_global_clock()->get_real_time() * m_dual_flash_rate);
+    if ((cycle & 1) == 0) {
+      static CPT(RenderState) flash_state = NULL;
+      if (flash_state == (const RenderState *)NULL) {
+        flash_state = state->add_attrib(ColorScaleAttrib::make(LVecBase4f(0.2f, 0.2f, 0.8f, 1.0f)));
+      }
+      return flash_state;
+    }
+  }
+#endif  // NDEBUG
+
   return state;
   return state;
 }
 }