Working on different collider types.

This commit is contained in:
2023-04-01 21:59:48 -07:00
parent d4fb2968ad
commit 5ff8489a39
11 changed files with 250 additions and 88 deletions

View File

@ -77,5 +77,23 @@ bool_t Dawn::boxCheckCollision(
entryPoint = posA + velocity * entryTime;
exitPoint = posA + velocity * exitTime;
return true;
}
bool_t Dawn::boxIsBoxColliding(
glm::vec2 posA, glm::vec2 minA, glm::vec2 maxA,
glm::vec2 posB, glm::vec2 minB, glm::vec2 maxB
) {
// Check for no overlap in X axis
if (posA.x + maxA.x < posB.x + minB.x || posA.x + minA.x > posB.x + maxB.x) {
return false;
}
// Check for no overlap in Y axis
if (posA.y + maxA.y < posB.y + minB.y || posA.y + minA.y > posB.y + maxB.y) {
return false;
}
// There is overlap in both X and Y axis, so the boxes are colliding
return true;
}

View File

@ -20,6 +20,22 @@ namespace Dawn {
glm::vec2 &exitPoint
);
/**
* Checks if two boxes are colliding.
*
* @param posA Position of the first box.
* @param minA Minimum point on the first box.
* @param maxA Maximum point on the first box.
* @param posB Position of the second box.
* @param minB Minimum point on the second box.
* @param maxB Maximum point on the second box.
* @return True if the boxes are colliding with each other, false otherwise.
*/
bool_t boxIsBoxColliding(
glm::vec2 posA, glm::vec2 minA, glm::vec2 maxA,
glm::vec2 posB, glm::vec2 minB, glm::vec2 maxB
);
/**
* Checks if a given point is within the 2D Boundaries of an object.
*