diff --git a/JotunnModStub/Alfar/AlfarVisuals.cs b/JotunnModStub/Alfar/AlfarVisuals.cs index 70b3f68..aa6df6e 100644 --- a/JotunnModStub/Alfar/AlfarVisuals.cs +++ b/JotunnModStub/Alfar/AlfarVisuals.cs @@ -196,7 +196,7 @@ namespace RacesOfValheim // slant and the wrap are mirrored so both outer corners go up and back. float side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Alfar". + // This eye's hand corrections (RaceEyeTuning). float forward = AlfarConfig.EyeForward; float eyeHeight = height; float eyeSeparation = separation; @@ -204,13 +204,13 @@ namespace RacesOfValheim float wrap = AlfarConfig.EyeWrap; float slant = AlfarConfig.EyeSlant; float tilt = 0f; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(AlfarConfig.RaceId, player, side); + RaceEyeTuning.Eye tuning = RaceEyeTuning.For(AlfarConfig.RaceId, player, side); if (tuning != null) { - forward += tuning.Forward.Value; - eyeHeight += tuning.Height.Value; - eyeSeparation += tuning.Separation.Value; - eyeSize *= tuning.Size.Value; + forward += tuning.Forward; + eyeHeight += tuning.Height; + eyeSeparation += tuning.Separation; + eyeSize *= tuning.Size; tilt = tuning.RotX; wrap += tuning.RotY; slant += tuning.RotZ; diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs index 8d0aeef..c0822ad 100644 --- a/JotunnModStub/Aswid/AswidVisuals.cs +++ b/JotunnModStub/Aswid/AswidVisuals.cs @@ -332,12 +332,12 @@ namespace RacesOfValheim float side = Mathf.Sign(Vector3.Dot(authored.Position, frame.LocalRight)); if (side == 0f) side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Aswid", on top of the race's own offsets. - EyePositionConfig.Tuning tuning = EyePositionConfig.For("Aswid", player, side); - float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward.Value : 0f); - float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height.Value : 0f); - float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation.Value : 0f); - float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size.Value : 1f); + // This eye's hand corrections (RaceEyeTuning), on top of the race's own offsets. + RaceEyeTuning.Eye tuning = RaceEyeTuning.For("Aswid", player, side); + float forward = AswidConfig.EyeForwardOffset.Value + (tuning != null ? tuning.Forward : 0f); + float height = AswidConfig.EyeHeightOffset.Value + (tuning != null ? tuning.Height : 0f); + float separation = AswidConfig.EyeSeparationOffset.Value + (tuning != null ? tuning.Separation : 0f); + float size = AswidConfig.EyeSizeMultiplier.Value * (tuning != null ? tuning.Size : 1f); Vector3 shift = frame.LocalForward * (forward * scale) + frame.LocalUp * (height * scale); @@ -359,7 +359,7 @@ namespace RacesOfValheim AswidConfig.EyeRotationY.Value * side, AswidConfig.EyeRotationZ.Value); - // The Eyes Position sliders turn the eye on the FACE's axes instead: conjugated by + // The RaceEyeTuning corrections turn the eye on the FACE's axes instead: conjugated by // the face frame, X tips it, Y turns it toward the temple and Z raises the outer // corner, the same on both eyes. Added to the bone-axis twist above, X rolled the // eyes and a mirrored Z tipped one up and the other down. diff --git a/JotunnModStub/ConfigSync.cs b/JotunnModStub/ConfigSync.cs index 0f9ac48..abbad38 100644 --- a/JotunnModStub/ConfigSync.cs +++ b/JotunnModStub/ConfigSync.cs @@ -87,7 +87,6 @@ namespace RacesOfValheim if (section.EndsWith("Keybinds", StringComparison.OrdinalIgnoreCase)) return false; if (LocalSections.Contains(section, StringComparer.OrdinalIgnoreCase)) return false; - if (section.StartsWith(EyePositionConfig.SectionPrefix, StringComparison.OrdinalIgnoreCase)) return false; if (LocalKeyParts.Any(key.Contains)) return false; // Model pose nudges (rotation/offset/yaw) are cosmetic, but "Attack Reach Offset" is a diff --git a/JotunnModStub/Dvergar/DvergarVisuals.cs b/JotunnModStub/Dvergar/DvergarVisuals.cs index b156fe2..c654a3a 100644 --- a/JotunnModStub/Dvergar/DvergarVisuals.cs +++ b/JotunnModStub/Dvergar/DvergarVisuals.cs @@ -293,18 +293,18 @@ namespace RacesOfValheim // radius. float side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Dvergar". + // This eye's hand corrections (RaceEyeTuning). float forward = DvergarConfig.EyeForward; float eyeHeight = height; float eyeSeparation = separation; float size = eyeSize * raceScale * toLocal; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(DvergarConfig.RaceId, player, side); + RaceEyeTuning.Eye tuning = RaceEyeTuning.For(DvergarConfig.RaceId, player, side); if (tuning != null) { - forward += tuning.Forward.Value; - eyeHeight += tuning.Height.Value; - eyeSeparation += tuning.Separation.Value; - size *= tuning.Size.Value; + forward += tuning.Forward; + eyeHeight += tuning.Height; + eyeSeparation += tuning.Separation; + size *= tuning.Size; } if (i == 0) size *= DvergarConfig.LeftEyeSizeMultiplier; diff --git a/JotunnModStub/EyePositionConfig.cs b/JotunnModStub/EyePositionConfig.cs deleted file mode 100644 index e08c257..0000000 --- a/JotunnModStub/EyePositionConfig.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System.Collections.Generic; -using BepInEx.Configuration; - -namespace RacesOfValheim -{ - /// - /// Hand placement for every race that hangs eyes on the face: one "Eyes Position - race" - /// section each, with a set of sliders per body and per eye. Per body because the two bodies - /// put their painted eyes in different places (PlayerFace); per eye because the face is not - /// symmetric enough for one set to fit both. Left and right are the character's own. - /// - /// Every value is a delta on the placement the race's own code computes: all zeros (and size - /// 1) is the code's own placement, and the female defaults below are the corrections found in - /// game on top of it. - /// - /// Local, never synced (ConfigSync): it only changes how this client draws faces. - /// - public static class EyePositionConfig - { - public const string SectionPrefix = "Eyes Position - "; - - /// One eye's sliders, for one body of one race. - public sealed class Tuning - { - public ConfigEntry Forward; - public ConfigEntry Height; - public ConfigEntry Separation; - public ConfigEntry Size; - - // Only bound for races whose eyes are not spheres; null elsewhere. - public ConfigEntry RotationX; - public ConfigEntry RotationY; - public ConfigEntry RotationZ; - - public float RotX => RotationX != null ? RotationX.Value : 0f; - public float RotY => RotationY != null ? RotationY.Value : 0f; - public float RotZ => RotationZ != null ? RotationZ.Value : 0f; - } - - // [race] -> { male left, male right, female left, female right } - private static readonly Dictionary tunings = new Dictionary(); - - public static void Bind(ConfigFile config) - { - // Defaults dialled in on screen (playtest, 2026-10-27), per eye: female left, female - // right, male left, male right. The Sverm's helmet hides its eyes, so it keeps the - // code's own placement. - BindRace(config, AlfarConfig.RaceId, true, - new Defaults { Separation = 0.006f, RotX = -17.524f }, - new Defaults { Separation = 0.015f, RotX = -17.524f }, - new Defaults(), - new Defaults { Separation = 0.009f }); - - BindRace(config, "Aswid", true, - new Defaults { Forward = -0.006f, Height = -0.010f, Separation = 0f, Size = 1.314f, - RotX = -14.279f, RotY = -5.841f, RotZ = -1.298f }, - new Defaults { Forward = -0.006f, Height = -0.012f, Separation = 0.011f, Size = 1.324f, - RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }, - new Defaults { Height = -0.005f, Separation = -0.005f, Size = 1.273f, - RotX = 6.49f, RotY = 4.544f, RotZ = 4.544f }, - new Defaults { Forward = -0.002f, Height = -0.005f, Separation = 0.004f, Size = 1.444f, - RotZ = 6.49f }); - - BindRace(config, DvergarConfig.RaceId, false, - new Defaults { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }, - new Defaults { Forward = -0.015f, Separation = 0.013f, Size = 1.616f }, - new Defaults { Forward = -0.003f, Size = 1.05f }, - new Defaults { Forward = -0.004f, Separation = 0.005f }); - - BindRace(config, SvermConfig.RaceId, false, new Defaults(), new Defaults(), new Defaults(), new Defaults()); - } - - /// Starting values for one eye's sliders. - private sealed class Defaults - { - public float Forward, Height, Separation, RotX, RotY, RotZ; - public float Size = 1f; - } - - /// - /// The sliders for one eye of the body this player is wearing right now. Side is the - /// races' own convention: negative is offset against the head frame's right axis, which is - /// the character's left eye. - /// - public static Tuning For(string race, Player player, float side) - { - if (!tunings.TryGetValue(race, out Tuning[] set)) return null; - return set[(PlayerFace.IsFemale(player) ? 2 : 0) + (side < 0f ? 0 : 1)]; - } - - private static void BindRace(ConfigFile config, string race, bool rotation, - Defaults femaleLeft, Defaults femaleRight, Defaults maleLeft, Defaults maleRight) - { - string section = SectionPrefix + race; - - // Female first in the list, left before right: Order sorts high to low. - tunings[race] = new[] - { - BindEye(config, section, "Male", "Left", rotation, 200, maleLeft), - BindEye(config, section, "Male", "Right", rotation, 100, maleRight), - BindEye(config, section, "Female", "Left", rotation, 400, femaleLeft), - BindEye(config, section, "Female", "Right", rotation, 300, femaleRight), - }; - } - - private static Tuning BindEye(ConfigFile config, string section, string body, string eye, bool rotation, int order, Defaults d) - { - string prefix = $"{body} {eye} Eye "; - string who = $"{body} characters, {eye.ToLowerInvariant()} eye (the character's own {eye.ToLowerInvariant()})"; - Tuning t = new Tuning(); - - t.Forward = config.Bind(section, prefix + "Forward", d.Forward, - new ConfigDescription($"{who}: moves the eye out of (+) or into (-) the face, in metres.", - new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 9 })); - t.Height = config.Bind(section, prefix + "Height", d.Height, - new ConfigDescription($"{who}: moves the eye up (+) or down (-), in metres.", - new AcceptableValueRange(-0.05f, 0.05f), new ConfigurationManagerAttributes { Order = order + 8 })); - t.Separation = config.Bind(section, prefix + "Separation", d.Separation, - new ConfigDescription($"{who}: moves the eye away from (+) or toward (-) the nose, in metres.", - new AcceptableValueRange(-0.03f, 0.03f), new ConfigurationManagerAttributes { Order = order + 7 })); - t.Size = config.Bind(section, prefix + "Size", d.Size, - new ConfigDescription($"{who}: scales the eye. 1 is the default size.", - new AcceptableValueRange(0.2f, 3f), new ConfigurationManagerAttributes { Order = order + 6 })); - - if (rotation) - { - t.RotationX = config.Bind(section, prefix + "Rotation X", d.RotX, - new ConfigDescription($"{who}: tips the eye down (+) or up (-), in degrees.", - new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 5 })); - t.RotationY = config.Bind(section, prefix + "Rotation Y", d.RotY, - new ConfigDescription($"{who}: turns the eye toward the temple (+) or the nose (-), in degrees.", - new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 4 })); - t.RotationZ = config.Bind(section, prefix + "Rotation Z", d.RotZ, - new ConfigDescription($"{who}: raises (+) or lowers (-) the outer corner, in degrees.", - new AcceptableValueRange(-90f, 90f), new ConfigurationManagerAttributes { Order = order + 3 })); - } - - return t; - } - } -} diff --git a/JotunnModStub/RaceEyeTuning.cs b/JotunnModStub/RaceEyeTuning.cs new file mode 100644 index 0000000..ea55567 --- /dev/null +++ b/JotunnModStub/RaceEyeTuning.cs @@ -0,0 +1,64 @@ +using System.Collections.Generic; + +namespace RacesOfValheim +{ + /// + /// Hand corrections for every race that hangs eyes on the face, per body and per eye. Per body + /// because the two bodies put their painted eyes in different places (PlayerFace); per eye + /// because the face is not symmetric enough for one set to fit both. Left and right are the + /// character's own. + /// + /// Every value is a delta on the placement the race's own code computes: zeros (and size 1) + /// change nothing. They were dialled in on screen with Configuration Manager sliders + /// (playtest, 2026-10-27) and then written down here; the sliders are gone. + /// + public static class RaceEyeTuning + { + /// One eye's corrections. Metres for the offsets, degrees for the rotations. + public sealed class Eye + { + public float Forward, Height, Separation, RotX, RotY, RotZ; + public float Size = 1f; + } + + private static readonly Eye Untouched = new Eye(); + + // [race] -> { male left, male right, female left, female right } + private static readonly Dictionary tunings = new Dictionary + { + [AlfarConfig.RaceId] = new[] + { + new Eye(), + new Eye { Separation = 0.009f }, + new Eye { Separation = 0.006f, RotX = -17.524f }, + new Eye { Separation = 0.015f, RotX = -17.524f }, + }, + ["Aswid"] = new[] + { + new Eye { Height = -0.005f, Separation = -0.005f, Size = 1.273f, RotX = 6.49f, RotY = 4.544f, RotZ = 4.544f }, + new Eye { Forward = -0.002f, Height = -0.005f, Separation = 0.004f, Size = 1.444f, RotZ = 6.49f }, + new Eye { Forward = -0.006f, Height = -0.010f, Size = 1.314f, RotX = -14.279f, RotY = -5.841f, RotZ = -1.298f }, + new Eye { Forward = -0.006f, Height = -0.012f, Separation = 0.011f, Size = 1.324f, RotX = 1.947f, RotY = 3.245f, RotZ = 4.544f }, + }, + [DvergarConfig.RaceId] = new[] + { + new Eye { Forward = -0.003f, Size = 1.05f }, + new Eye { Forward = -0.004f, Separation = 0.005f }, + new Eye { Forward = -0.011f, Separation = 0.005f, Size = 1.616f }, + new Eye { Forward = -0.015f, Separation = 0.013f, Size = 1.616f }, + }, + // The Sverm's helmet hides its eyes, so it keeps the code's own placement. + }; + + /// + /// The corrections for one eye of the body this player is wearing right now. Side is the + /// races' own convention: negative is offset against the head frame's right axis, which is + /// the character's left eye. Never null. + /// + public static Eye For(string race, Player player, float side) + { + if (!tunings.TryGetValue(race, out Eye[] set)) return Untouched; + return set[(PlayerFace.IsFemale(player) ? 2 : 0) + (side < 0f ? 0 : 1)]; + } + } +} diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 5eb3b9b..f075a97 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -56,8 +56,6 @@ namespace RacesOfValheim // Not a race either: the faction truce and the faction merchants, which cut across // every race at once, so they bind last rather than inside the alphabetical run above. FactionsConfig.Bind(Config); - // Not a race either: the hand placement of every race's eyes, one section per race. - EyePositionConfig.Bind(Config); // After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync. ConfigSync.Apply(Config); harmony.PatchAll(); diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index 350a153..dd18e5d 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -263,18 +263,18 @@ namespace RacesOfValheim // Index 0 is offset against the right axis, so it is the model's left eye. float side = i == 0 ? -1f : 1f; - // This eye's sliders from "Eyes Position - Sverm". + // This eye's hand corrections (RaceEyeTuning). float forward = EyeForward; float eyeHeight = height; float eyeSeparation = separation; float size = eyeSize * scale * toLocal; - EyePositionConfig.Tuning tuning = EyePositionConfig.For(SvermConfig.RaceId, player, side); + RaceEyeTuning.Eye tuning = RaceEyeTuning.For(SvermConfig.RaceId, player, side); if (tuning != null) { - forward += tuning.Forward.Value; - eyeHeight += tuning.Height.Value; - eyeSeparation += tuning.Separation.Value; - size *= tuning.Size.Value; + forward += tuning.Forward; + eyeHeight += tuning.Height; + eyeSeparation += tuning.Separation; + size *= tuning.Size; } if (i == 0) size *= LeftEyeSizeMultiplier;