소스 검색

Merge pull request #1 from ProfJski/ProfJski-patch-1

Update CheckCollisionSpheres() to avoid sqrt
pull/832/head
ProfJski 5 년 전
committed by GitHub
부모
커밋
4330b098f3
No known key found for this signature in database GPG 키 ID: 4AEE18F83AFDEB23
1개의 변경된 파일1개의 추가작업 그리고 11개의 파일을 삭제
  1. +1
    -11
      src/models.c

+ 1
- 11
src/models.c 파일 보기

@ -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(B,A),Vector3Subtract(B,A))<=(RadA+RadB)*(RadA+RadB);
}
// Detect collision between two boxes

불러오는 중...
취소
저장