add-dvergar-color-and-skeleton-menu #14

Merged
kanym merged 30 commits from add-dvergar-color-and-skeleton-menu into main 2026-08-05 22:08:39 +02:00
Showing only changes of commit e6bf266eea - Show all commits

fix(dvergar): derive the sideways axis so both eyes sit at the same depth

One eye reading correctly while the other creeps up the forehead is what an out-of-square frame looks like. The three axes were each rounded to the nearest one independently, which guarantees nothing about the angles between them - and a right that shares an axis with forward is no longer sideways, so the separation pushes one eye out of the face and pulls the other into it.

Right is now a cross product of the other two, which cannot be anything but perpendicular to both. Symmetric by construction rather than by luck of the pose the head was in when the eyes were built.
kanym 2026-08-05 21:54:26 +02:00

View file

@ -318,7 +318,13 @@ namespace RacesOfValheim
EyeFrame frame = holder.AddComponent<EyeFrame>();
frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward));
frame.LocalUp = SnapToAxis(headBone.InverseTransformDirection(root.up));
frame.LocalRight = SnapToAxis(headBone.InverseTransformDirection(root.right));
// Right is derived, never snapped. Rounding all three independently guarantees
// nothing about the angles between them, and a "right" that shares an axis with
// forward stops being sideways: the separation then pushes one eye out of the face
// and pulls the other into it, which is one eye sitting proud of a forehead while its
// twin sits correctly. A cross product cannot be anything but perpendicular.
frame.LocalRight = Vector3.Cross(frame.LocalUp, frame.LocalForward).normalized;
for (int i = 0; i < 2; i++)
{