Added some functions (incomplete)
This commit is contained in:
parent
036e77939f
commit
29c618a35e
38
src/models.c
38
src/models.c
@ -1336,7 +1336,17 @@ bool CheckCollisionBoxSphere(Vector3 minBBox, Vector3 maxBBox, Vector3 centerSph
|
||||
return collision;
|
||||
}
|
||||
|
||||
// Detect collision between ray and box
|
||||
// Detect collision between ray and sphere
|
||||
bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius)
|
||||
{
|
||||
bool collision = false;
|
||||
|
||||
// TODO: implement collision...
|
||||
|
||||
return collision;
|
||||
}
|
||||
|
||||
// Detect collision between ray and bounding box
|
||||
bool CheckCollisionRayBox(Ray ray, Vector3 minBBox, Vector3 maxBBox)
|
||||
{
|
||||
bool collision = false;
|
||||
@ -1359,6 +1369,32 @@ bool CheckCollisionRayBox(Ray ray, Vector3 minBBox, Vector3 maxBBox)
|
||||
// TODO: Useful function to check collision area?
|
||||
//BoundingBox GetCollisionArea(BoundingBox box1, BoundingBox box2)
|
||||
|
||||
// Calculate mesh bounding box limits
|
||||
BoundingBox CalculateBoundingBox(Mesh mesh)
|
||||
{
|
||||
// Get min and max vertex to construct bounds (AABB)
|
||||
Vector3 minVertex = mesh.vertices[0];
|
||||
Vector3 maxVertex = mesh.vertices[0];
|
||||
|
||||
for (int i = 1; i < mesh.vertexCount; i++)
|
||||
{
|
||||
// TODO: Compare min and max with previous vertex
|
||||
//minVertex = Vector3.Min(minVertex, mesh.vertices[i]);
|
||||
//maxVertex = Vector3.Max(maxVertex, mesh.vertices[i]);
|
||||
}
|
||||
|
||||
// NOTE: For OBB, transform mesh by model transform matrix
|
||||
//minVertex = VectorTransform(meshMin, mesh.transform);
|
||||
//maxVertex = VectorTransform(meshMax, mesh.transform);
|
||||
|
||||
// Create the bounding box
|
||||
BoundingBox box;
|
||||
box.min = minVertex;
|
||||
box.max = maxVertex;
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
// Detect and resolve cubicmap collisions
|
||||
// NOTE: player position (or camera) is modified inside this function
|
||||
Vector3 ResolveCollisionCubicmap(Image cubicmap, Vector3 mapPosition, Vector3 *playerPosition, float radius)
|
||||
|
Loading…
Reference in New Issue
Block a user