fix(characters): rig-independent weapon mount, measured facing, revert Miku
WEAPON MOUNT, all models. set_weapon() seated the gun with a fixed rotation_degrees = (0, 90, -90). A bone attachment is expressed in the BONE's axes and no two rigs agree on those, so one constant mounted the weapon differently on every character. It never needed to be right: the pose layer aims the gun by rotating the wrist until the weapon's forward lies on the aim line, so the identity means "forward is the hand bone's -Z", which is true on any rig, and the wrist absorbs the roll. The grip now sits at the bone origin, so the gun is in the hand rather than at an offset from a differently-oriented bone. Verified by render on kiyoko: rifle shouldered, both hands on it. FACING. flatten_and_scale() now measures toes-versus-ankles and snaps the character to face Blender -Y, the convention the runtime's blanket flip is built around. Kiyoko was 180 degrees off. Snapped to the nearest quarter turn so splayed feet in a rest pose are not read as a turned character. MIKU. Re-imported without --grow-cloth. Her grown hair chains were the cause of the stretching: cloth_bones.py clears a vertex's body weights and re-assigns it to the fitted polyline, so a poor fit does not degrade to "stiff", it degrades to "torn". She now has no hair simulation — stiff but correct — until that tool blends against the weights it replaces instead of destroying them. ARIA'S SKIRT IS NOT SIMULATED. Worth recording plainly, because it looks better than Taila's and the obvious conclusion is the wrong one: aria has ZERO cloth chains. Her skirt never clips because it is rigidly skinned and follows the legs it is weighted to. There is nothing to port to Taila except switching her simulation off. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
27c4117c25
commit
c8b0337aa7
@@ -413,6 +413,45 @@ def flatten_and_scale(arm, meshes, target_height, roles=None):
|
||||
print(f"Stood the character up: feet->hips ran along "
|
||||
f"{'XYZ'[k]}{'+' if d[k] > 0 else '-'}, rotated to Z+")
|
||||
|
||||
# TURN THE CHARACTER TO FACE THE SAME WAY AS EVERY OTHER CHARACTER.
|
||||
#
|
||||
# Which way a model faces is a property of the file, not a constant, and two
|
||||
# separate things were guessing at it: facing_correction() aligns the rest
|
||||
# pose to the library's, and the runtime then applies a blanket 180 degrees
|
||||
# because "glTF forward is +Z". When a source disagrees with either, the two
|
||||
# compose into a character who runs backwards, and nothing measured the
|
||||
# result. Kiyoko shipped like that.
|
||||
#
|
||||
# The skeleton knows: toes are in front of ankles. Snap that to Blender -Y,
|
||||
# which is the convention the rest of the pipeline and the runtime flip are
|
||||
# built around, so every character leaves here pointing the same way whatever
|
||||
# the source did.
|
||||
if roles is not None:
|
||||
fwd = Vector((0.0, 0.0, 0.0))
|
||||
n_f = 0
|
||||
for side in ("L", "R"):
|
||||
a = arm.data.bones.get(roles.limb.get(("foot", side), ""))
|
||||
t = arm.data.bones.get(roles.limb.get(("toe", side), ""))
|
||||
if a and t:
|
||||
fwd += (t.head_local - a.head_local)
|
||||
n_f += 1
|
||||
if n_f:
|
||||
fwd.z = 0.0
|
||||
if fwd.length > 1e-4:
|
||||
fwd.normalize()
|
||||
want = Vector((0.0, -1.0, 0.0))
|
||||
ang = math.atan2(fwd.x, -fwd.y) # signed yaw from -Y to fwd
|
||||
# Snap to the nearest quarter turn: a rest pose with the feet
|
||||
# slightly splayed must not be counted as a turn.
|
||||
q = round(ang / (math.pi / 2)) * (math.pi / 2)
|
||||
if abs(q) > 1e-6:
|
||||
R = Matrix.Rotation(-q, 4, Vector((0.0, 0.0, 1.0)))
|
||||
for obj in [arm] + meshes:
|
||||
obj.matrix_world = R @ obj.matrix_world
|
||||
apply_all()
|
||||
print("Turned the character to face -Y: was %.0f degrees off"
|
||||
% math.degrees(q))
|
||||
|
||||
lo = Vector((1e9, 1e9, 1e9))
|
||||
hi = -lo.copy()
|
||||
for m in meshes:
|
||||
|
||||
Reference in New Issue
Block a user