Pārlūkot izejas kodu

Merge pull request #832 from ProfJski/master

Remove sqrt() from CheckCollisionSpheres()
pull/833/head
Ray pirms 5 gadiem
committed by GitHub
vecāks
revīzija
5fd3f13cb6
Šim parakstam datu bāzē netika atrasta zināma atslēga GPG atslēgas ID: 4AEE18F83AFDEB23
1 mainītis faili ar 1 papildinājumiem un 11 dzēšanām
  1. +1
    -11
      src/models.c

+ 1
- 11
src/models.c Parādīt failu

@ -2472,17 +2472,7 @@ void DrawBoundingBox(BoundingBox box, Color color)
// Detect collision between two spheres
bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB)
{
bool collision = false;
float dx = centerA.x - centerB.x; // X distance between centers
float dy = centerA.y - centerB.y; // Y distance between centers
float dz = centerA.z - centerB.z; // Y distance between centers
float distance = sqrtf(dx*dx + dy*dy + dz*dz); // Distance between centers
if (distance <= (radiusA + radiusB)) collision = true;
return collision;
return Vector3DotProduct(Vector3Subtract(centerB,centerA),Vector3Subtract(centerB,centerA))<=(radiusA+radiusB)*(radiusA+radiusB);
}
// Detect collision between two boxes

Notiek ielāde…
Atcelt
Saglabāt