diff --git a/__init__.py b/__init__.py index 088747d..dba41cf 100644 --- a/__init__.py +++ b/__init__.py @@ -29,7 +29,7 @@ bl_info = { "name": "CharMorph", "author": "Michael Vigovsky", - "version": (0, 2, 9), + "version": (0, 3, 0), "blender": (2, 83, 0), "location": "View3D > Tools > CharMorph", "description": "Character creation and morphing, cloth fitting and rigging tools", diff --git a/cmedit/__init__.py b/cmedit/__init__.py index b311f4e..05099a3 100644 --- a/cmedit/__init__.py +++ b/cmedit/__init__.py @@ -361,12 +361,16 @@ def normalize(v): continue v2 = counterpart_vertex(mesh.vertices, kd, v) if v2 is None: + print("no counterpart", v.index) continue gdict = {obj.vertex_groups[g.group].name: g for g in v2.groups} wgt2 = 0 #cleanup groups without counterparts before normalizing for g in v.groups: + if g.group > len(obj.vertex_groups) or g.group < 0: + print("bad vg id", v.index, g.group) + continue vg = obj.vertex_groups[g.group] g2e = gdict.get(swap_l_r(vg.name)) if g2e: @@ -400,8 +404,8 @@ def normalize(v): return {"FINISHED"} if abs(g1e.weight-g2w) >= 0.00001: - if not is_deform(g2name): - print("Normalizing non-deform", v.index, v2.index, g2name) + #if not is_deform(g2name): + # print("Normalizing non-deform", v.index, v2.index, g2name) #print("Normalizing", v.index, v2.index, g1e.weight, g2w, wgt2, g2name) if v2.select: wgt = (g1e.weight+g2w)/2 diff --git a/cmedit/file_io.py b/cmedit/file_io.py index 720c1ba..a9b0081 100644 --- a/cmedit/file_io.py +++ b/cmedit/file_io.py @@ -109,6 +109,9 @@ def execute(self, context): def float_dtype(context): return numpy.float64 if context.window_manager.cmedit_ui.morph_float_precicion == "64" else numpy.float32 +def flatten(arr, dtype): + return numpy.block([numpy.array(item, dtype=dtype) for item in arr]) + class OpVgExport(bpy.types.Operator, bpy_extras.io_utils.ExportHelper): bl_idname = "cmedit.vg_export" bl_label = "Export VGs" @@ -129,8 +132,8 @@ def execute(self, context): numpy.savez_compressed(self.filepath, names=b'\0'.join(name.encode("utf-8") for name in names), cnt=numpy.array(cnt, dtype=numpy.uint16 if max(cnt) > 255 else numpy.uint8), - idx=numpy.array(idx, dtype=numpy.uint16), - weights=numpy.array(weights, dtype = float_dtype(context)) + idx=flatten(idx, numpy.uint16), + weights=flatten(weights, float_dtype(context)) ) return {"FINISHED"} diff --git a/data b/data index 6e7dd22..4a87f25 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 6e7dd22647bd824731d98265546591c0087f496a +Subproject commit 4a87f25213551be080b24182ba36aecebadfe6be