2
0
Эх сурвалжийг харах

Fix state attribs at primitive level in bam2egg; also prevent duplication of state attribs at primitive level if possible

rdb 9 жил өмнө
parent
commit
c9ea02445e

+ 2 - 0
panda/src/egg/eggPrimitive.I

@@ -27,6 +27,7 @@ INLINE EggPrimitive::
 EggPrimitive(const EggPrimitive &copy) :
 EggPrimitive(const EggPrimitive &copy) :
   EggNode(copy),
   EggNode(copy),
   EggAttributes(copy),
   EggAttributes(copy),
+  EggRenderMode(copy),
   _textures(copy._textures),
   _textures(copy._textures),
   _material(copy._material),
   _material(copy._material),
   _bface(copy._bface)
   _bface(copy._bface)
@@ -42,6 +43,7 @@ INLINE EggPrimitive &EggPrimitive::
 operator = (const EggPrimitive &copy) {
 operator = (const EggPrimitive &copy) {
   EggNode::operator = (copy);
   EggNode::operator = (copy);
   EggAttributes::operator = (copy);
   EggAttributes::operator = (copy);
+  EggRenderMode::operator = (copy);
   copy_vertices(copy);
   copy_vertices(copy);
   _textures = copy._textures;
   _textures = copy._textures;
   _material = copy._material;
   _material = copy._material;

+ 9 - 0
panda/src/egg2pg/eggSaver.cxx

@@ -640,6 +640,15 @@ convert_geom_node(GeomNode *node, const WorkingNodePath &node_path,
     CPT(RenderState) geom_state = node->get_geom_state(i);
     CPT(RenderState) geom_state = node->get_geom_state(i);
     CPT(RenderState) geom_net_state = net_state->compose(geom_state);
     CPT(RenderState) geom_net_state = net_state->compose(geom_state);
 
 
+    // If there is only one Geom, and the node has no state, apply the state
+    // attributes from the Geom to the group instead, so that we don't end up
+    // duplicating it for a lot of primitives.
+    if (num_geoms == 1 && node->get_num_children() == 0 && egg_parent == egg_group &&
+        !geom_state->is_empty() && node->get_state()->is_empty()) {
+      apply_state_properties(egg_group, geom_state);
+      geom_state = RenderState::make_empty();
+    }
+
     const Geom *geom = node->get_geom(i);
     const Geom *geom = node->get_geom(i);
     int num_primitives = geom->get_num_primitives();
     int num_primitives = geom->get_num_primitives();
     for (int j = 0; j < num_primitives; ++j) {
     for (int j = 0; j < num_primitives; ++j) {