Skip to content

Commit

Permalink
CharMorph 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Upliner committed Feb 24, 2022
1 parent bebd2c5 commit 6aee3d7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions cmedit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions cmedit/file_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"}
Expand Down

0 comments on commit 6aee3d7

Please sign in to comment.