fix(aswid): stop borrowing the Skeleton's eye position, only its mesh
player.transform (previous commit) fixed the frame used for the shift/rotation config offsets, but that code path is inert at every offset's default of 0 - so it never touched the actual bug. The real placement came from source.localPosition, copied straight off the Skeleton creature's eye_l/eye_r and reinterpreted under the player's own head bone. That only works if the two rigs agree on scale, and they do not: the Skeleton's rig measured 0.02 lossy scale at the eye bone against this player rig's ~95-100, with nothing tying one prefab's authored scale to another's. Taken as-is it put the eyes roughly 0.2 world units off the head bone - visibly floating above the face, on every single build, matching the "never fixes, not even after logout" report exactly. Eyes are now placed from the player's own measured frame and three fixed constants (BaseEyeForward/Height/Separation) - the pre-rewrite sphere code's own numbers, already tuned and playtested on this exact rig. Still borrows eye_l/eye_r for their mesh and material (the actual point of the rewrite - real lit sockets instead of painted spheres), just not their transform. Confirmed against real numbers from in-game diagnostic logging rather than guessed a third time; that logging has been removed.
This commit is contained in:
parent
028c34be3c
commit
982e88fa57
1 changed files with 45 additions and 4 deletions
|
|
@ -44,6 +44,20 @@ namespace RacesOfValheim
|
|||
// scale cancels and a given config value lands on the same part of the face at any size -
|
||||
// Fader-tier growth included. Kept in the arithmetic because it is honest about intent.
|
||||
|
||||
// The eye_l/eye_r pair is borrowed for its MESH AND MATERIAL only, never for its position.
|
||||
// Their authored local offset lives in the Skeleton creature's own rig, at whatever scale
|
||||
// that rig happens to use at the eye bone - measured at 0.02 lossy scale against this
|
||||
// player rig's 95-100, a roughly 5000x difference with no fixed ratio to correct for,
|
||||
// because nothing ties one prefab's rig scale to another's. Carrying that number over
|
||||
// unchanged (even after remapping which axis is which) put the eyes some 0.2 world units
|
||||
// off the head bone - visibly floating above the face. These three are the pre-rewrite
|
||||
// sphere code's own numbers, tuned by eye on THIS player rig and confirmed by playtest
|
||||
// before the borrowed-eye-light rewrite - the one measurement in this file that is
|
||||
// actually expressed in the right units to begin with.
|
||||
private const float BaseEyeForward = 0.081f;
|
||||
private const float BaseEyeHeight = 0.181f;
|
||||
private const float BaseEyeSeparation = 0.032f;
|
||||
|
||||
// ─── Race check ─────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -412,20 +426,47 @@ namespace RacesOfValheim
|
|||
frame.SourceModel = modelName;
|
||||
frame.FlatShader = AswidConfig.EyeFlatColorShader.Value;
|
||||
|
||||
// canonicalToFrame turns "face forward, as authored" into "face forward, on THIS
|
||||
// rig's own axes" - the rotation that carries the ordinary (X,Y,Z) convention onto
|
||||
// (frame.LocalRight, frame.LocalUp, frame.LocalForward). Used for the socket's base
|
||||
// facing below; NOT used for position - see BaseEyeForward/Height/Separation for why.
|
||||
Quaternion canonicalToFrame = Quaternion.LookRotation(frame.LocalForward, frame.LocalUp);
|
||||
|
||||
foreach (Transform source in sources)
|
||||
{
|
||||
GameObject eye = Object.Instantiate(source.gameObject, holder.transform);
|
||||
eye.name = source.name;
|
||||
|
||||
// LEFT vs RIGHT read from the source object's own name, not from list order -
|
||||
// "eye_l"/"eye_r" is the actual contract FindSourceEyes matches against; the order
|
||||
// GetComponentsInChildren happens to walk the source hierarchy in is not.
|
||||
float side = source.name.ToLowerInvariant().Contains("_l") ? -1f : 1f;
|
||||
|
||||
// Placed from the player's own measured frame and three fixed constants, NOT from
|
||||
// source.localPosition. The borrowed position is authored on the Skeleton
|
||||
// creature's own rig, at whatever scale that rig happens to use at the eye bone -
|
||||
// measured at 0.02 lossy scale against this player rig's ~95-100, and nothing ties
|
||||
// one prefab's rig scale to another's, so there is no reliable factor to correct
|
||||
// it by. Taken as-is (even after fixing which axis is which) it put the eyes
|
||||
// roughly 0.2 world units off the head bone - visibly floating above the face.
|
||||
Vector3 basePosition = frame.LocalForward * BaseEyeForward
|
||||
+ frame.LocalUp * BaseEyeHeight
|
||||
+ frame.LocalRight * (side * BaseEyeSeparation);
|
||||
|
||||
// The socket's own authored tilt is skipped for the same reason its position is -
|
||||
// canonicalToFrame alone (face forward, on this rig's axes) is what the config's
|
||||
// twist then nudges from in PlaceEyes.
|
||||
Quaternion baseRotation = canonicalToFrame;
|
||||
|
||||
// Remembered before anything moves it, because everything the config does is
|
||||
// expressed as a delta on this.
|
||||
EyeBase authored = eye.AddComponent<EyeBase>();
|
||||
authored.Position = source.localPosition;
|
||||
authored.Rotation = source.localRotation;
|
||||
authored.Position = basePosition;
|
||||
authored.Rotation = baseRotation;
|
||||
authored.Scale = source.localScale;
|
||||
|
||||
eye.transform.localPosition = source.localPosition;
|
||||
eye.transform.localRotation = source.localRotation;
|
||||
eye.transform.localPosition = basePosition;
|
||||
eye.transform.localRotation = baseRotation;
|
||||
eye.transform.localScale = source.localScale;
|
||||
|
||||
// Allowlist, not a blocklist - the same rule the skeleton's own glow and the head
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue