fix(visuals): stop the glow eyes from occasionally landing behind the skull

AswidVisuals/DvergarVisuals measure which way the head bone faces
exactly once, the first time BuildEyes runs for a given character, by
reading the bone's live pose at that instant and snapping it to the
nearest axis - then cache the result for as long as the eyes exist.
Taken while sitting, attached, mid-attack or asleep, the head can be
turned away from the body's own forward, and the snap picks whichever
axis is closest to that pose - landing the eyes behind the skull
instead of on the face, and staying wrong for the rest of the session.

ApplyEyes now defers the first build while the player is attached,
attached to a ship, mid-attack or asleep, since it runs again on every
subsequent UpdateColors anyway. Reduces the obvious bad-timing cases;
does not by itself rule out a mistimed read during ordinary idle
animation, which would need the measurement moved to the model's bind
pose (animation-independent) to close out completely.

Also shrinks the Aswid's eyes by 10% (EyeSize 0.062 -> 0.0558), per
request.

Confirmed improved by playtest.
This commit is contained in:
kanym 2026-08-09 16:48:35 +02:00
commit 26bfd339e8
2 changed files with 30 additions and 3 deletions

View file

@ -68,7 +68,7 @@ namespace RacesOfValheim
public static readonly float EyeSeparation = 0.032f; // half the distance between them
public static readonly float EyeForward = 0.081f; // centre out from the head bone
public static readonly float EyeHeight = 0.181f; // up from the head bone
public static readonly float EyeSize = 0.062f; // across, so a 24mm radius at 0.78
public static readonly float EyeSize = 0.0558f; // 0.062 x 0.9 - across, so a 24mm radius at 0.78
// Carried over from the Dvergar's own tuning on this same rig: the face is not flat, so
// two eyes placed symmetrically do not come out looking symmetrical. May need a pass in
@ -147,7 +147,22 @@ namespace RacesOfValheim
return;
}
if (eyes == null) eyes = BuildEyes(headBone);
if (eyes == null)
{
// BuildEyes measures which way the skull faces from the head bone's pose at this
// exact instant (see the frame comment above it) - a one-time reading, cached for
// as long as the eyes exist. Taken while sitting, attached to something, mid-attack
// or asleep, the head can be tilted or turned away from the body's own forward, and
// the snap-to-axis picks whichever axis is closest to THAT pose - which is how eyes
// ended up behind the skull instead of on the face. Waiting for a plain standing
// pose costs nothing (ApplyEyes runs again on the next UpdateColors either way) and
// this is the only place in the whole flow where the timing actually matters.
if (player.IsAttached() || player.IsAttachedToShip() || player.InAttack() || player.IsSleeping())
{
return;
}
eyes = BuildEyes(headBone);
}
if (eyes == null) return; // already logged once by the resolver
PlaceEyes(player, headBone, eyes);