From ff5e3de5da31869dd9c238794ffabf3822e09c62 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 16 May 2002 00:54:08 +0000 Subject: [PATCH] m-dual-flash --- panda/src/pgraph/config_pgraph.cxx | 2 ++ panda/src/pgraph/config_pgraph.h | 1 + panda/src/pgraph/cullResult.cxx | 33 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 491ac395ed..5e995663cc 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/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); // Set this false to disable just the transparent part of M_dual. 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 diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 5ec9d0c74e..0db6abc54a 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/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_opaque; extern const bool m_dual_transparent; +extern const bool m_dual_flash; extern EXPCL_PANDA void init_libpgraph(); diff --git a/panda/src/pgraph/cullResult.cxx b/panda/src/pgraph/cullResult.cxx index ac262ee971..a2ca41b96b 100644 --- a/panda/src/pgraph/cullResult.cxx +++ b/panda/src/pgraph/cullResult.cxx @@ -21,6 +21,7 @@ #include "alphaTestAttrib.h" #include "transparencyAttrib.h" #include "renderState.h" +#include "clockObject.h" //////////////////////////////////////////////////////////////////// // Function: CullResult::make_next @@ -209,6 +210,10 @@ get_binary_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 // Access: Private @@ -223,6 +228,20 @@ get_dual_transparent_state() { TransparencyAttrib::make(TransparencyAttrib::M_alpha), 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; } @@ -240,5 +259,19 @@ get_dual_opaque_state() { TransparencyAttrib::make(TransparencyAttrib::M_none), 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; }