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