Skip to content

Commit

Permalink
findClosest optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Anuken committed Sep 14, 2024
1 parent 8073823 commit 25e8455
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arc-core/src/arc/math/geom/Geometry.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static <T extends Position> T findClosest(float x, float y, T[] list){
T closest = null;
float cdist = 0f;
for(T t : list){
float dst = t.dst(x, y);
float dst = t.dst2(x, y);
if(closest == null || dst < cdist){
closest = t;
cdist = dst;
Expand All @@ -104,7 +104,7 @@ public static <T extends Position> T findClosest(float x, float y, Iterable<T> l
T closest = null;
float cdist = 0f;
for(T t : list){
float dst = t.dst(x, y);
float dst = t.dst2(x, y);
if(closest == null || dst < cdist){
closest = t;
cdist = dst;
Expand All @@ -117,7 +117,7 @@ public static <T extends Position> T findFurthest(float x, float y, Iterable<T>
T furthest = null;
float fdist = 0f;
for(T t : list){
float dst = t.dst(x, y);
float dst = t.dst2(x, y);
if(furthest == null || dst > fdist){
furthest = t;
fdist = dst;
Expand Down

0 comments on commit 25e8455

Please sign in to comment.