فهرست منبع

Added to OBJ converter warning and skipping of morphs with different numbers of vertices than the original model.

alteredq 15 سال پیش
والد
کامیت
9c2cc81fc9
1فایلهای تغییر یافته به همراه15 افزوده شده و 9 حذف شده
  1. 15 9
      utils/exporters/convert_obj_threejs_slim.py

+ 15 - 9
utils/exporters/convert_obj_threejs_slim.py

@@ -817,6 +817,8 @@ def convert_ascii(infile, morphfiles, outfile):
     elif ALIGN == "top":
         top(vertices)
     
+    n_vertices = len(vertices)
+    
     normals_string = ""
     if SHADING == "smooth":
         normals_string = ",".join(generate_normal(n) for n in normals)
@@ -835,15 +837,19 @@ def convert_ascii(infile, morphfiles, outfile):
                 
                 morphFaces, morphVertices, morphUvs, morphNormals, morphMaterials, morphMtllib = parse_obj(normpath)
                 
-                if ALIGN == "center":
-                    center(morphVertices)
-                elif ALIGN == "bottom":
-                    bottom(morphVertices)
-                elif ALIGN == "top":
-                    top(morphVertices)
-                    
-                morphData.append((get_name(name), morphVertices ))
-                print name, len(morphVertices)
+                n_morph_vertices = len(morphVertices)
+                if n_vertices != n_morph_vertices:
+                    print "WARNING: skipping morph [%s] with different number of vertices [%d] than the original model [%d]" % (name, n_morph_vertices, n_vertices)
+                else:                    
+                    if ALIGN == "center":
+                        center(morphVertices)
+                    elif ALIGN == "bottom":
+                        bottom(morphVertices)
+                    elif ALIGN == "top":
+                        top(morphVertices)
+                        
+                    morphData.append((get_name(name), morphVertices ))
+                    print "adding [%s] with %d vertices" % (name, len(morphVertices))
     
     morphTargets = ""
     if len(morphData):