mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Reduce precision of distance checks
Fixes huge maps, such as Dark Race
This commit is contained in:
parent
0fdcc22d93
commit
add1fb8794
2 changed files with 12 additions and 8 deletions
|
|
@ -5736,11 +5736,11 @@ static void K_UpdateDistanceFromFinishLine(player_t *const player)
|
||||||
UINT32 adddist;
|
UINT32 adddist;
|
||||||
fixed_t disttowaypoint =
|
fixed_t disttowaypoint =
|
||||||
P_AproxDistance(
|
P_AproxDistance(
|
||||||
player->mo->x - player->nextwaypoint->mobj->x,
|
(player->mo->x >> FRACBITS) - (player->nextwaypoint->mobj->x >> FRACBITS),
|
||||||
player->mo->y - player->nextwaypoint->mobj->y);
|
(player->mo->y >> FRACBITS) - (player->nextwaypoint->mobj->y >> FRACBITS));
|
||||||
disttowaypoint = P_AproxDistance(disttowaypoint, player->mo->z - player->nextwaypoint->mobj->z);
|
disttowaypoint = P_AproxDistance(disttowaypoint, (player->mo->z >> FRACBITS) - (player->nextwaypoint->mobj->z >> FRACBITS));
|
||||||
|
|
||||||
adddist = ((UINT32)disttowaypoint) >> FRACBITS;
|
adddist = (UINT32)disttowaypoint;
|
||||||
|
|
||||||
player->distancetofinish = pathtofinish.totaldist + adddist;
|
player->distancetofinish = pathtofinish.totaldist + adddist;
|
||||||
Z_Free(pathtofinish.array);
|
Z_Free(pathtofinish.array);
|
||||||
|
|
|
||||||
|
|
@ -221,8 +221,10 @@ waypoint_t *K_GetClosestWaypointToMobj(mobj_t *const mobj)
|
||||||
for (i = 0; i < numwaypoints; i++)
|
for (i = 0; i < numwaypoints; i++)
|
||||||
{
|
{
|
||||||
checkwaypoint = &waypointheap[i];
|
checkwaypoint = &waypointheap[i];
|
||||||
checkdist = P_AproxDistance(mobj->x - checkwaypoint->mobj->x, mobj->y - checkwaypoint->mobj->y);
|
checkdist = P_AproxDistance(
|
||||||
checkdist = P_AproxDistance(checkdist, mobj->z - checkwaypoint->mobj->z);
|
(mobj->x >> FRACBITS) - (checkwaypoint->mobj->x >> FRACBITS),
|
||||||
|
(mobj->y >> FRACBITS) - (checkwaypoint->mobj->y >> FRACBITS));
|
||||||
|
checkdist = P_AproxDistance(checkdist, (mobj->z >> FRACBITS) - (checkwaypoint->mobj->z >> FRACBITS));
|
||||||
|
|
||||||
if (checkdist < closestdist)
|
if (checkdist < closestdist)
|
||||||
{
|
{
|
||||||
|
|
@ -258,8 +260,10 @@ waypoint_t *K_GetBestWaypointTouchingMobj(mobj_t *const mobj)
|
||||||
for (i = 0; i < numwaypoints; i++)
|
for (i = 0; i < numwaypoints; i++)
|
||||||
{
|
{
|
||||||
checkwaypoint = &waypointheap[i];
|
checkwaypoint = &waypointheap[i];
|
||||||
checkdist = P_AproxDistance(mobj->x - checkwaypoint->mobj->x, mobj->y - checkwaypoint->mobj->y);
|
checkdist = P_AproxDistance(
|
||||||
checkdist = P_AproxDistance(checkdist, mobj->z - checkwaypoint->mobj->z);
|
(mobj->x >> FRACBITS) - (checkwaypoint->mobj->x >> FRACBITS),
|
||||||
|
(mobj->y >> FRACBITS) - (checkwaypoint->mobj->y >> FRACBITS));
|
||||||
|
checkdist = P_AproxDistance(checkdist, (mobj->z >> FRACBITS) - (checkwaypoint->mobj->z >> FRACBITS));
|
||||||
|
|
||||||
// The mobj has to be touching this waypoint to update to it.
|
// The mobj has to be touching this waypoint to update to it.
|
||||||
if (checkdist <= checkwaypoint->mobj->radius)
|
if (checkdist <= checkwaypoint->mobj->radius)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue