Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
c3e650dcb1

+ 8 - 9
panda/src/egg/eggData.cxx

@@ -296,15 +296,6 @@ pre_write() {
   textures.uniquify_trefs();
   textures.uniquify_trefs();
   textures.sort_by_tref();
   textures.sort_by_tref();
 
 
-  // Now put them all back at the head of the file, after any initial
-  // comment records.
-  iterator ci = begin();
-  while (ci != end() && (*ci)->is_of_type(EggComment::get_class_type())) {
-    ++ci;
-  }
-
-  textures.insert_textures(this, ci);
-
   // Do the same thing with the materials.
   // Do the same thing with the materials.
   EggMaterialCollection materials;
   EggMaterialCollection materials;
   materials.extract_materials(this);
   materials.extract_materials(this);
@@ -312,6 +303,14 @@ pre_write() {
   materials.collapse_equivalent_materials(~0, this);
   materials.collapse_equivalent_materials(~0, this);
   materials.uniquify_mrefs();
   materials.uniquify_mrefs();
   materials.sort_by_mref();
   materials.sort_by_mref();
+
+  // Now put them all back at the head of the file, after any initial
+  // comment records.
+  iterator ci = begin();
+  while (ci != end() && (*ci)->is_of_type(EggComment::get_class_type())) {
+    ++ci;
+  }
+  textures.insert_textures(this, ci);
   materials.insert_materials(this, ci);
   materials.insert_materials(this, ci);
 
 
   // Also make sure that the vertex pools are uniquely named.  This
   // Also make sure that the vertex pools are uniquely named.  This

+ 2 - 0
panda/src/egg/eggGroupNode.cxx

@@ -961,6 +961,7 @@ r_resolve_externals(const DSearchPath &searchpath,
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void EggGroupNode::
 void EggGroupNode::
 prepare_add_child(EggNode *node) {
 prepare_add_child(EggNode *node) {
+  nassertv(node != (EggNode *)NULL);
   // Make sure the node is not already a child of some other group.
   // Make sure the node is not already a child of some other group.
   nassertv(node->get_parent() == NULL);
   nassertv(node->get_parent() == NULL);
   nassertv(node->get_depth() == 0);
   nassertv(node->get_depth() == 0);
@@ -983,6 +984,7 @@ prepare_add_child(EggNode *node) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void EggGroupNode::
 void EggGroupNode::
 prepare_remove_child(EggNode *node) {
 prepare_remove_child(EggNode *node) {
+  nassertv(node != (EggNode *)NULL);
   // Make sure the node is in fact a child of this group.
   // Make sure the node is in fact a child of this group.
   nassertv(node->get_parent() == this);
   nassertv(node->get_parent() == this);
   nassertv(node->get_depth() == get_depth() + 1);
   nassertv(node->get_depth() == get_depth() + 1);

+ 9 - 8
panda/src/egg/eggMaterialCollection.cxx

@@ -76,10 +76,10 @@ extract_materials(EggGroupNode *node) {
 //       Access: Public
 //       Access: Public
 //  Description: Adds a series of EggMaterial nodes to the beginning of
 //  Description: Adds a series of EggMaterial nodes to the beginning of
 //               the indicated node to reflect each of the materials in
 //               the indicated node to reflect each of the materials in
-//               the collection.  Returns the number of material nodes
-//               added.
+//               the collection.  Returns an iterator representing the
+//               first position after the newly inserted materials.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-int EggMaterialCollection::
+EggGroupNode::iterator EggMaterialCollection::
 insert_materials(EggGroupNode *node) {
 insert_materials(EggGroupNode *node) {
   return insert_materials(node, node->begin());
   return insert_materials(node, node->begin());
 }
 }
@@ -89,19 +89,20 @@ insert_materials(EggGroupNode *node) {
 //       Access: Public
 //       Access: Public
 //  Description: Adds a series of EggMaterial nodes to the beginning of
 //  Description: Adds a series of EggMaterial nodes to the beginning of
 //               the indicated node to reflect each of the materials in
 //               the indicated node to reflect each of the materials in
-//               the collection.  Returns the number of material nodes
-//               added.
+//               the collection.  Returns an iterator representing the
+//               first position after the newly inserted materials.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-int EggMaterialCollection::
+EggGroupNode::iterator EggMaterialCollection::
 insert_materials(EggGroupNode *node, EggGroupNode::iterator position) {
 insert_materials(EggGroupNode *node, EggGroupNode::iterator position) {
   OrderedMaterials::iterator oti;
   OrderedMaterials::iterator oti;
   for (oti = _ordered_materials.begin(); 
   for (oti = _ordered_materials.begin(); 
        oti != _ordered_materials.end(); 
        oti != _ordered_materials.end(); 
        ++oti) {
        ++oti) {
-    node->insert(position, (*oti).p());
+    EggMaterial *material = (*oti);
+    position = node->insert(position, material);
   }
   }
 
 
-  return size();
+  return position;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 2 - 2
panda/src/egg/eggMaterialCollection.h

@@ -50,8 +50,8 @@ public:
   void clear();
   void clear();
 
 
   int extract_materials(EggGroupNode *node);
   int extract_materials(EggGroupNode *node);
-  int insert_materials(EggGroupNode *node);
-  int insert_materials(EggGroupNode *node, EggGroupNode::iterator position);
+  EggGroupNode::iterator insert_materials(EggGroupNode *node);
+  EggGroupNode::iterator insert_materials(EggGroupNode *node, EggGroupNode::iterator position);
 
 
   int find_used_materials(EggNode *node);
   int find_used_materials(EggNode *node);
   void remove_unused_materials(EggNode *node);
   void remove_unused_materials(EggNode *node);

+ 3 - 1
panda/src/egg/eggNameUniquifier.cxx

@@ -75,7 +75,9 @@ uniquify(EggNode *node) {
 
 
     EggGroupNode::iterator ci;
     EggGroupNode::iterator ci;
     for (ci = group->begin(); ci != group->end(); ++ci) {
     for (ci = group->begin(); ci != group->end(); ++ci) {
-      uniquify(*ci);
+      EggNode *child = (*ci);
+      nassertv(child != (EggNode *)NULL);
+      uniquify(child);
     }
     }
   }
   }
 }
 }

+ 9 - 8
panda/src/egg/eggTextureCollection.cxx

@@ -76,10 +76,10 @@ extract_textures(EggGroupNode *node) {
 //       Access: Public
 //       Access: Public
 //  Description: Adds a series of EggTexture nodes to the beginning of
 //  Description: Adds a series of EggTexture nodes to the beginning of
 //               the indicated node to reflect each of the textures in
 //               the indicated node to reflect each of the textures in
-//               the collection.  Returns the number of texture nodes
-//               added.
+//               the collection.  Returns an iterator representing the
+//               first position after the newly inserted textures.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-int EggTextureCollection::
+EggGroupNode::iterator EggTextureCollection::
 insert_textures(EggGroupNode *node) {
 insert_textures(EggGroupNode *node) {
   return insert_textures(node, node->begin());
   return insert_textures(node, node->begin());
 }
 }
@@ -89,19 +89,20 @@ insert_textures(EggGroupNode *node) {
 //       Access: Public
 //       Access: Public
 //  Description: Adds a series of EggTexture nodes to the beginning of
 //  Description: Adds a series of EggTexture nodes to the beginning of
 //               the indicated node to reflect each of the textures in
 //               the indicated node to reflect each of the textures in
-//               the collection.  Returns the number of texture nodes
-//               added.
+//               the collection.  Returns an iterator representing the
+//               first position after the newly inserted textures.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-int EggTextureCollection::
+EggGroupNode::iterator EggTextureCollection::
 insert_textures(EggGroupNode *node, EggGroupNode::iterator position) {
 insert_textures(EggGroupNode *node, EggGroupNode::iterator position) {
   OrderedTextures::iterator oti;
   OrderedTextures::iterator oti;
   for (oti = _ordered_textures.begin(); 
   for (oti = _ordered_textures.begin(); 
        oti != _ordered_textures.end(); 
        oti != _ordered_textures.end(); 
        ++oti) {
        ++oti) {
-    node->insert(position, (*oti).p());
+    EggTexture *texture = (*oti);
+    position = node->insert(position, texture);
   }
   }
 
 
-  return size();
+  return position;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 2 - 2
panda/src/egg/eggTextureCollection.h

@@ -50,8 +50,8 @@ public:
   void clear();
   void clear();
 
 
   int extract_textures(EggGroupNode *node);
   int extract_textures(EggGroupNode *node);
-  int insert_textures(EggGroupNode *node);
-  int insert_textures(EggGroupNode *node, EggGroupNode::iterator position);
+  EggGroupNode::iterator insert_textures(EggGroupNode *node);
+  EggGroupNode::iterator insert_textures(EggGroupNode *node, EggGroupNode::iterator position);
 
 
   int find_used_textures(EggNode *node);
   int find_used_textures(EggNode *node);
   void remove_unused_textures(EggNode *node);
   void remove_unused_textures(EggNode *node);