From fcb65951b86c3aa207a344f24101fe1d2099c26b Mon Sep 17 00:00:00 2001
From: MPC <lazymyuutsu@gmail.com>
Date: Thu, 20 Dec 2018 17:37:06 -0300
Subject: [PATCH] change implementation of square root

---
 src/m_fixed.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/m_fixed.c b/src/m_fixed.c
index 412494e3ed..bfbe81f950 100644
--- a/src/m_fixed.c
+++ b/src/m_fixed.c
@@ -125,7 +125,10 @@ fixed_t FixedEuclidean(fixed_t x2, fixed_t y2, fixed_t x1, fixed_t y1)
 {
 	INT64 dx = x2-x1;
 	INT64 dy = y2-y1;
-	return (fixed_t)llrint(sqrt(dx*dx+dy*dy));
+	union {INT64 i; float x;} u;
+	u.x = (dx*dx+dy*dy);
+	u.i = (1<<29) + (u.i >> 1) - (1<<22);
+	return (fixed_t)llrintf(u.x);
 }
 
 vector2_t *FV2_Load(vector2_t *vec, fixed_t x, fixed_t y)
-- 
GitLab