REVIEW: CheckCollisionSpheres() params naming
This commit is contained in:
parent
f30354fc35
commit
9097d0b4ef
2 changed files with 7 additions and 7 deletions
12
src/models.c
12
src/models.c
|
@ -2745,24 +2745,24 @@ void DrawBoundingBox(BoundingBox box, Color color)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect collision between two spheres
|
// Detect collision between two spheres
|
||||||
bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB)
|
bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2)
|
||||||
{
|
{
|
||||||
bool collision = false;
|
bool collision = false;
|
||||||
|
|
||||||
// Simple way to check for collision, just checking distance between two points
|
// Simple way to check for collision, just checking distance between two points
|
||||||
// Unfortunately, sqrtf() is a costly operation, so we avoid it with following solution
|
// Unfortunately, sqrtf() is a costly operation, so we avoid it with following solution
|
||||||
/*
|
/*
|
||||||
float dx = centerA.x - centerB.x; // X distance between centers
|
float dx = center1.x - center2.x; // X distance between centers
|
||||||
float dy = centerA.y - centerB.y; // Y distance between centers
|
float dy = center1.y - center2.y; // Y distance between centers
|
||||||
float dz = centerA.z - centerB.z; // Z distance between centers
|
float dz = center1.z - center2.z; // Z distance between centers
|
||||||
|
|
||||||
float distance = sqrtf(dx*dx + dy*dy + dz*dz); // Distance between centers
|
float distance = sqrtf(dx*dx + dy*dy + dz*dz); // Distance between centers
|
||||||
|
|
||||||
if (distance <= (radiusA + radiusB)) collision = true;
|
if (distance <= (radius1 + radius2)) collision = true;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Check for distances squared to avoid sqrtf()
|
// Check for distances squared to avoid sqrtf()
|
||||||
if (Vector3DotProduct(Vector3Subtract(centerB, centerA), Vector3Subtract(centerB, centerA)) <= (radiusA + radiusB)*(radiusA + radiusB)) collision = true;
|
if (Vector3DotProduct(Vector3Subtract(center2, center1), Vector3Subtract(center2, center1)) <= (radius1 + radius2)*(radius1 + radius2)) collision = true;
|
||||||
|
|
||||||
return collision;
|
return collision;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1380,7 +1380,7 @@ RLAPI void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float
|
||||||
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 center, float size, Color tint); // Draw a billboard texture defined by source
|
RLAPI void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle source, Vector3 center, float size, Color tint); // Draw a billboard texture defined by source
|
||||||
|
|
||||||
// Collision detection functions
|
// Collision detection functions
|
||||||
RLAPI bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
|
RLAPI bool CheckCollisionSpheres(Vector3 center1, float radius1, Vector3 center2, float radius2); // Detect collision between two spheres
|
||||||
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
RLAPI bool CheckCollisionBoxes(BoundingBox box1, BoundingBox box2); // Detect collision between two bounding boxes
|
||||||
RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Detect collision between box and sphere
|
RLAPI bool CheckCollisionBoxSphere(BoundingBox box, Vector3 center, float radius); // Detect collision between box and sphere
|
||||||
RLAPI bool CheckCollisionRaySphere(Ray ray, Vector3 center, float radius); // Detect collision between ray and sphere
|
RLAPI bool CheckCollisionRaySphere(Ray ray, Vector3 center, float radius); // Detect collision between ray and sphere
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue