Browse Source

egg-rename tool had a bug: it needs to rename the eggnodes as well, not just the group nodes

Asad M. Zaman 20 years ago
parent
commit
b629960ae4
3 changed files with 26 additions and 0 deletions
  1. 4 0
      panda/src/egg/eggGroupNode.cxx
  2. 20 0
      panda/src/egg/eggNode.cxx
  3. 2 0
      panda/src/egg/eggNode.h

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

@@ -829,6 +829,10 @@ rename_nodes(vector_string strip_prefix, bool recurse) {
         EggGroupNode *group_child = DCAST(EggGroupNode, *ci);
         num_renamed += group_child->rename_nodes(strip_prefix, recurse);
       }
+      else if ((*ci)->is_of_type(EggNode::get_class_type())) {
+        EggNode *node_child = DCAST(EggNode, *ci);
+        num_renamed += node_child->rename_node(strip_prefix);
+      }
     }
   }
   return num_renamed;

+ 20 - 0
panda/src/egg/eggNode.cxx

@@ -31,6 +31,26 @@ extern int eggyyparse();
 TypeHandle EggNode::_type_handle;
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: EggNode::rename_node
+//       Access: Published
+//  Description: Rename by stripping out the prefix
+////////////////////////////////////////////////////////////////////
+int EggNode::
+rename_node(vector_string strip_prefix) {
+  int num_renamed = 0;
+  for (unsigned int ni = 0; ni < strip_prefix.size(); ++ni) {
+    string axe_name = strip_prefix[ni];
+    if (this->get_name().substr(0, axe_name.size()) == axe_name) {
+      string new_name = this->get_name().substr(axe_name.size());
+      //cout << "renaming " << this->get_name() << "->" << new_name << endl;
+      this->set_name(new_name);
+      num_renamed += 1;
+    }
+  }
+  return num_renamed;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: EggNode::apply_texmats
 //       Access: Public

+ 2 - 0
panda/src/egg/eggNode.h

@@ -70,6 +70,8 @@ PUBLISHED:
   INLINE void flatten_transforms();
   void apply_texmats();
 
+  int rename_node(vector_string strip_prefix);
+
   virtual bool is_joint() const;
   virtual bool is_anim_matrix() const;