Merge pull request #124 from RebeccaNod1/main

Fix #120: Resolve inaccurate radar distances for seated avatars in NearmeWithDetails
This commit is contained in:
Madpeter 2026-05-01 19:00:49 +01:00 committed by GitHub
commit ce1274fd84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 7 deletions

View file

@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
using System.Text.Json; using System.Text.Json;
@ -83,14 +83,20 @@ namespace SecondBotEvents.Commands
{ {
if (av.ID != GetClient().Self.AgentID) 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() NearMeDetails details = new()
{ {
id = av.ID.ToString(), id = av.ID.ToString(),
name = av.Name, name = av.Name,
x = (int)Math.Round(av.Position.X), x = (int)Math.Round(globalPos.X),
y = (int)Math.Round(av.Position.Y), y = (int)Math.Round(globalPos.Y),
z = (int)Math.Round(av.Position.Z), z = (int)Math.Round(globalPos.Z),
range = (int)Math.Round(Vector3.Distance(av.Position, GetClient().Self.SimPosition)) range = Math.Round(Vector3.Distance(globalPos, GetClient().Self.SimPosition), 2)
}; };
BetterNearMe.Add(details); BetterNearMe.Add(details);
} }

View file

@ -1,4 +1,4 @@
using SecondBotEvents.Services; using SecondBotEvents.Services;
namespace SecondBotEvents.Commands namespace SecondBotEvents.Commands
{ {
@ -28,7 +28,7 @@ namespace SecondBotEvents.Commands
public int x { get; set; } public int x { get; set; }
public int y { get; set; } public int y { get; set; }
public int z { get; set; } public int z { get; set; }
public int range { get; set; } public double range { get; set; }
} }