Skip to content

Commit 09461ca

Browse files
committed
Tilt UI-Focus camera to work around UIX rendering issues
Adds a workaround for Yellow-Dog-Man/Resonite-Issues#1292
1 parent 6526190 commit 09461ca

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

CommunityBugFixCollection/Locale/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"CommunityBugFixCollection.NonHDRColorClamping.Description": "Korrigiert, dass die nicht-HDR Varianten der Color(X) Kanal-Additionen die Werte nicht limitieren.",
3333
"CommunityBugFixCollection.PauseAnimatorUpdates.Description": "Verhindert, dass Animatoren jeden Frame in alle assoziierten Felder schreiben, obwohl sie nicht am animieren sind.",
3434
"CommunityBugFixCollection.SmoothDraggables.Description": "Umgeht, dass Slider und Joints in Headless-Sessions verrutschen.",
35+
"CommunityBugFixCollection.TiltedUIAlignment.Description": "Kippt die UI-fokussierte Kamera, um UIX-Renderprobleme zum umgehen.",
3536
"CommunityBugFixCollection.StationaryGrabWorldActivation.Description": "Verhindert, dass die Welt-Greifen Fortbewegung den Spieler bei jeder Aktivierung bewegt.",
3637
"CommunityBugFixCollection.UserInspectorAsNonHost.Description": "Sorgt dafür, dass Benutzer-Inspektoren bereits präsente Benutzer auch in Sessions anzeigen, in denen man nicht der Host ist."
3738
}

CommunityBugFixCollection/Locale/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"CommunityBugFixCollection.PauseAnimatorUpdates.Description": "Fixes animators updating all associated fields every frame while enabled but not playing.",
3434
"CommunityBugFixCollection.SmoothDraggables.Description": "Workaround for Sliders and Joints snapping in sessions hosted by a headless.",
3535
"CommunityBugFixCollection.StationaryGrabWorldActivation.Description": "Stops the Grab World Locomotion from moving the player with each activiation.",
36+
"CommunityBugFixCollection.TiltedUIAlignment.Description": "Tilts the UI-Focus camera to work around UIX rendering issues.",
3637
"CommunityBugFixCollection.UserInspectorAsNonHost.Description": "Fixes UserInspectors not listing existing users in the session for non-host users.",
3738
"CommunityBugFixCollection.ValueModDecimal.Description": "Adds a zero check to the Decimal ValueMod ProtoFlux node to prevent DIV/0 crashes"
3839
}
39-
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Elements.Core;
2+
using FrooxEngine;
3+
using HarmonyLib;
4+
using MonkeyLoader.Resonite;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
9+
namespace CommunityBugFixCollection
10+
{
11+
[HarmonyPatchCategory(nameof(TiltedUIAlignment))]
12+
[HarmonyPatch(typeof(UI_TargettingController), nameof(UI_TargettingController.OnBeforeHeadUpdate))]
13+
internal sealed class TiltedUIAlignment : ResoniteMonkey<TiltedUIAlignment>
14+
{
15+
public override IEnumerable<string> Authors => Contributors.Banane9;
16+
17+
public override bool CanBeDisabled => true;
18+
19+
private static void Postfix(UI_TargettingController __instance)
20+
{
21+
if (!Enabled)
22+
return;
23+
24+
var space = __instance.ViewSpace ?? __instance.Slot;
25+
var spacePosition = space.GlobalPosition;
26+
var rootDistance = MathX.Max(1, MathX.MaxComponent(MathX.Abs(spacePosition)));
27+
28+
var rotationAxis = space.Right;
29+
var angle = MathX.Clamp(0.1f, 5, 0.01f * MathX.Sqrt(rootDistance));
30+
31+
// Add angle to camera to prevent flickering
32+
var rotation = floatQ.AxisAngle(rotationAxis, angle);
33+
__instance.ViewRotation *= rotation;
34+
35+
// Adjust position based on angle to frame UI properly still
36+
var antiRotation = floatQ.AxisAngle(rotationAxis, -angle - 2f);
37+
__instance.ViewPosition = __instance._currentCenter + (space.GlobalRotationToLocal(antiRotation) * __instance._currentPlane * __instance._currentDistance);
38+
}
39+
}
40+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ just disable them in the settings in the meantime.
6363

6464
* Sliders and Joints snapping in sessions hosted by a headless (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/399)
6565
* Missing Cloud Home template for Groups (fallback to User Cloud Home) (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1144)
66+
* UIX Rendering issues in UI-Focus mode (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1292)
6667

6768

6869
## Features

0 commit comments

Comments
 (0)