Physics cleanup a bit.

This commit is contained in:
2025-06-20 11:51:36 -05:00
parent 47d5291681
commit 4ac6456489

View File

@ -193,8 +193,6 @@ collisionresult_t physicsCheckCircleTriangle(
fixed248_t closestX = FIXED248_ZERO; fixed248_t closestX = FIXED248_ZERO;
fixed248_t closestY = FIXED248_ZERO; fixed248_t closestY = FIXED248_ZERO;
fixed248_t normalX = FIXED248_ZERO;
fixed248_t normalY = FIXED248_ZERO;
fixed248_t minDistSq = FIXED248_MAX; fixed248_t minDistSq = FIXED248_MAX;
for(uint8_t i = 0; i < 3; ++i) { for(uint8_t i = 0; i < 3; ++i) {
@ -217,8 +215,8 @@ collisionresult_t physicsCheckCircleTriangle(
minDistSq = distSq; minDistSq = distSq;
closestX = testX; closestX = testX;
closestY = testY; closestY = testY;
normalX = dx; result.normalX = dx;
normalY = dy; result.normalY = dy;
} }
} }
@ -229,24 +227,20 @@ collisionresult_t physicsCheckCircleTriangle(
FIXED248_ONE FIXED248_ONE
); );
fixed248_t nx = fx248Mulfx248(-normalX, invDist); result.normalX = fx248Mulfx248(-result.normalX, invDist);
fixed248_t ny = fx248Mulfx248(-normalY, invDist); result.normalY = fx248Mulfx248(-result.normalY, invDist);
if(physicsIsPointInTriangle( if(physicsIsPointInTriangle(
circleX, circleY, vx[0], vy[0], vx[1], vy[1], vx[2], vy[2] circleX, circleY, vx[0], vy[0], vx[1], vy[1], vx[2], vy[2]
)) { )) {
result.hit = true; result.hit = true;
result.depth = fx248Subfx248(circleR, dist); result.depth = fx248Subfx248(circleR, dist);
result.normalX = nx;
result.normalY = ny;
return result; return result;
} }
if(dist < circleR) { if(dist < circleR) {
result.hit = true; result.hit = true;
result.depth = fx248Subfx248(circleR, dist); result.depth = fx248Subfx248(circleR, dist);
result.normalX = nx;
result.normalY = ny;
} }
return result; return result;