Browse Source

fix bug in <lines>

David Rose 18 years ago
parent
commit
259ce0f3e3
1 changed files with 16 additions and 12 deletions
  1. 16 12
      panda/src/egg/eggGroupNode.cxx

+ 16 - 12
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<EggAttributes> 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<EggAttributes> 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) {