fix(dvergar): stop measuring the eyes from the camera anchor

The trace found it. An eye sat at local (0, 0.0066, 0) on a bone with a scale of
78, which is 0.513m straight up - exactly the distance being reported from the
head. The offsets in play are 0.0007 local units, three orders of magnitude too
small to account for that, so the drift was never in them.

It was the origin. The previous version started from Character.m_eye on the
reasoning that it is the game's own answer to where a player's eyes are, and it
is not: it is where the camera goes, half a metre above the head bone. Everything
after that was correct arithmetic applied to the wrong point, which is why five
rounds of adjusting the offsets changed nothing.

Placement now starts at the head bone and nowhere else. The offsets return to
real distances for a face - forward to the surface of the skull, up from its base
- and the frame conversion is left alone, since the same trace proved it right:
0.0002 local units on a bone scaled 78 rendered as a 0.016m eye, exactly as
asked.
This commit is contained in:
kanym 2026-08-05 20:47:17 +02:00
commit f93b57ceff
2 changed files with 17 additions and 20 deletions

View file

@ -227,17 +227,19 @@ namespace RacesOfValheim
// Metres -> the head bone's local units, which the armature authors at roughly 100x.
float toLocal = 1f / lossy;
Vector3 localEye = player.m_eye != null
? headBone.InverseTransformPoint(player.m_eye.position)
: Vector3.zero;
Vector3 localForward = headBone.InverseTransformDirection(root.forward).normalized;
Vector3 localUp = headBone.InverseTransformDirection(root.up).normalized;
Vector3 localRight = headBone.InverseTransformDirection(root.right).normalized;
// Measured from the head bone itself, and from nothing else.
//
// The previous version started from Character.m_eye, on the reasoning that it is the
// game's own answer to where a player's eyes are. It is not - it is where the camera
// goes, and the trace showed it sitting 0.51m straight above the head bone. That half
// metre was the entire drift: the offsets below are under a centimetre in local units
// and never stood a chance of mattering next to it.
float raceScale = GetVisualScale(player);
Vector3 baseLocal = localEye
+ localForward * (DvergarConfig.EyeForward * raceScale * toLocal)
Vector3 baseLocal = localForward * (DvergarConfig.EyeForward * raceScale * toLocal)
+ localUp * (DvergarConfig.EyeHeight * raceScale * toLocal);
float eyeLocalSize = DvergarConfig.EyeSize * raceScale * toLocal;