fix(skeleton): reattach the mandible, light the skull for real, and grow at Fader
The jaw hung off the side of the skull because a creature rig carries bones a human rig has no answer for. Unmatched bones fell back to bones[0] - the root - so the mandible was skinned to the hips and followed them. The remap now walks the creature'''s own hierarchy upward until something matches, which lands a jaw on the head. It no longer opens, which no player will notice, and it is attached, which every player did. Teeth and any other facial part the model carries are fixed by the same walk. The head flame never appeared. It was built by hand out of the smoke material with a hand-rolled fire gradient, which at best would have read as a wisp rather than a burning skull, and at worst never resolved a source at all and returned in silence. It now clones real fire particles off a vanilla prefab - the torch first, ground torches and the fire pit behind it - and says in the log which one it took, or warns if none of them resolved. The torch light comes with it, at half range and reduced intensity, since a light tuned to fill a corridor from waist height blows out a face at point-blank range. Fader now stands 15% taller. That scale goes on the player root, which is how this race has always sized itself, so the collider, the camera pivot and every equipment attachment scale with the mesh rather than leaving the model to drift away from them.
This commit is contained in:
parent
6b890f71c4
commit
59c250b4f8
3 changed files with 110 additions and 57 deletions
|
|
@ -298,14 +298,13 @@ namespace RacesOfValheim
|
|||
Transform[] newBones = new Transform[newSmr.bones.Length];
|
||||
for (int i = 0; i < newSmr.bones.Length; i++)
|
||||
{
|
||||
Transform matchedBone = FindBoneByName(playerBones, newSmr.bones[i].name);
|
||||
newBones[i] = matchedBone != null ? matchedBone : playerBones[0];
|
||||
newBones[i] = ResolveBone(playerBones, newSmr.bones[i]);
|
||||
}
|
||||
newSmr.bones = newBones;
|
||||
|
||||
|
||||
if (newSmr.rootBone != null)
|
||||
{
|
||||
newSmr.rootBone = FindBoneByName(playerBones, newSmr.rootBone.name) ?? playerBones[0];
|
||||
newSmr.rootBone = ResolveBone(playerBones, newSmr.rootBone);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -397,6 +396,32 @@ namespace RacesOfValheim
|
|||
catch (System.Exception e) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the player bone a creature bone should be skinned to.
|
||||
///
|
||||
/// A creature rig carries bones a human rig has no answer for - a jaw above all, but
|
||||
/// also teeth and tails. Those used to fall back to bones[0], the root, which skinned
|
||||
/// the mandible to the hips and left it hanging off the side of the skull. Follow the
|
||||
/// creature's own hierarchy upward instead until something matches, so a jaw lands on
|
||||
/// the head and rides it. It cannot open any more, which no player will notice, and it
|
||||
/// is attached, which every player did.
|
||||
/// </summary>
|
||||
private static Transform ResolveBone(Transform[] playerBones, Transform sourceBone)
|
||||
{
|
||||
if (sourceBone == null) return playerBones[0];
|
||||
|
||||
Transform direct = FindBoneByName(playerBones, sourceBone.name);
|
||||
if (direct != null) return direct;
|
||||
|
||||
for (Transform parent = sourceBone.parent; parent != null; parent = parent.parent)
|
||||
{
|
||||
Transform match = FindBoneByName(playerBones, parent.name);
|
||||
if (match != null) return match;
|
||||
}
|
||||
|
||||
return playerBones[0];
|
||||
}
|
||||
|
||||
private static Transform FindBoneByName(Transform[] bones, string skelBoneName)
|
||||
{
|
||||
// Exact match first
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue