perf: use squared distance for nearby
This commit is contained in:
parent
5f9787884b
commit
cf16b931bb
@ -251,7 +251,7 @@ internal class Messages : IDisposable {
|
|||||||
|
|
||||||
internal IEnumerable<Message> Nearby() {
|
internal IEnumerable<Message> Nearby() {
|
||||||
if (this.Plugin.ClientState.LocalPlayer is not { } player) {
|
if (this.Plugin.ClientState.LocalPlayer is not { } player) {
|
||||||
return Array.Empty<Message>();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
var position = player.Position;
|
var position = player.Position;
|
||||||
@ -262,13 +262,12 @@ internal class Messages : IDisposable {
|
|||||||
nearby = this.Current
|
nearby = this.Current
|
||||||
.Values
|
.Values
|
||||||
.Where(msg => Math.Abs(msg.Position.Y - position.Y) <= 1f)
|
.Where(msg => Math.Abs(msg.Position.Y - position.Y) <= 1f)
|
||||||
.Where(msg => Vector3.Distance(msg.Position, position) <= 2f)
|
.Where(msg => Vector3.DistanceSquared(msg.Position, position) <= 4f)
|
||||||
.ToList();
|
.ToList();
|
||||||
} finally {
|
} finally {
|
||||||
this.CurrentMutex.Release();
|
this.CurrentMutex.Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return nearby;
|
return nearby;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ internal class ActorManager : IDisposable {
|
|||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
this._tasks.Dequeue();
|
this._tasks.Dequeue();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user