Bladeren bron

pgraph: Remove unused vertices during premunge phase

Disable with premunge-remove-unused-vertices config var - let me know if causes issues for you, performance or otherwise, though!
rdb 3 jaren geleden
bovenliggende
commit
fc8c07a949

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

@@ -290,6 +290,11 @@ ConfigVariableBool premunge_data
           "encoding requirements, as appropriate.  When this is false, the "
           "data will be munged at render time instead."));
 
+ConfigVariableBool premunge_remove_unused_vertices
+("premunge-remove-unused-vertices", true,
+ PRC_DESC("Set this true to remove unused vertices as part of the premunge "
+          "which occurs when models are loaded from disk."));
+
 ConfigVariableBool preserve_geom_nodes
 ("preserve-geom-nodes", false,
  PRC_DESC("This specifies the default value for the \"preserved\" flag on "

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

@@ -55,6 +55,7 @@ extern ConfigVariableBool depth_offset_decals;
 extern ConfigVariableInt max_collect_vertices;
 extern ConfigVariableInt max_collect_indices;
 extern EXPCL_PANDA_PGRAPH ConfigVariableBool premunge_data;
+extern ConfigVariableBool premunge_remove_unused_vertices;
 extern ConfigVariableBool preserve_geom_nodes;
 extern ConfigVariableBool flatten_geoms;
 extern EXPCL_PANDA_PGRAPH ConfigVariableInt max_lenses;

+ 3 - 0
panda/src/pgraph/geomNode.cxx

@@ -892,6 +892,9 @@ do_premunge(GraphicsStateGuardianBase *gsg,
       CPT(Geom) geom = entry._geom.get_read_pointer();
       PT(GeomMunger) munger = gsg->get_geom_munger(geom_state, current_thread);
       entry._geom = transformer.premunge_geom(geom, munger);
+      if (premunge_remove_unused_vertices) {
+        transformer.register_vertices(entry._geom.get_write_pointer(), true);
+      }
     }
   }
   CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler);

+ 1 - 0
panda/src/pgraph/sceneGraphReducer.I

@@ -176,5 +176,6 @@ premunge(PandaNode *root, const RenderState *initial_state) {
   if (_gsg != nullptr) {
     PStatTimer timer(_premunge_collector);
     r_premunge(root, initial_state);
+    _transformer.finish_apply();
   }
 }