Răsfoiți Sursa

fixed the dogLL pupil not animating problem and and crash bug with earlier morph check in

Asad M. Zaman 22 ani în urmă
părinte
comite
d1b2691371

+ 21 - 1
pandatool/src/softegg/softNodeDesc.cxx

@@ -121,6 +121,26 @@ set_parent(SoftNodeDesc *parent) {
   _parent->_children.push_back(this);
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: SoftNodeDesc::set_parent
+//       Access: Public
+//  Description: Sometimes, parent is not known at node creation
+//               As soon as it is known, set the parent
+////////////////////////////////////////////////////////////////////
+void SoftNodeDesc::
+force_set_parent(SoftNodeDesc *parent) {
+  if (_parent)
+    softegg_cat.spam() << " current parent " << _parent->get_name();
+
+  _parent = parent;
+  
+  if (_parent)
+    softegg_cat.spam() << " new parent " << _parent->get_name() << endl;
+
+  // Add ourselves to our parent.
+  _parent->_children.push_back(this);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: SoftNodeDesc::has_model
 //       Access: Public
@@ -453,7 +473,7 @@ get_transform(SAA_Scene *scene, EggGroup *egg_group, bool global) {
 
   }
 
-  if (_parentJoint)
+  if (_parentJoint && !stec.flatten)
     softegg_cat.debug() << _parentJoint->get_name() << endl;
   else
     softegg_cat.debug() << _parentJoint << endl;

+ 1 - 0
pandatool/src/softegg/softNodeDesc.h

@@ -53,6 +53,7 @@ public:
   ~SoftNodeDesc();
 
   void set_parent(SoftNodeDesc *parent);
+  void force_set_parent(SoftNodeDesc *parent);
   void set_model(SAA_Elem *model);
   bool has_model() const;
   SAA_Elem *get_model() const;

+ 38 - 4
pandatool/src/softegg/softNodeTree.cxx

@@ -223,7 +223,12 @@ build_complete_hierarchy(SAA_Scene &scene, SAA_Database &database) {
   // find _parentJoint for each node
   _root->set_parentJoint(&scene, NULL);
 
-  softegg_cat.spam() << "========================================================\n";
+  /*
+  if (stec.flatten) {
+    softegg_cat.spam() << "rprprprprprprprprprprprprprprprprprprprprprprprprprprprpr\n";
+    reparent_flatten(_root);
+  }
+  */
 
   return all_ok;
 }
@@ -374,7 +379,7 @@ get_egg_group(SoftNodeDesc *node_desc) {
       egg_group->set_group_type(EggGroup::GT_joint);
     }
 
-    if (!node_desc->_parentJoint || node_desc->_parentJoint == _root) {
+    if (stec.flatten || (!node_desc->_parentJoint || node_desc->_parentJoint == _root)) {
       // The parent is the root.
       softegg_cat.spam() << "came hereeeee\n";
       _egg_root->add_child(egg_group);
@@ -420,7 +425,7 @@ get_egg_table(SoftNodeDesc *node_desc) {
     node_desc->_anim->set_fps(_fps);
     egg_table->add_child(node_desc->_anim);
     
-    if (!node_desc->_parentJoint || node_desc->_parentJoint == _root) {
+    if (stec.flatten || (!node_desc->_parentJoint || node_desc->_parentJoint == _root)) {
       //    if (!node_desc->_parent->is_joint()) {
       // The parent is not a joint; put it at the top.
       _skeleton_node->add_child(egg_table);
@@ -595,10 +600,12 @@ r_build_node(SoftNodeDesc *parent_node, const string &name) {
   if (ni != _nodes_by_name.end()) {
     softegg_cat.spam() << "  already built node " << (*ni).first;
     node_desc = (*ni).second;
-    
+
+    /*    
     if (stec.flatten)
       node_desc->set_parent(_root);
     else
+    */
       node_desc->set_parent(parent_node);
 
     return node_desc;
@@ -606,9 +613,11 @@ r_build_node(SoftNodeDesc *parent_node, const string &name) {
 
   // Otherwise, we have to create it.  Do this recursively, so we
   // create each node along the path.
+  /*
   if (stec.flatten)
     node_desc = new SoftNodeDesc(_root, name);
   else
+  */
     node_desc = new SoftNodeDesc(parent_node, name);
 
   softegg_cat.spam() << " node name : " << name << endl;
@@ -618,6 +627,31 @@ r_build_node(SoftNodeDesc *parent_node, const string &name) {
 
   return node_desc;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: SoftNodeTree::reparent_flatten
+//       Access: Private
+//  Description: recursively, reparent all nodes to root
+////////////////////////////////////////////////////////////////////
+void SoftNodeTree::
+reparent_flatten(SoftNodeDesc *node) {
+  // get a copy of the current childrens
+  SoftNodeDesc::Children old_children = node->_children;
+  // clear the _children to make room for new ones
+  node->_children.clear();
+
+  if (node != _root) {
+    softegg_cat.spam() << "reparenting " << node << ":" << node->get_name();
+    node->force_set_parent(_root);
+  }
+
+  SoftNodeDesc::Children::const_iterator ci;
+  for (ci = old_children.begin(); ci != old_children.end(); ++ci) {
+    SoftNodeDesc *child = (*ci);
+    reparent_flatten(child);
+  }
+
+}
 //
 //
 //

+ 1 - 0
pandatool/src/softegg/softNodeTree.h

@@ -73,6 +73,7 @@ private:
   EggGroupNode *_skeleton_node;
 
   SoftNodeDesc *r_build_node(SoftNodeDesc *parent_node, const string &path);
+  void reparent_flatten(SoftNodeDesc *node);
 
   typedef pmap<string, SoftNodeDesc *> NodesByName;
   NodesByName _nodes_by_name;

+ 7 - 10
pandatool/src/softegg/softToEggConverter.cxx

@@ -1223,11 +1223,10 @@ make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type) {
         }
       }
       }
+      // if model has key shapes, generate vertex offsets
+      if ( numShapes > 0 && make_morph )
+        node_desc->make_vertex_offsets( numShapes);
     }
-
-  // if model has key shapes, generate vertex offsets
-  if ( numShapes > 0 && make_morph )
-    node_desc->make_vertex_offsets( numShapes);
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -1498,11 +1497,11 @@ make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType ty
         else 
           softegg_cat.spam() << "texname :" << node_desc->texNameArray[0] << endl;
       }
-    }
 
-  // if model has key shapes, generate vertex offsets
-  if ( numShapes > 0 && make_morph )
-    node_desc->make_vertex_offsets( numShapes);
+      // if model has key shapes, generate vertex offsets
+      if ( numShapes > 0 && make_morph )
+        node_desc->make_vertex_offsets( numShapes);
+    }
 }
 
 ////////////////////////////////////////////////////////////////////
@@ -2006,7 +2005,6 @@ cleanup_soft_skin()
         // hard skin this vertex
         joint->ref_vertex( vert, 1.0f );
       }
-      /*
       else {    
         membership = joint->get_vertex_membership(vert);
         if ( membership == 0 ) {
@@ -2018,7 +2016,6 @@ cleanup_soft_skin()
           joint->ref_vertex( vert, 1.0f );
         }
       }
-      */
     }
   }
   return true;