Skip to content

Commit

Permalink
Merge pull request makehumancommunity#130 from makehumancommunity/_fe…
Browse files Browse the repository at this point in the history
…ature_proxy_correction

proposal to solve makehumancommunity#78, a solution between numpy and python.
  • Loading branch information
joepal1976 authored Oct 31, 2020
2 parents df25749 + bfee432 commit 00a955e
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions makehuman/shared/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,26 +966,20 @@ def transferVertexMaskToProxy(vertsMask, proxy):
that have all vertices hidden will be hidden.
True in vertex mask means: show vertex, false means hide (masked)
"""
# Convert basemesh vertex mask to local mask for proxy vertices
proxyVertMask = np.ones(len(proxy.ref_vIdxs), dtype=bool)

# Proxy verts that use exact mapping
# preset new mask to unhidden and calculate all the vertices which depend directly to base mesh
# (value 1.0, 0.0, 0.0 in weighting), create this mask with negation using np.any
masksize = len(proxy.ref_vIdxs)
proxyVertMask = np.ones(masksize, dtype=bool)
exact_mask = ~np.any(proxy.weights[:,1:], axis=1)

# Faster numpy implementation of the above:
unmasked_row_col = np.nonzero(vertsMask[proxy.ref_vIdxs])
unmasked_rows = unmasked_row_col[0]
if len(unmasked_rows) > 0:
unmasked_count = np.bincount(unmasked_rows) # count number of unmasked verts per row
# only hide/mask a vertex if at least two referenced body verts are hidden/masked
masked_idxs = np.nonzero(unmasked_count < 2)
proxyVertMask[masked_idxs] = False
else:
# All verts are masked
proxyVertMask[:] = False

# Directly map exactly mapped proxy verts
proxyVertMask[exact_mask] = vertsMask[proxy.ref_vIdxs[exact_mask,0]]
# now set values according to mask
for c in range(masksize):
p = proxy.ref_vIdxs[c]
if exact_mask[c]:
proxyVertMask[c] = vertsMask[p[0]]
else:
if (int(vertsMask[p[0]]) + int(vertsMask[p[1]]) + int(vertsMask[p[2]])) < 2:
proxyVertMask[c] = False # at least two visible Reference

return proxyVertMask

Expand Down

0 comments on commit 00a955e

Please sign in to comment.