Browse Source

discard unused uvsets unless requested by the keep-all-uvsets in Maya

Asad M. Zaman 20 years ago
parent
commit
879329de0e
1 changed files with 15 additions and 0 deletions
  1. 15 0
      pandatool/src/mayaegg/mayaToEggConverter.cxx

+ 15 - 0
pandatool/src/mayaegg/mayaToEggConverter.cxx

@@ -1744,6 +1744,10 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path,
     }
     }
   }
   }
 
 
+  bool keep_all_uvsets = egg_group->has_object_type("keep-all-uvsets");
+  if (keep_all_uvsets)
+    mayaegg_cat.info() << "will keep_all_uvsets" << endl;
+
   MStringArray maya_uvset_names;
   MStringArray maya_uvset_names;
   status = mesh.getUVSetNames(maya_uvset_names);
   status = mesh.getUVSetNames(maya_uvset_names);
   if (!status) {
   if (!status) {
@@ -1871,13 +1875,24 @@ make_polyset(MayaNodeDesc *node_desc, const MDagPath &dag_path,
             colordef_uv_name = "default";
             colordef_uv_name = "default";
 
 
           // get the shader color def that matches this EggTexture
           // get the shader color def that matches this EggTexture
+          // Asad: optimizing uvset: to discard unused uvsets. This for 
+          // loop figures out which ones are unused.
+          // 
+          bool found = false;
           for (size_t tj=0; tj< shader->_color.size(); ++tj) {
           for (size_t tj=0; tj< shader->_color.size(); ++tj) {
             color_def = shader->get_color_def(tj);
             color_def = shader->get_color_def(tj);
             if (color_def->_uvset_name == colordef_uv_name) {
             if (color_def->_uvset_name == colordef_uv_name) {
               mayaegg_cat.debug() << "matched colordef idx: " << tj << endl;
               mayaegg_cat.debug() << "matched colordef idx: " << tj << endl;
+              found = true;
               break;
               break;
             }
             }
           }
           }
+          // if uvset is not used don't add it to the vertex
+          if (!found && !keep_all_uvsets) {
+            mayaegg_cat.spam() << "discarding unused uvset " << uvset_name << endl;
+            continue;
+          }
+
           mayaegg_cat.debug() << "color_def->uvset_name :" << color_def->_uvset_name << endl;
           mayaegg_cat.debug() << "color_def->uvset_name :" << color_def->_uvset_name << endl;
           if (color_def->has_projection()) {
           if (color_def->has_projection()) {
             // If the shader has a projection, use it instead of the
             // If the shader has a projection, use it instead of the