Browse Source

add m-dual* Configrc variables

David Rose 23 years ago
parent
commit
e86a87f2d8

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

@@ -89,6 +89,14 @@ const bool fake_view_frustum_cull = config_pgraph.GetBool("fake-view-frustum-cul
 // trapped with assert-abort).
 const bool unambiguous_graph = config_pgraph.GetBool("unambiguous-graph", false);
 
+// Set this false to disable TransparencyAttrib::M_dual altogether
+// (and use M_alpha in its place).
+const bool m_dual = config_pgraph.GetBool("m-dual", true);
+// Set this false to disable just the opaque part of M_dual.
+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);
+
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libpgraph
 //  Description: Initializes the library.  This must be called at

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

@@ -29,6 +29,10 @@ NotifyCategoryDecl(pgraph, EXPCL_PANDA, EXPTP_PANDA);
 extern const bool fake_view_frustum_cull;
 extern const bool unambiguous_graph;
 
+extern const bool m_dual;
+extern const bool m_dual_opaque;
+extern const bool m_dual_transparent;
+
 extern EXPCL_PANDA void init_libpgraph();
 
 #endif

+ 17 - 6
panda/src/pgraph/cullResult.cxx

@@ -69,7 +69,7 @@ add_object(CullableObject *object) {
       break;
 
     case TransparencyAttrib::M_dual:
-      {
+      if (m_dual) {
         // M_dual is implemented by drawing the opaque parts first,
         // without transparency, then drawing the transparent parts
         // later.  This means we must copy the object and add it to
@@ -81,15 +81,26 @@ add_object(CullableObject *object) {
             bin_attrib->get_bin_name().empty()) {
           // We make a copy of the object to draw the transparent part
           // without decals; this gets placed in the transparent bin.
-          CullableObject *transparent_part = new CullableObject(*object);
-          transparent_part->_state = state->compose(get_dual_transparent_state());
-          CullBin *bin = get_bin(transparent_part->_state->get_bin_index());
-          nassertv(bin != (CullBin *)NULL);
-          bin->add_object(transparent_part);
+#ifndef NDEBUG
+          if (m_dual_transparent) 
+#endif
+          {
+            CullableObject *transparent_part = new CullableObject(*object);
+            transparent_part->_state = state->compose(get_dual_transparent_state());
+            CullBin *bin = get_bin(transparent_part->_state->get_bin_index());
+            nassertv(bin != (CullBin *)NULL);
+            bin->add_object(transparent_part);
+          }
 
           // Now we can draw the opaque part, with decals.  This will
           // end up in the opaque bin.
           object->_state = state->compose(get_dual_opaque_state());
+#ifndef NDEBUG
+          if (!m_dual_opaque) {
+            delete object;
+            return;
+          }
+#endif
         }
       }
       break;