From 23d890c7f93bfdc0b41d09f70f755eee6a92c554 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Tue, 7 May 2024 22:29:56 +0800 Subject: [PATCH] [saco] Implement and match `SquaredDistanceBetweenPoints(...)` --- saco/game/util.cpp | 26 ++++++++++++++++++++++++++ saco/game/util.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/saco/game/util.cpp b/saco/game/util.cpp index a0691c3..6ab197a 100644 --- a/saco/game/util.cpp +++ b/saco/game/util.cpp @@ -1552,6 +1552,32 @@ float __stdcall DistanceBetweenPoints(float x1, float y1, float z1, float x2, fl //---------------------------------------------------- +float __stdcall SquaredDistanceBetweenPoints(float x1, float y1, float z1, float x2, float y2, float z2) +{ + float fSX,fSY,fSZ; + + fSX = (x1 - x2) * (x1 - x2); + fSY = (y1 - y2) * (y1 - y2); + fSZ = (z1 - z2) * (z1 - z2); + + return fSX + fSY + fSZ; +} + +//---------------------------------------------------- + +float __stdcall SquaredDistanceBetweenPoints(VECTOR *vec1, VECTOR *vec2) +{ + float fDX,fDY,fDZ; + + fDZ = vec1->Z - vec2->Z; + fDY = vec1->Y - vec2->Y; + fDX = vec1->X - vec2->X; + + return (fDX * fDX) + (fDY * fDY) + (fDZ * fDZ); +} + +//---------------------------------------------------- + float DegToRad(float fDegrees) { if (fDegrees > 360.0f || fDegrees < 0.0f) return 0.0f; diff --git a/saco/game/util.h b/saco/game/util.h index f09263e..a289b1d 100644 --- a/saco/game/util.h +++ b/saco/game/util.h @@ -34,6 +34,8 @@ BYTE __stdcall FindPlayerNumFromPedPtr(DWORD dwPedPtr); float __stdcall SquaredDistanceBetweenHorizontalPoints(float x1, float y1, float x2, float y2); float DistanceBetweenHorizontalPoints(float x1, float y1, float x2, float y2); float DistanceBetweenPoints(float x1, float y1, float z1, float x2, float y2, float z2); +float __stdcall SquaredDistanceBetweenPoints(float x1, float y1, float z1, float x2, float y2, float z2); +float __stdcall SquaredDistanceBetweenPoints(VECTOR *vec1, VECTOR *vec2); void GameResetRadarColors();