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.
This commit is contained in:
parent
e3ade9aa63
commit
e6bf266eea
1 changed files with 7 additions and 1 deletions
|
|
@ -318,7 +318,13 @@ namespace RacesOfValheim
|
||||||
EyeFrame frame = holder.AddComponent<EyeFrame>();
|
EyeFrame frame = holder.AddComponent<EyeFrame>();
|
||||||
frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward));
|
frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward));
|
||||||
frame.LocalUp = SnapToAxis(headBone.InverseTransformDirection(root.up));
|
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++)
|
for (int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue