feat(characters): four VRoid characters imported and selectable
Kiyoko, Hikari, Aria and Momo, all CC-BY from Sketchfab, licences recorded beside each skin. Seven GLB characters selectable now. kiyoko 13 meshes 20 cloth chains (62 bones) 0.0% cross-leg bleed aria 15 meshes 15 cloth chains (37 bones) 0.0% momo 5 meshes 9 cloth chains (35 bones) 0.0% hikari 13 meshes 10 cloth chains (37 bones) 0.2%, 12 twist bones These are the first characters imported that were NOT authored against the library's own bone spelling, and every one of them broke something that had been quietly wrong all along. All four failures were in code that guesses anatomy from names, which is exactly what tools/rig_map.py exists to stop doing: - LIMB ROLES went to the first role in LIMB_ORDER that matched at all, so shin's catch-all "leg" claimed UpperLeg before thigh's exact "upperleg" was ever consulted, and the thigh went unassigned. The result depended on the order bones arrived in. Claims are now granted longest-stem first. This also broke Mixamo (LeftUpLeg/LeftLeg) and had simply never been hit, because every character so far used Rigify DEF- names. - Names cannot settle thigh-vs-shin at all. A bare "leg" is the SHIN on Mixamo and the THIGH on a rig whose shin is "knee" — both common, same token, opposite bones. RigRoles now walks the leg from the foot upward and fills in whatever the names could not, stepping over twist bones. - verify_character.py looked for legs by the substrings "thigh"/"shin", which VRoid spells UpperLeg/LowerLeg. It declared every locomotion clip static while the legs animated perfectly, and the cross-leg bleed check found no leg vertex groups at all and passed vacuously. Two green- looking lies from one missing lookup; both now read the sidecar's resolved roles. - The cosmetic/spring classifier matched whole tokens only, so Momo's HairFL / HairFR / HairF_Top tokenised to "hairfl" and matched nothing. She imported with six chains, all bust, and no hair. Both classifiers now share one rule that also accepts a two-character positional suffix, which is short enough that "forearm" and "earring" are still untouched. Two more pipeline fixes: - A source model's own clips leaked into the export. Clearing bpy.data .actions before the library import is not enough — hikari carried two on a second armature's NLA tracks, and NLA_TRACKS export mode ships anything in a track anywhere in the file. They export as rest-pose statues. Now everything not retargeted is stripped from every object. - verify_character.py gained a check for cloth chains with no measurable extent. A chain whose bones are zero-length is dropped by the runtime and simulates nothing, while the sidecar still cheerfully reports it. Known: hikari's ten cloth chains are all zero-length and her collider fit found nothing, so her costume does not simulate — her rig has been through two toolchains and its cosmetic bones are empty terminators. She animates correctly otherwise. The new check now reports this instead of hiding it. tools/retarget.py also carries local working-tree changes that predate this session. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
cd0d1b2d99
commit
fc9e6f4275
+58
-6
@@ -106,6 +106,25 @@ SPRING_CLASSES = {"hair", "skirt", "cloth", "ribbon", "tail", "cape", "coat",
|
||||
"antenna", "wing"}
|
||||
|
||||
|
||||
def spring_class(name):
|
||||
"""Which secondary-motion class this bone belongs to, or None.
|
||||
|
||||
Whole token first, then a SHORT positional suffix — the same rule as
|
||||
rig_map.is_cosmetic, and it must be the same rule, because a bone that reads
|
||||
as cosmetic there and as nothing here is left out of every chain and its
|
||||
geometry never moves. DANDADAN's hair is HairFL / HairFR / HairF_Top, which
|
||||
tokenise to "hairfl" and matched no class at all: she imported with six
|
||||
chains, all of them her bust, and not one strand of hair.
|
||||
"""
|
||||
for t in tokens(name):
|
||||
if t in SPRING_CLASSES:
|
||||
return t
|
||||
for c in SPRING_CLASSES:
|
||||
if len(t) - len(c) <= 2 and t.startswith(c) and len(t) > len(c):
|
||||
return c
|
||||
return None
|
||||
|
||||
|
||||
# --------------------------------------------------------------------- import
|
||||
|
||||
|
||||
@@ -680,8 +699,7 @@ def _body_points(meshes):
|
||||
mw = m.matrix_world
|
||||
for v in m.data.vertices:
|
||||
cloth_w = sum(g.weight for g in v.groups
|
||||
if any(t in SPRING_CLASSES
|
||||
for t in tokens(gname.get(g.group, ""))))
|
||||
if spring_class(gname.get(g.group, "")))
|
||||
if cloth_w < 0.35:
|
||||
out.append(mw @ v.co)
|
||||
return out
|
||||
@@ -880,7 +898,7 @@ def describe_rig(arm, roles, mapping, meshes):
|
||||
chains = []
|
||||
springy = {b.name: b for b in arm.data.bones
|
||||
if b.name not in driven
|
||||
and any(t in SPRING_CLASSES for t in tokens(b.name))}
|
||||
and spring_class(b.name)}
|
||||
neighbours = _cloth_neighbours(meshes, set(springy))
|
||||
|
||||
for name, bone in springy.items():
|
||||
@@ -902,8 +920,7 @@ def describe_rig(arm, roles, mapping, meshes):
|
||||
hulls.append(_hull_samples(arm, path[i], owned))
|
||||
fallback = t
|
||||
chains.append({
|
||||
"class": next((t for t in tokens(path[0])
|
||||
if t in SPRING_CLASSES), "cloth"),
|
||||
"class": spring_class(path[0]) or "cloth",
|
||||
"root_parent": bone.parent.name if bone.parent else None,
|
||||
"bones": path,
|
||||
"tips": tips,
|
||||
@@ -1066,6 +1083,7 @@ def main():
|
||||
arm.animation_data.nla_tracks.remove(track)
|
||||
|
||||
merged = 0
|
||||
kept_clips = set()
|
||||
for action in [a for a in bpy.data.actions if a not in before_actions]:
|
||||
clip = LIBRARY_CLIP_MAP.get(action.name.split(".")[0])
|
||||
if not clip:
|
||||
@@ -1074,11 +1092,44 @@ def main():
|
||||
baked = retarget_clip(src_arm, src_roles, arm, roles, mapping, action,
|
||||
clip, yaw, scale)
|
||||
add_nla_clip(arm, baked, clip)
|
||||
kept_clips.add(clip)
|
||||
merged += 1
|
||||
if merged == 0:
|
||||
print("ERROR: no clips retargeted")
|
||||
sys.exit(1)
|
||||
|
||||
# Drop anything animated that we did not put here.
|
||||
#
|
||||
# Clearing bpy.data.actions before the library import is not enough: a
|
||||
# character can carry its own clip in an NLA track that survives, and it is
|
||||
# then exported alongside ours. `hikari` shipped two — " Girl|Loli Anime
|
||||
# GirlAction" — which are keyed for a rig that no longer exists after the
|
||||
# retarget, so they export as frozen rest-pose statues and the build fails a
|
||||
# check that is right to fail it.
|
||||
# Across EVERY object, not just the armature we retargeted onto. The export
|
||||
# runs in NLA_TRACKS mode, so anything sitting in an NLA track anywhere in
|
||||
# the file ships — including a second armature the model happened to carry,
|
||||
# which is where hikari's two were hiding.
|
||||
def _strip_foreign(ad):
|
||||
if ad is None:
|
||||
return
|
||||
for track in list(ad.nla_tracks):
|
||||
if not any(st.action and st.action.name in kept_clips
|
||||
for st in track.strips):
|
||||
ad.nla_tracks.remove(track)
|
||||
if ad.action is not None and ad.action.name not in kept_clips:
|
||||
ad.action = None
|
||||
|
||||
for obj in list(bpy.data.objects):
|
||||
_strip_foreign(obj.animation_data)
|
||||
if obj.type == "MESH" and obj.data.shape_keys:
|
||||
_strip_foreign(obj.data.shape_keys.animation_data)
|
||||
for a in list(bpy.data.actions):
|
||||
if a.name not in kept_clips:
|
||||
a.use_fake_user = False
|
||||
bpy.data.actions.remove(a)
|
||||
print(f"Kept {len(kept_clips)} clips; dropped everything else")
|
||||
|
||||
for o in new_objects:
|
||||
bpy.data.objects.remove(o, do_unlink=True)
|
||||
|
||||
@@ -1149,7 +1200,8 @@ def subdivide_cloth_panels(arm, meshes, roles, segments=4):
|
||||
for bone in arm.data.bones:
|
||||
if not is_cosmetic(bone.name):
|
||||
continue
|
||||
if not any(t in SPRING_CLASSES and t != "hair" for t in tokens(bone.name)):
|
||||
cls = spring_class(bone.name)
|
||||
if cls is None or cls == "hair":
|
||||
continue
|
||||
if bone.children:
|
||||
continue # already a chain — the artist's own topology wins
|
||||
|
||||
Reference in New Issue
Block a user