Skip to content

Commit c9a0cb2

Browse files
committed
Add null-checks in the TrackedDevicePositioner component's UpdateBodyNode method to prevent log spam
Adds a fix for Yellow-Dog-Man/Resonite-Issues#5182
1 parent 0c3e6bf commit c9a0cb2

5 files changed

Lines changed: 79 additions & 1 deletion

File tree

CommunityBugFixCollection/Locale/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"CommunityBugFixCollection.PauseAnimatorUpdates.Description": "Verhindert, dass Animatoren jeden Frame in alle assoziierten Felder schreiben, obwohl sie nicht am animieren sind.",
4242
"CommunityBugFixCollection.ReallyNoDestroyUndo.Description": "Sorgt dafür, dass die NoDestroyUndo Komponente tatsächlich verhindert, dass das Zerstören eines Objekts rückgängig gemacht werden kann.",
4343
"CommunityBugFixCollection.SmoothDraggables.Description": "Umgeht, dass Slider und Joints in Headless-Sessions verrutschen.",
44+
"CommunityBugFixCollection.StopTrackedDeviceSpam.Description": "Fügt null-Checks in der UpdateBodyNode-Methode der TrackedDevicePositioner-Komponente hinzu, um Logspam zu verhindern.",
4445
"CommunityBugFixCollection.TiltedUIAlignment.Description": "Kippt die UI-fokussierte Kamera, um UIX-Renderprobleme zum umgehen.",
4546
"CommunityBugFixCollection.SteamVRFocusResolutionScale.Description": "Verhindert, dass das SteamVR Unity Plugin die Renderauflösung dauerhaft verringert, wenn ein Fokusevent verpasst wird.",
4647
"CommunityBugFixCollection.StationaryGrabWorldActivation.Description": "Verhindert, dass die Welt-Greifen Fortbewegung den Spieler bei jeder Aktivierung bewegt.",

CommunityBugFixCollection/Locale/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"CommunityBugFixCollection.SmoothDraggables.Description": "Workaround for Sliders and Joints snapping in sessions hosted by a headless.",
5050
"CommunityBugFixCollection.StationaryGrabWorldActivation.Description": "Stops the Grab World Locomotion from moving the player with each activiation.",
5151
"CommunityBugFixCollection.SteamVRFocusResolutionScale.Description": "Prevents the SteamVR Unity plugin from permanently lowering the render resolution when a focus event is missed.",
52+
"CommunityBugFixCollection.StopTrackedDeviceSpam.Description": "Adds null-checks in the TrackedDevicePositioner component's UpdateBodyNode method to prevent log spam.",
5253
"CommunityBugFixCollection.TiltedUIAlignment.Description": "Tilts the UI-Focus camera to work around UIX rendering issues.",
5354
"CommunityBugFixCollection.ValidQuaternionInputs.Description": "Makes the ProtoFlux Tool spawn valid float and double quaternion inputs.",
5455
"CommunityBugFixCollection.ValueModDecimal.Description": "Adds a zero check to the Decimal ValueMod ProtoFlux node to prevent DIV/0 crashes.",
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
using Elements.Core;
2+
using FrooxEngine;
3+
using FrooxEngine.CommonAvatar;
4+
using HarmonyLib;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace CommunityBugFixCollection
12+
{
13+
[HarmonyPatchCategory(nameof(StopTrackedDeviceSpam))]
14+
[HarmonyPatch(typeof(TrackedDevicePositioner), nameof(TrackedDevicePositioner.UpdateBodyNode))]
15+
internal sealed class StopTrackedDeviceSpam : ResoniteBugFixMonkey<StopTrackedDeviceSpam>
16+
{
17+
public override IEnumerable<string> Authors => Contributors.Banane9;
18+
19+
[HarmonyPatch()]
20+
private static bool Prefix(TrackedDevicePositioner __instance)
21+
{
22+
if (!Enabled)
23+
return true;
24+
25+
if (__instance.TrackedDevice is not ITrackedDevice device)
26+
return false;
27+
28+
var bodyNode = device.CorrespondingBodyNode;
29+
if (__instance.ObjectSlot.Target is not null && __instance.UsingExternalObjectSlot)
30+
{
31+
if (__instance.ObjectSlot.Target.Node.Value == bodyNode)
32+
return false;
33+
34+
__instance.ObjectSlot.Target = null!;
35+
}
36+
37+
var target = __instance.ObjectSlot.Target;
38+
if (target is null || target.Node.Value != bodyNode)
39+
{
40+
var existingBodyNode = __instance.LocalUserRoot.GetRegisteredComponent((AvatarObjectSlot s) => s.Node.Value == bodyNode);
41+
42+
if (existingBodyNode != null)
43+
{
44+
UniLog.Log($"Device corresponding body node: {bodyNode}. Exiting: {__instance.ObjectSlot.Target?.Node.Value}");
45+
46+
__instance.RemoveBodyNode();
47+
__instance.ObjectSlot.Target = existingBodyNode;
48+
49+
return false;
50+
}
51+
}
52+
53+
if (__instance.CreateAvatarObjectSlot.Value)
54+
__instance.UpdateObjectSlot();
55+
56+
if (__instance.BodyNodeRoot.Target.FilterWorldElement() is not null)
57+
{
58+
if (device.IsDeviceActive)
59+
{
60+
__instance.BodyNodeRoot.Target.LocalPosition = device.BodyNodePositionOffset;
61+
__instance.BodyNodeRoot.Target.LocalRotation = device.BodyNodeRotationOffset;
62+
}
63+
else
64+
{
65+
__instance.BodyNodeRoot.Target.LocalPosition = float3.Zero;
66+
__instance.BodyNodeRoot.Target.LocalRotation = floatQ.Identity;
67+
}
68+
}
69+
70+
if (__instance.ObjectSlot.Target!.FilterWorldElement() is not null)
71+
__instance.ObjectSlot.Target!.Node.Value = bodyNode;
72+
73+
return false;
74+
}
75+
}
76+
}

CommunityBugFixCollection/ValidQuaternionInputs.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using FrooxEngine.ProtoFlux;
33
using FrooxEngine.ProtoFlux.Runtimes.Execution.Nodes;
44
using HarmonyLib;
5-
using MonkeyLoader;
65
using System;
76
using System.Collections.Generic;
87
using System.Text;

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ just disable them in the settings in the meantime.
5959
* Animators updating all associated fields every frame while enabled but not playing (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3480)
6060
* Grid World floor shaking on AMD and Intel GPUs (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3829)
6161
* DuplicateSlot ProtoFlux node crashes game when if OverrideParent is identical to Template (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3950)
62+
* Log spam from `TrackedDevicePositioner.UpdateBodyNode()` in certain scenarios (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/5182)
6263

6364
Fixes with no issue (that could be found).
6465
* Content of notification being off-center.

0 commit comments

Comments
 (0)