From f82e249ab7a107da3155df6089f803343337ee75 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Sun, 9 Aug 2026 21:28:50 -0400 Subject: Fix lights Enable/Disable All buttons, better sort Signed-off-by: Andrew Opalach --- Lights.cs | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 103 insertions(+), 15 deletions(-) (limited to 'Lights.cs') diff --git a/Lights.cs b/Lights.cs index 2670af4..c0409d1 100644 --- a/Lights.cs +++ b/Lights.cs @@ -273,6 +273,7 @@ namespace WorldTuningTool public int TargetNo => MemoryUtil.Read(Object + 0x614); public nint Texture => MemoryUtil.Read(Object + 0x670); public nint ShadowCacheResource => MemoryUtil.Read(Object + 0x698); + public Vector3 Position => MemoryUtil.Read(Object + 0x5A0); public uSpotLight(nint lightObject) : base(lightObject) { @@ -533,7 +534,8 @@ namespace WorldTuningTool private List newLights = new List(); private List sceneLights = new List(); - private bool sortByDistanceToPlayer = false; + private bool sortByDistanceToPlayerPoint = false; + private bool sortByDistanceToPlayerSpot = false; private NativeAction addToScene; private NativeAction removeFromScene; @@ -817,7 +819,7 @@ namespace WorldTuningTool bool disableAll = ImGui.Button("Disable All"); if (ImGui.BeginItemTooltip()) { - ImGui.Text("Set \"Group\" to 0, Disable \"Shadow Cast\" and \"Do Volumetric\"."); + ImGui.Text("Set \"Group\" to 0, \"Intensity\" to 0.0 and Disable \"Shadow Cast\" and \"Do Volumetric\"."); ImGui.EndTooltip(); } ImGui.SameLine(); @@ -829,16 +831,58 @@ namespace WorldTuningTool { light.Parameters[0].ForceOverrideOn(); light.Parameters[0].SetOverrideValue(default, 0); + light.Parameters[3].ForceOverrideOn(); + light.Parameters[3].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); light.Parameters[7].ForceOverrideOn(); light.Parameters[7].SetOverrideValue(default, 0); light.Parameters[16].ForceOverrideOn(); light.Parameters[16].SetOverrideValue(default, 0); + if (light is uLlkPointLight) + { + light.Parameters[21].ForceOverrideOn(); + light.Parameters[21].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } + if (light is uLlkSpotLight) + { + light.Parameters[32].ForceOverrideOn(); + light.Parameters[32].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } + if (light is uHemiSphereLight) + { + light.Parameters[18].ForceOverrideOn(); + light.Parameters[18].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } + if (light is uLlkHemiSphereLight) + { + light.Parameters[21].ForceOverrideOn(); + light.Parameters[21].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + light.Parameters[23].ForceOverrideOn(); + light.Parameters[23].SetOverrideValue(new Vector4(0.0f, 0.0f, 0.0f, 0.0f), 0); + } } if (enableAll) { light.Parameters[0].ForceOverrideOff(); + light.Parameters[3].ForceOverrideOff(); light.Parameters[7].ForceOverrideOff(); light.Parameters[16].ForceOverrideOff(); + if (light is uLlkPointLight) + { + light.Parameters[21].ForceOverrideOff(); + } + if (light is uLlkSpotLight) + { + light.Parameters[32].ForceOverrideOff(); + } + if (light is uHemiSphereLight) + { + light.Parameters[18].ForceOverrideOff(); + } + if (light is uLlkHemiSphereLight) + { + light.Parameters[21].ForceOverrideOff(); + light.Parameters[23].ForceOverrideOff(); + } } if (ImGui.CollapsingHeader(($"{light.Name} ({light.Info})"))) { @@ -923,33 +967,41 @@ namespace WorldTuningTool ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags.Framed; if (ImGui.TreeNodeEx("Scene Lights", flags)) { + ImGui.PushID("Infinite"); if (ImGui.CollapsingHeader("Infinite")) { DrawLights(sceneLights.Where(x => (x.Type == 1)), width); ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("Point"); if (ImGui.CollapsingHeader("Point")) { - ImGui.Checkbox("Sort By Distance To Player", ref sortByDistanceToPlayer); + ImGui.Checkbox("Sort By Distance To Player", ref sortByDistanceToPlayerPoint); ImGui.SameLine(); - if (sortByDistanceToPlayer) + if (sortByDistanceToPlayerPoint) { Vector3 pos = default; Player? player = Player.MainPlayer; - if (player != null) + if (player != null) pos = player.Position; + DrawLights(Enumerable.OrderBy(sceneLights.Where(x => (x.Type == 2)), x => x, Comparer.Create((x, y) => { - pos = player.Position; - } - uLight[] pointLights = sceneLights.Where(x => (x.Type == 2)).ToArray(); - Array.Sort(pointLights, delegate(uLight x, uLight y) - { - float distX = Vector3.Distance(pos, ((uPointLight)x).Position); - float distY = Vector3.Distance(pos, ((uPointLight)y).Position); + Vector3 xPos = ((uPointLight)x).Position; + if (((uPointLight)x).Parent != 0x0) + { + xPos += MemoryUtil.GetRef(((uPointLight)x).Parent + 0x160); + } + Vector3 yPos = ((uPointLight)y).Position; + if (((uPointLight)y).Parent != 0x0) + { + yPos += MemoryUtil.GetRef(((uPointLight)y).Parent + 0x160); + } + float distX = Vector3.Distance(pos, xPos); + float distY = Vector3.Distance(pos, yPos); if (distX < distY) return -1; else if (distX > distY) return 1; return 0; - }); - DrawLights(pointLights, width); + })), width); } else { @@ -957,20 +1009,56 @@ namespace WorldTuningTool } ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("Spot"); if (ImGui.CollapsingHeader("Spot")) { - DrawLights(sceneLights.Where(x => (x.Type == 3)), width); + ImGui.Checkbox("Sort By Distance To Player", ref sortByDistanceToPlayerSpot); + ImGui.SameLine(); + if (sortByDistanceToPlayerSpot) + { + Vector3 pos = default; + Player? player = Player.MainPlayer; + if (player != null) pos = player.Position; + DrawLights(Enumerable.OrderBy(sceneLights.Where(x => (x.Type == 3)), x => x, Comparer.Create((x, y) => + { + Vector3 xPos = ((uSpotLight)x).Position; + if (((uSpotLight)x).Parent != 0x0) + { + xPos += MemoryUtil.GetRef(((uSpotLight)x).Parent + 0x160); + } + Vector3 yPos = ((uSpotLight)y).Position; + if (((uSpotLight)y).Parent != 0x0) + { + yPos += MemoryUtil.GetRef(((uSpotLight)y).Parent + 0x160); + } + float distX = Vector3.Distance(pos, xPos); + float distY = Vector3.Distance(pos, yPos); + if (distX < distY) return -1; + else if (distX > distY) return 1; + return 0; + })), width); + } + else + { + DrawLights(sceneLights.Where(x => (x.Type == 3)), width); + } ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("HemiSphere"); if (ImGui.CollapsingHeader("Hemi Sphere")) { DrawLights(sceneLights.Where(x => (x.Type == 4)), width); ImGui.Separator(); } + ImGui.PopID(); + ImGui.PushID("Other"); if (ImGui.CollapsingHeader("Other")) { DrawLights(sceneLights.Where(x => (x.Type == -1 || x.Type == 5)), width); } + ImGui.PopID(); ImGui.TreePop(); } ImGui.PopID(); -- cgit v1.2.3-101-g0448