mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Additional clipmove() reworks
This fixes a LOT of clipping errors but needs thorough testing. git-svn-id: https://svn.eduke32.com/eduke32@7829 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
17d3c302a3
commit
52db0e37f7
1 changed files with 20 additions and 23 deletions
|
@ -1328,36 +1328,39 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
|
|||
|
||||
do
|
||||
{
|
||||
for (native_t i=clipnum-1;i>=0;--i)
|
||||
{
|
||||
if (clipinsideboxline(pos->x, pos->y, clipit[i].x1, clipit[i].y1, clipit[i].x2, clipit[i].y2, walldist))
|
||||
{
|
||||
keepaway(&pos->x, &pos->y, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vec2_t vec = goal;
|
||||
|
||||
hitwall = raytrace(pos->x, pos->y, &vec.x, &vec.y);
|
||||
if (hitwall >= 0)
|
||||
if ((hitwall = raytrace(pos->x, pos->y, &vec.x, &vec.y)) >= 0)
|
||||
{
|
||||
vec2_t const clipr = { clipit[hitwall].x2 - clipit[hitwall].x1, clipit[hitwall].y2 - clipit[hitwall].y1 };
|
||||
uint64_t const tempull = (int64_t)clipr.x * (int64_t)clipr.x + (int64_t)clipr.y * (int64_t)clipr.y;
|
||||
int64_t const templl = (int64_t)clipr.x * clipr.x + (int64_t)clipr.y * clipr.y;
|
||||
|
||||
if (tempull > 0 && tempull < INT32_MAX)
|
||||
if (templl > 0)
|
||||
{
|
||||
int32_t const tempint2 = (int32_t) tempull;
|
||||
int32_t const tempint1 = (goal.x-vec.x)*clipr.x+(goal.y-vec.y)*clipr.y;
|
||||
int32_t const i = ((klabs(tempint1)>>11) < tempint2) ? divscale20(tempint1, tempint2) : 0;
|
||||
int64_t const templl2 = (int64_t)(goal.x-vec.x)*clipr.x + (int64_t)(goal.y-vec.y)*clipr.y;
|
||||
int32_t const i = ((llabs(templl2)>>11) < templl) ? divscale64(templl2, templl, 20) : 0;
|
||||
|
||||
goal = { mulscale20(clipr.x, i)+vec.x, mulscale20(clipr.y, i)+vec.y };
|
||||
}
|
||||
|
||||
int32_t const tempint1 = dmulscale6(clipr.x, move.x, clipr.y, move.y);
|
||||
int32_t const tempint = dmulscale6(clipr.x, move.x, clipr.y, move.y);
|
||||
|
||||
for (native_t i=cnt+1, j; i<=clipmoveboxtracenum; ++i)
|
||||
{
|
||||
j = hitwalls[i];
|
||||
int32_t const tempint2 = dmulscale6(clipit[j].x2 - clipit[j].x1, move.x, clipit[j].y2 - clipit[j].y1, move.y);
|
||||
|
||||
if ((tempint1^tempint2) < 0)
|
||||
{
|
||||
clipupdatesector(*(vec2_t *)pos, sectnum, rad);
|
||||
if ((tempint ^ dmulscale6(clipit[j].x2-clipit[j].x1, move.x, clipit[j].y2-clipit[j].y1, move.y)) < 0)
|
||||
return clipReturn;
|
||||
}
|
||||
}
|
||||
|
||||
keepaway(&goal.x, &goal.y, hitwall);
|
||||
xvect = (goal.x-vec.x)<<14;
|
||||
|
@ -1368,17 +1371,11 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
|
|||
hitwalls[cnt] = hitwall;
|
||||
}
|
||||
|
||||
int const osectnum = *sectnum;
|
||||
clipupdatesector(vec, sectnum, rad);
|
||||
|
||||
if (*sectnum != -1 && (*sectnum == osectnum || editstatus || !check_floor_curb(osectnum, *sectnum, flordist, pos->z, vec)))
|
||||
{
|
||||
pos->x = vec.x;
|
||||
pos->y = vec.y;
|
||||
cnt--;
|
||||
}
|
||||
else
|
||||
*sectnum = osectnum;
|
||||
} while ((xvect|yvect) != 0 && hitwall >= 0 && cnt > 0);
|
||||
|
||||
return clipReturn;
|
||||
|
|
Loading…
Reference in a new issue