Skip to content

Commit c9ea024

Browse files
committed
Fix state attribs at primitive level in bam2egg; also prevent duplication of state attribs at primitive level if possible
1 parent 7c79a99 commit c9ea024

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

panda/src/egg/eggPrimitive.I

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ INLINE EggPrimitive::
2727
EggPrimitive(const EggPrimitive &copy) :
2828
EggNode(copy),
2929
EggAttributes(copy),
30+
EggRenderMode(copy),
3031
_textures(copy._textures),
3132
_material(copy._material),
3233
_bface(copy._bface)
@@ -42,6 +43,7 @@ INLINE EggPrimitive &EggPrimitive::
4243
operator = (const EggPrimitive &copy) {
4344
EggNode::operator = (copy);
4445
EggAttributes::operator = (copy);
46+
EggRenderMode::operator = (copy);
4547
copy_vertices(copy);
4648
_textures = copy._textures;
4749
_material = copy._material;

panda/src/egg2pg/eggSaver.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,15 @@ convert_geom_node(GeomNode *node, const WorkingNodePath &node_path,
640640
CPT(RenderState) geom_state = node->get_geom_state(i);
641641
CPT(RenderState) geom_net_state = net_state->compose(geom_state);
642642

643+
// If there is only one Geom, and the node has no state, apply the state
644+
// attributes from the Geom to the group instead, so that we don't end up
645+
// duplicating it for a lot of primitives.
646+
if (num_geoms == 1 && node->get_num_children() == 0 && egg_parent == egg_group &&
647+
!geom_state->is_empty() && node->get_state()->is_empty()) {
648+
apply_state_properties(egg_group, geom_state);
649+
geom_state = RenderState::make_empty();
650+
}
651+
643652
const Geom *geom = node->get_geom(i);
644653
int num_primitives = geom->get_num_primitives();
645654
for (int j = 0; j < num_primitives; ++j) {

0 commit comments

Comments
 (0)