Committing current progress.

This commit is contained in:
2021-08-19 11:18:56 -07:00
parent 1b90e20187
commit 765116435e
10 changed files with 199 additions and 37 deletions

View File

@ -10,7 +10,7 @@
bool aabbPoint2D(
float pointX, float pointY,
float x, float y, float width, float height,
aabbpointhit_t *hit
aabbpointhit2d_t *hit
) {
float dx, px, sx, halfWidth;
@ -55,3 +55,46 @@ bool aabbPoint2D(
return true;
}
bool aabbVector2D(
float x, float y,
float vx, float vy,
float bx, float by, float width, float height,
aabbvectorhit2d_t *hit
) {
// float halfWidth = width / 2.0;
// float halfHeight = height / 2.0;
// float paddingX = 0;
// float paddingY = 0;
// float scaleX = 1.0 / vx;
// float scaleY = 1.0 / vy;
// float signX = mathSign(scaleX);
// float signY = mathSign(scaleY);
// float nearTimeX = (bx - signX * (halfWidth + paddingX) - bx) * scaleX;
// float nearTimeY = (by - signY * (halfHeight + paddingY) - by) * scaleY;
// float farTimeX = (bx + signX * (halfWidth + paddingX) - bx) * scaleX;
// float farTimeY = (by + signY * (halfHeight + paddingY) - by) * scaleY;
// if(nearTimeX > farTimeY || nearTimeY > farTimeX) return false;
// float nearTime = nearTimeX > nearTimeY ? nearTimeX : nearTimeY;
// float farTime = farTimeX < farTimeY ? farTimeX : farTimeY;
// if (nearTime >= 1 || farTime <= 0) return false;
// hit->time = mathClamp(nearTime, 0, 1);
// if(nearTimeX > nearTimeY) {
// hit->normalX = -signX;
// hit->normalY = 0;
// } else {
// hit->normalX = 0;
// hit->normalY = -signY;
// }
// float deltaX = (1.0 - hit->time) * -vx;
// float deltaY = (1.0 - hit->time) * -vy;
// hit->hitX = bx + deltaX * hit->time;
// hit->hitY = by + deltaY * hit->time;
return true;
}

View File

@ -13,5 +13,11 @@
bool aabbPoint2D(
float pointX, float pointY,
float x, float y, float width, float height,
aabbpointhit_t *hit
aabbpointhit2d_t *hit
);
bool aabbVector2D(
float x, float y, float vx, float vy,
float bx, float by, float width, float height,
aabbvectorhit2d_t *vector
);