aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvictorfisac <victorfisac@gmail.com>2016-01-20 19:26:30 +0100
committervictorfisac <victorfisac@gmail.com>2016-01-20 19:26:30 +0100
commit25f5995be0f52c756052a9fff276bd11e95fc895 (patch)
treebf9bd71745bb9430e1e89a521043b69713f07953 /src
parent423a45ac85c64c578e15a6672bff3ae17c2be44a (diff)
downloadraylib-25f5995be0f52c756052a9fff276bd11e95fc895.tar.gz
raylib-25f5995be0f52c756052a9fff276bd11e95fc895.zip
Revert "Added ray-sphere collision detection"
This reverts commit 423a45ac85c64c578e15a6672bff3ae17c2be44a.
Diffstat (limited to 'src')
-rw-r--r--src/models.c41
-rw-r--r--src/raylib.h2
2 files changed, 3 insertions, 40 deletions
diff --git a/src/models.c b/src/models.c
index daa05b1a..06044820 100644
--- a/src/models.c
+++ b/src/models.c
@@ -1341,42 +1341,7 @@ bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius
{
bool collision = false;
- Vector3 raySpherePos = VectorSubtract(spherePosition, ray.position);
- float distance = VectorLength(raySpherePos);
- float vector = VectorDotProduct(raySpherePos, ray.direction);
- float d = sphereRadius*sphereRadius - (distance*distance - vector*vector);
-
- if(d >= 0.0f) collision = true;
-
- return collision;
-}
-
-// Detect collision between ray and sphere with extended parameters and collision point detection
-bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint)
-{
- bool collision = false;
-
- Vector3 raySpherePos = VectorSubtract(spherePosition, ray.position);
- float distance = VectorLength(raySpherePos);
- float vector = VectorDotProduct(raySpherePos, ray.direction);
- float d = sphereRadius*sphereRadius - (distance*distance - vector*vector);
-
- if(d >= 0.0f) collision = true;
-
- // Calculate collision point
- Vector3 offset = ray.direction;
- float collisionDistance = 0;
-
- // Check if ray origin is inside the sphere to calculate the correct collision point
- if(distance < sphereRadius) collisionDistance = vector + sqrt(d);
- else collisionDistance = vector - sqrt(d);
-
- VectorScale(&offset, collisionDistance);
- Vector3 cPoint = VectorAdd(ray.position, offset);
-
- collisionPoint->x = cPoint.x;
- collisionPoint->y = cPoint.y;
- collisionPoint->z = cPoint.z;
+ // TODO: implement collision...
return collision;
}
@@ -1408,8 +1373,8 @@ bool CheckCollisionRayBox(Ray ray, Vector3 minBBox, Vector3 maxBBox)
BoundingBox CalculateBoundingBox(Mesh mesh)
{
// Get min and max vertex to construct bounds (AABB)
- Vector3 minVertex = {mesh.vertices[0], mesh.vertices[1], mesh.vertices[2]};
- Vector3 maxVertex = {mesh.vertices[0], mesh.vertices[1], mesh.vertices[2]};
+ Vector3 minVertex = mesh.vertices[0];
+ Vector3 maxVertex = mesh.vertices[0];
for (int i = 1; i < mesh.vertexCount; i++)
{
diff --git a/src/raylib.h b/src/raylib.h
index 876d22a9..16311df8 100644
--- a/src/raylib.h
+++ b/src/raylib.h
@@ -770,8 +770,6 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vec
bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres
bool CheckCollisionBoxes(Vector3 minBBox1, Vector3 maxBBox1, Vector3 minBBox2, Vector3 maxBBox2); // Detect collision between two boxes
bool CheckCollisionBoxSphere(Vector3 minBBox, Vector3 maxBBox, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere
-bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius); // Detect collision between ray and sphere
-bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint); // Detect collision between ray and sphere with extended parameters and collision point detection
bool CheckCollisionRayBox(Ray ray, Vector3 minBBox, Vector3 maxBBox); // Detect collision between ray and box
Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius); // Detect collision of player radius with cubicmap
// NOTE: Return the normal vector of the impacted surface