From f93b57ceff9155963017b7b66aa6d714e986353f Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 5 Aug 2026 20:47:17 +0200 Subject: [PATCH] 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. --- JotunnModStub/Dvergar/DvergarConfig.cs | 23 +++++++++-------------- JotunnModStub/Dvergar/DvergarVisuals.cs | 14 ++++++++------ 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarConfig.cs b/JotunnModStub/Dvergar/DvergarConfig.cs index 3fa0c72..6078c2d 100644 --- a/JotunnModStub/Dvergar/DvergarConfig.cs +++ b/JotunnModStub/Dvergar/DvergarConfig.cs @@ -87,22 +87,17 @@ 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. // - // 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. + // Metres from the head bone, which sits at the base of the skull, along the player's own + // forward and up. The eyes are parented to that bone, so all of this rides the head + // animation, and every offset scales with the race. // - // 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 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. + // Do not reintroduce Character.m_eye as a starting point. It reads like the right + // reference and is not: it is where the camera goes, half a metre above the head bone, + // and starting from it put the eyes in the treetops. That was measured, not guessed - + // the trace is in the commit history. public static readonly float EyeSeparation = 0.032f; // half the distance between them - public static readonly float EyeForward = 0.070f; - public static readonly float EyeHeight = 0.000f; + public static readonly float EyeForward = 0.095f; + public static readonly float EyeHeight = 0.070f; public static readonly float EyeSize = 0.020f; // Base glow, before any star. The tiers replace it with the emissive colours the game diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index 3dea9d8..ffdac13 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -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;