fix(aswid): land the borrowed eye sockets on the face, and make the sliders able to say so
Scale is inherited, so source.localScale could not come across either: it is authored under a parent that puts the object at 0.02 lossy scale, and re-parenting it under a head bone at ~95 drew the mesh some 4750x too big - an eye the size of the character, centred near the face, therefore mostly inside the skull with the corners reading as flat rectangles. "Wrong place" and "blocky" were one scale error seen from two angles. Carries lossyScale (the size the game actually draws it at on a real skeleton) over the new parent's scale instead. The remaining offset would not compute cleanly from either rig, so it was dialled in on screen and written down as the new defaults rather than guessed at again - size 1.1, forward 0.01, separation 0.007, yaw 24.664, roll -180 (the socket arrives upside down on a player's head bone; that is the half turn that rights it). The sliders that found those numbers could not have: they were bound at +/-0.1 m and 0.1-5x, nowhere near far enough to pull the pair out of the skull, so they read as doing nothing at all. Widened to +/-0.5 m and 0.01-50x. Eye Rotation Y is now mirrored - the left eye takes the negative - so the pair toes in or out together instead of both turning off the same shoulder. X and Z stay shared on purpose: both eyes pitching up is a face looking up, where mirroring pitch or roll would cross them. Confirmed correct in game.
This commit is contained in:
parent
982e88fa57
commit
cb69d3af3e
2 changed files with 86 additions and 26 deletions
|
|
@ -242,28 +242,49 @@ namespace RacesOfValheim
|
|||
new ConfigDescription("How bright the final-stage red burns - the single knob for it, since the hue is already pure. Expect a floor: below the bloom threshold the eyes stop glowing and become flat dots.",
|
||||
new AcceptableValueRange<float>(0f, 3f), new ConfigurationManagerAttributes { Order = 87 }));
|
||||
|
||||
EyeSizeMultiplier = config.Bind(eyes, "Eye Size Multiplier", 1f,
|
||||
new ConfigDescription("Scales both sockets. 1 is the size the source creature wears them at.",
|
||||
new AcceptableValueRange<float>(0.1f, 5f), new ConfigurationManagerAttributes { Order = 80 }));
|
||||
// ─── Ranges are deliberately wide ────────────────────────────────
|
||||
// These started at +/-0.1 m and 0.1-5x, on the assumption that the borrowed sockets
|
||||
// land close to right and only need nudging. They do not, and a slider that cannot
|
||||
// reach the correct value is worse than no slider - it looks like the setting does not
|
||||
// work. Wide enough to dig the pair out of the skull from any starting point, and to
|
||||
// find the right size by eye when the source model's own scale does not transfer.
|
||||
// Every one of these is live: the eye ticker reapplies them each frame, so a drag in
|
||||
// Configuration Manager moves them while you watch.
|
||||
|
||||
EyeForwardOffset = config.Bind(eyes, "Eye Forward Offset", 0f,
|
||||
new ConfigDescription("Moves both eyes out of (or into) the face. 0 leaves them where the source creature wears them.",
|
||||
new AcceptableValueRange<float>(-0.1f, 0.1f), new ConfigurationManagerAttributes { Order = 70 }));
|
||||
// ─── The defaults below were found in game, not derived ──────────
|
||||
// The borrowed sockets do not arrive on the face by themselves: their authored pose
|
||||
// and scale belong to the Skeleton's own rig and none of it transfers cleanly to a
|
||||
// player armature (see AswidVisuals.BuildEyes for what does and does not carry over).
|
||||
// Four attempts to compute the remainder each missed, so it was dialled in on screen
|
||||
// instead and the answer written down here. That is what these seven numbers are - a
|
||||
// measurement, not a taste. Treat them as the working baseline: a fresh install lands
|
||||
// on a correct face, and the sliders are then free to be about taste again.
|
||||
//
|
||||
// The -180 on Z is the honest shape of it: the socket arrives upside down relative to
|
||||
// the player's head bone, and this is the half turn that rights it.
|
||||
|
||||
EyeSizeMultiplier = config.Bind(eyes, "Eye Size Multiplier", 1.1f,
|
||||
new ConfigDescription("Scales both sockets. 1 is the size the source creature wears them at.",
|
||||
new AcceptableValueRange<float>(0.01f, 50f), new ConfigurationManagerAttributes { Order = 80 }));
|
||||
|
||||
EyeForwardOffset = config.Bind(eyes, "Eye Forward Offset", 0.01f,
|
||||
new ConfigDescription("Moves both eyes out of (or into) the face, in metres. Positive is forward, out of the skull.",
|
||||
new AcceptableValueRange<float>(-0.5f, 0.5f), new ConfigurationManagerAttributes { Order = 70 }));
|
||||
EyeHeightOffset = config.Bind(eyes, "Eye Height Offset", 0f,
|
||||
new ConfigDescription("Moves both eyes up or down the face.",
|
||||
new AcceptableValueRange<float>(-0.1f, 0.1f), new ConfigurationManagerAttributes { Order = 69 }));
|
||||
EyeSeparationOffset = config.Bind(eyes, "Eye Separation Offset", 0f,
|
||||
new ConfigDescription("Pushes the two eyes apart (or together). Each moves away from the centre of the face, so this is half the change in the gap.",
|
||||
new AcceptableValueRange<float>(-0.1f, 0.1f), new ConfigurationManagerAttributes { Order = 68 }));
|
||||
new ConfigDescription("Moves both eyes up or down the face, in metres. Positive is up.",
|
||||
new AcceptableValueRange<float>(-0.5f, 0.5f), new ConfigurationManagerAttributes { Order = 69 }));
|
||||
EyeSeparationOffset = config.Bind(eyes, "Eye Separation Offset", 0.007f,
|
||||
new ConfigDescription("Pushes the two eyes apart (or together), in metres. Each moves away from the centre of the face, so this is half the change in the gap.",
|
||||
new AcceptableValueRange<float>(-0.5f, 0.5f), new ConfigurationManagerAttributes { Order = 68 }));
|
||||
|
||||
EyeRotationX = config.Bind(eyes, "Eye Rotation X", 0f,
|
||||
new ConfigDescription("Turns both eyes on the spot. Only matters if the borrowed socket is flat enough to be seen edge-on.",
|
||||
new AcceptableValueRange<float>(-180f, 180f), new ConfigurationManagerAttributes { Order = 60 }));
|
||||
EyeRotationY = config.Bind(eyes, "Eye Rotation Y", 0f,
|
||||
new ConfigDescription("As above, around the second axis.",
|
||||
EyeRotationY = config.Bind(eyes, "Eye Rotation Y", 24.664f,
|
||||
new ConfigDescription("As above, around the second axis - but MIRRORED: the left eye turns the opposite way, so the pair toes in or out together instead of both pointing off the same shoulder.",
|
||||
new AcceptableValueRange<float>(-180f, 180f), new ConfigurationManagerAttributes { Order = 59 }));
|
||||
EyeRotationZ = config.Bind(eyes, "Eye Rotation Z", 0f,
|
||||
new ConfigDescription("As above, around the third axis.",
|
||||
EyeRotationZ = config.Bind(eyes, "Eye Rotation Z", -180f,
|
||||
new ConfigDescription("As above, around the third axis. The default half turn is what rights the borrowed socket, which arrives upside down on a player's head bone.",
|
||||
new AcceptableValueRange<float>(-180f, 180f), new ConfigurationManagerAttributes { Order = 58 }));
|
||||
|
||||
EyeSmoke = config.Bind(eyes, "Eye Smoke", true,
|
||||
|
|
|
|||
|
|
@ -312,11 +312,6 @@ namespace RacesOfValheim
|
|||
Vector3 shift = frame.LocalForward * (AswidConfig.EyeForwardOffset.Value * scale)
|
||||
+ frame.LocalUp * (AswidConfig.EyeHeightOffset.Value * scale);
|
||||
|
||||
Quaternion twist = Quaternion.Euler(
|
||||
AswidConfig.EyeRotationX.Value,
|
||||
AswidConfig.EyeRotationY.Value,
|
||||
AswidConfig.EyeRotationZ.Value);
|
||||
|
||||
for (int i = 0; i < holder.childCount; i++)
|
||||
{
|
||||
Transform eye = holder.GetChild(i);
|
||||
|
|
@ -329,6 +324,19 @@ namespace RacesOfValheim
|
|||
float side = Mathf.Sign(Vector3.Dot(authored.Position, frame.LocalRight));
|
||||
if (side == 0f) side = i == 0 ? -1f : 1f;
|
||||
|
||||
// YAW IS MIRRORED, the other two are not. Turning both eyes the same way on Y
|
||||
// makes the pair look sideways - both point off the same shoulder, because a face
|
||||
// is symmetric about its centre line and yaw is the axis that crosses it. Negating
|
||||
// it on the left eye turns them out from (or in towards) the nose together, which
|
||||
// is what "toe them in a bit" actually means on a pair of eyes.
|
||||
//
|
||||
// Pitch and roll are shared deliberately: both eyes looking up is a face looking
|
||||
// up, and mirroring either of those would cross them instead of aiming them.
|
||||
Quaternion twist = Quaternion.Euler(
|
||||
AswidConfig.EyeRotationX.Value,
|
||||
AswidConfig.EyeRotationY.Value * side,
|
||||
AswidConfig.EyeRotationZ.Value);
|
||||
|
||||
eye.localPosition = authored.Position + shift +
|
||||
frame.LocalRight * (side * AswidConfig.EyeSeparationOffset.Value * scale);
|
||||
eye.localRotation = twist * authored.Rotation;
|
||||
|
|
@ -395,6 +403,11 @@ namespace RacesOfValheim
|
|||
List<Transform> sources = FindSourceEyes(modelName);
|
||||
if (sources.Count == 0) return null; // already logged once by the finder
|
||||
|
||||
// The placement below divides by this, and the rig reports 0 for a frame or two while
|
||||
// it is still coming up. Returning null costs nothing - ApplyEyes calls again next
|
||||
// tick - where dividing by it would put the pair somewhere unrecoverable.
|
||||
if (Mathf.Abs(headBone.lossyScale.x) < 0.0001f) return null;
|
||||
|
||||
// Anything of ours left anywhere else on this player goes first. ApplyEyes only ever
|
||||
// looks under the head bone, so a holder that ended up on some other transform is
|
||||
// invisible to it - it would build a second pair beside the wrong one rather than
|
||||
|
|
@ -447,27 +460,53 @@ namespace RacesOfValheim
|
|||
// 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);
|
||||
// it by. In game it landed 0.22 m straight up from the head bone and barely any
|
||||
// forward, where 0.181 up / 0.081 forward is the face - eyes above the skull.
|
||||
//
|
||||
// THE / lossyScale IS NOT OPTIONAL. The constants are world metres; localPosition
|
||||
// is in the head bone's own space, which the armature authors at ~95-100x. Setting
|
||||
// them without this term puts the eyes 0.081 x 95 = 7.7 m out - off the model
|
||||
// entirely and invisible, which is exactly what dropping this term did once
|
||||
// already. PlaceEyes applies the config offsets through the same 1/lossy factor
|
||||
// for the same reason, and the pre-rewrite sphere code always had it.
|
||||
float toLocal = 1f / headBone.lossyScale.x;
|
||||
|
||||
Vector3 basePosition = frame.LocalForward * (BaseEyeForward * toLocal)
|
||||
+ frame.LocalUp * (BaseEyeHeight * toLocal)
|
||||
+ frame.LocalRight * (side * BaseEyeSeparation * toLocal);
|
||||
|
||||
// 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;
|
||||
|
||||
// SCALE IS INHERITED, so the authored localScale cannot come across either.
|
||||
//
|
||||
// source.localScale is authored under the Skeleton's own parent chain, which puts
|
||||
// that object at 0.02 lossy scale in the world. Re-parented under a head bone at
|
||||
// ~95 and left alone, the same number renders the mesh some 4750x too big: an eye
|
||||
// the size of the character, centred near the face, therefore mostly INSIDE the
|
||||
// skull, with the corners that clear it reading as flat rectangles rather than as
|
||||
// eyes. That is one bug with two faces - "wrong place" and "blocky" were the same
|
||||
// scale error seen from outside and from in front.
|
||||
//
|
||||
// lossyScale (world) rather than localScale (relative to a parent we do not have)
|
||||
// is the honest quantity to carry over: it is the size the game actually draws
|
||||
// this object at on a real skeleton. Divided into the new parent's scale, the pair
|
||||
// lands at exactly the size vanilla wears them, which is the whole point of
|
||||
// borrowing them instead of drawing spheres.
|
||||
Vector3 baseScale = source.lossyScale * toLocal;
|
||||
|
||||
// Remembered before anything moves it, because everything the config does is
|
||||
// expressed as a delta on this.
|
||||
EyeBase authored = eye.AddComponent<EyeBase>();
|
||||
authored.Position = basePosition;
|
||||
authored.Rotation = baseRotation;
|
||||
authored.Scale = source.localScale;
|
||||
authored.Scale = baseScale;
|
||||
|
||||
eye.transform.localPosition = basePosition;
|
||||
eye.transform.localRotation = baseRotation;
|
||||
eye.transform.localScale = source.localScale;
|
||||
eye.transform.localScale = baseScale;
|
||||
|
||||
// Allowlist, not a blocklist - the same rule the skeleton's own glow and the head
|
||||
// flame are cloned under. Whatever rode along goes, whatever type it turns out to
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue