From d3dae384497f61ad7eb1d9578db8860e6e6336aa Mon Sep 17 00:00:00 2001 From: ProfJski <49599659+ProfJski@users.noreply.github.com> Date: Wed, 8 May 2019 13:54:12 -0400 Subject: [PATCH 1/2] Update CheckCollisionSpheres() to avoid sqrt Square root calls are computationally expensive. In this case, they can be avoided. Instead of checking distance Date: Wed, 8 May 2019 14:14:57 -0400 Subject: [PATCH 2/2] Update models.c --- src/models.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models.c b/src/models.c index 9e534a7c..fc93c141 100644 --- a/src/models.c +++ b/src/models.c @@ -2472,7 +2472,7 @@ void DrawBoundingBox(BoundingBox box, Color color) // Detect collision between two spheres bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB) { - return Vector3DotProduct(Vector3Subtract(B,A),Vector3Subtract(B,A))<=(RadA+RadB)*(RadA+RadB); + return Vector3DotProduct(Vector3Subtract(centerB,centerA),Vector3Subtract(centerB,centerA))<=(radiusA+radiusB)*(radiusA+radiusB); } // Detect collision between two boxes