From 9c2cc81fc9f1680e17d088c44de583a768005bd7 Mon Sep 17 00:00:00 2001 From: alteredq Date: Thu, 17 Mar 2011 15:43:47 +0100 Subject: [PATCH] Added to OBJ converter warning and skipping of morphs with different numbers of vertices than the original model. --- utils/exporters/convert_obj_threejs_slim.py | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/utils/exporters/convert_obj_threejs_slim.py b/utils/exporters/convert_obj_threejs_slim.py index 95249e3baf..b31241adb9 100644 --- a/utils/exporters/convert_obj_threejs_slim.py +++ b/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): -- GitLab