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

@ -159,7 +159,19 @@ namespace RacesOfValheim
return;
}
if (eyes == null) eyes = BuildEyes(player, headBone);
if (eyes == null)
{
// See AswidVisuals.ApplyEyes for the full reasoning - BuildEyes takes a one-time
// reading of the head bone's pose to work out which way the skull faces, and
// caches it for as long as the eyes exist. Sitting, attached, mid-attack or asleep,
// the head can be turned away from the body's own forward at that instant, which is
// how the snap-to-axis picked the wrong side and left the eyes behind the skull.
if (player.IsAttached() || player.IsAttachedToShip() || player.InAttack() || player.IsSleeping())
{
return;
}
eyes = BuildEyes(player, headBone);
}
if (eyes == null) return; // already logged once by the resolver
PlaceEyes(player, headBone, eyes);