From 259ce0f3e3e4ff85315603a6e659225cd1cbbb4c Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 13 Apr 2007 23:05:06 +0000 Subject: [PATCH] fix bug in --- panda/src/egg/eggGroupNode.cxx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/panda/src/egg/eggGroupNode.cxx b/panda/src/egg/eggGroupNode.cxx index 32c2dcfdd0..4d3ad85fb8 100644 --- a/panda/src/egg/eggGroupNode.cxx +++ b/panda/src/egg/eggGroupNode.cxx @@ -1228,29 +1228,22 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, vertices.push_back(*pi); } + typedef pvector Attributes; + Attributes attributes; + if (prim->is_of_type(EggCompositePrimitive::get_class_type())) { // A compositive primitive has the additional complication of // dealing with its attributes. - typedef pvector Attributes; - Attributes attributes; - EggCompositePrimitive *cprim = DCAST(EggCompositePrimitive, prim); int i; int num_components = cprim->get_num_components(); for (i = 0; i < num_components; i++) { attributes.push_back(*cprim->get_component(i)); } - - cprim->clear(); - - for (i = 0; i < num_components; i++) { - cprim->set_component(i, &attributes[i]); - } - - } else { - prim->clear(); } + prim->clear(); + // Now look for a new home for the vertices. First, see if any // of the vertex pools we've already created already have a copy // of each one of the vertices. @@ -1326,6 +1319,17 @@ rebuild_vertex_pools(EggVertexPools &vertex_pools, unsigned int max_vertices, nassertv(new_vertex != (EggVertex *)NULL); prim->add_vertex(new_vertex); } + + if (prim->is_of_type(EggCompositePrimitive::get_class_type())) { + // Now restore the composite attributes. + EggCompositePrimitive *cprim = DCAST(EggCompositePrimitive, prim); + int i; + int num_components = cprim->get_num_components(); + nassertv(num_components == (int)attributes.size()); + for (i = 0; i < num_components; i++) { + cprim->set_component(i, &attributes[i]); + } + } } else if (child->is_of_type(EggGroupNode::get_class_type())) { if (recurse) {