fix(dvergar): put the eyes on the head instead of on the camera

Both faults reported came from the same wrong anchor. Character.m_eye is the
camera's eye point, not the model's: it lives outside the scaled rig, so on a
Dvergar - who renders at 78% - the quads hung where a full-height human's face
would have been, a foot above the head. And it turns with the look direction
rather than with the face, so they pointed wherever the player was looking rather
than wherever the head was.

They now hang off the player root, unscaled, and are placed onto the head bone in
world space every frame: position from the bone, orientation from the player's
own facing, and every offset multiplied by the race's visual scale so they shrink
with the body. That also means the placement constants are honest metres measured
from the base of the skull, which is what makes them tunable at all.

Driven per frame from the two places that already tick a Dvergar - the race
script for the local player, the visual controller for remote ones - because
world-space placement has to be re-applied rather than inherited.
This commit is contained in:
kanym 2026-08-05 20:14:08 +02:00
commit 76b89a8e5a
4 changed files with 56 additions and 20 deletions

View file

@ -87,14 +87,21 @@ 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 Character.m_eye, which already sits at eye height and faces
// wherever the player is looking, so no bone axes have to be guessed at. EyeForward is
// the one to tune first: too little and the quads sink into the face, too much and they
// float in front of it.
public static readonly float EyeSeparation = 0.035f; // half the distance between them
public static readonly float EyeForward = 0.075f;
public static readonly float EyeHeight = -0.010f;
public static readonly float EyeSize = 0.022f;
// 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.
//
// 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.
//
// EyeForward and EyeHeight are the two to tune, measured from the head bone at the base
// of the skull.
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 EyeSize = 0.020f;
// Base glow, before any star. The tiers replace it with the emissive colours the game
// itself gives a starred dverger - RGBA(0, 4, 3.3) at one star and RGBA(12, 0, 8.8) at