fix(dvergar): measure where the eyes go instead of guessing at it

Three attempts have now placed these by picking a distance from a bone and hoping,
and all three landed somewhere wrong - above the head, on the camera, and inside
the skull. The distance was never the thing to fix.

Character.m_eye is the game's own answer to where a player's eyes are. Asking the
head bone to express that point in its local space gives an offset that is
correct by construction: no working out which way the bone points, no hand-picked
distance from the base of the skull, and because the result is local it rides
every head animation without being recomputed. The config offsets stay as small
nudges in metres on top of that, with EyeForward pushing out of the skull to the
surface of the face.

Also logs the bone name, its scale and the measured eye point once per session,
so the next round starts from numbers rather than from another guess.
This commit is contained in:
kanym 2026-08-05 20:33:13 +02:00
commit e7d60f61ba
2 changed files with 81 additions and 42 deletions

View file

@ -87,20 +87,22 @@ namespace RacesOfValheim
// instead. Nothing else in the mod does this, so there was no working example to copy;
// the Aswid's red eyes were never built at all, only cleaned up.
//
// Offsets are in metres from the head bone, along the player's own facing, and every one
// of them is multiplied by the race's visual scale so they shrink with a Dvergar rather
// than hanging where a full-height human's face would have been.
// These are adjustments in metres on top of a measured starting point, not absolute
// offsets from a bone. The eyes are parented to the head bone and placed at whatever
// Character.m_eye works out to in that bone's local space - the game's own answer to
// where this player's eyes are - so the numbers below only have to nudge, and everything
// rides the head animation because it is expressed in the head's own coordinates.
//
// The first attempt hung them off Character.m_eye instead. That is the camera's eye
// point, not the model's: it sits outside the scaled rig, so the quads floated above and
// in front of a shrunken Dvergar, and it turns with the look direction rather than the
// head, so they never sat in the face at all.
// Two earlier attempts guessed instead, and both failed in an instructive way: parented
// to m_eye the eyes floated a foot above a shrunken Dvergar, because m_eye is the
// camera's anchor and lives outside the scaled rig; placed from the player root's axes
// they ignored the head entirely and read as stuck to the camera.
//
// EyeForward and EyeHeight are the two to tune, measured from the head bone at the base
// of the skull.
// EyeForward pushes them out of the skull to the surface of the face - it is the one that
// matters. All of them scale with the race.
public static readonly float EyeSeparation = 0.032f; // half the distance between them
public static readonly float EyeForward = 0.090f;
public static readonly float EyeHeight = 0.080f;
public static readonly float EyeForward = 0.070f;
public static readonly float EyeHeight = 0.000f;
public static readonly float EyeSize = 0.020f;
// Base glow, before any star. The tiers replace it with the emissive colours the game