Working on different collider types.
This commit is contained in:
@ -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;
|
||||
}
|
@ -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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user