From 176b9d059fb674d63abb1710a9c33aab096a79c9 Mon Sep 17 00:00:00 2001 From: RebeccaNod1 Date: Mon, 27 Apr 2026 17:07:27 -0600 Subject: [PATCH] Fix #120: Resolve global position of seated avatars for accurate Nearme radar tracking --- SecondBotEvents/Commands/Avatars.cs | 16 +++++++++++----- SecondBotEvents/Commands/Core.cs | 4 ++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/SecondBotEvents/Commands/Avatars.cs b/SecondBotEvents/Commands/Avatars.cs index 511c89d..f47b10b 100644 --- a/SecondBotEvents/Commands/Avatars.cs +++ b/SecondBotEvents/Commands/Avatars.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using OpenMetaverse; using System.Text.Json; @@ -83,14 +83,20 @@ namespace SecondBotEvents.Commands { if (av.ID != GetClient().Self.AgentID) { + Vector3 globalPos = av.Position; + if (av.ParentID != 0 && GetClient().Network.CurrentSim.ObjectsPrimitives.TryGetValue(av.ParentID, out Primitive parentObj)) + { + globalPos = parentObj.Position + (av.Position * parentObj.Rotation); + } + NearMeDetails details = new() { id = av.ID.ToString(), name = av.Name, - x = (int)Math.Round(av.Position.X), - y = (int)Math.Round(av.Position.Y), - z = (int)Math.Round(av.Position.Z), - range = (int)Math.Round(Vector3.Distance(av.Position, GetClient().Self.SimPosition)) + x = (int)Math.Round(globalPos.X), + y = (int)Math.Round(globalPos.Y), + z = (int)Math.Round(globalPos.Z), + range = Math.Round(Vector3.Distance(globalPos, GetClient().Self.SimPosition), 2) }; BetterNearMe.Add(details); } diff --git a/SecondBotEvents/Commands/Core.cs b/SecondBotEvents/Commands/Core.cs index b4ece4d..6e35b03 100644 --- a/SecondBotEvents/Commands/Core.cs +++ b/SecondBotEvents/Commands/Core.cs @@ -1,4 +1,4 @@ -using SecondBotEvents.Services; +using SecondBotEvents.Services; namespace SecondBotEvents.Commands { @@ -28,7 +28,7 @@ namespace SecondBotEvents.Commands public int x { get; set; } public int y { get; set; } public int z { get; set; } - public int range { get; set; } + public double range { get; set; } }