mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-12 11:10:39 +00:00
engine.c: apply "usual readability transformations" on inside() and comment it.
The main thing to note is the "half-open" nature of the x/y range checks. git-svn-id: https://svn.eduke32.com/eduke32@3897 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
a3adf3508e
commit
8b4a87925b
2 changed files with 45 additions and 28 deletions
|
@ -1782,9 +1782,12 @@ static int32_t restore_highlighted_map(mapinfofull_t *mapinfo, int32_t forreal)
|
||||||
// insert sprites
|
// insert sprites
|
||||||
for (i=0; i<mapinfo->numsprites; i++)
|
for (i=0; i<mapinfo->numsprites; i++)
|
||||||
{
|
{
|
||||||
int32_t sect = onumsectors+mapinfo->sprite[i].sectnum;
|
const spritetype *srcspr = &mapinfo->sprite[i];
|
||||||
j = insertsprite(sect, mapinfo->sprite[i].statnum);
|
int32_t sect = onumsectors + srcspr->sectnum;
|
||||||
Bmemcpy(&sprite[j], &mapinfo->sprite[i], sizeof(spritetype));
|
|
||||||
|
j = insertsprite(sect, srcspr->statnum);
|
||||||
|
Bassert(j >= 0);
|
||||||
|
Bmemcpy(&sprite[j], srcspr, sizeof(spritetype));
|
||||||
sprite[j].sectnum = sect;
|
sprite[j].sectnum = sect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8579,15 +8582,10 @@ int32_t fixspritesectors(void)
|
||||||
|
|
||||||
for (j=0; j<numsectors; j++)
|
for (j=0; j<numsectors; j++)
|
||||||
{
|
{
|
||||||
if (inside(dax,day, j) != 1)
|
if (cz <= sprite[i].z && sprite[i].z <= fz && inside(dax,day, j) == 1)
|
||||||
continue;
|
|
||||||
|
|
||||||
if (cz <= sprite[i].z && sprite[i].z <= fz)
|
|
||||||
{
|
{
|
||||||
if (fixmaponsave_sprites || (sprite[i].sectnum < 0 || sprite[i].sectnum >= numsectors))
|
if (fixmaponsave_sprites || (unsigned)sprite[i].sectnum >= numsectors+0u)
|
||||||
{
|
{
|
||||||
numfixedsprites++;
|
|
||||||
|
|
||||||
if (printfirsttime == 0)
|
if (printfirsttime == 0)
|
||||||
{
|
{
|
||||||
initprintf("--------------------\n");
|
initprintf("--------------------\n");
|
||||||
|
@ -8595,7 +8593,9 @@ int32_t fixspritesectors(void)
|
||||||
}
|
}
|
||||||
initprintf_nowarn("Changed sectnum of sprite #%d from %d to %d\n",
|
initprintf_nowarn("Changed sectnum of sprite #%d from %d to %d\n",
|
||||||
i, TrackerCast(sprite[i].sectnum), j);
|
i, TrackerCast(sprite[i].sectnum), j);
|
||||||
|
|
||||||
changespritesect(i, j);
|
changespritesect(i, j);
|
||||||
|
numfixedsprites++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11385,28 +11385,45 @@ int32_t clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_t
|
||||||
//
|
//
|
||||||
int32_t inside(int32_t x, int32_t y, int16_t sectnum)
|
int32_t inside(int32_t x, int32_t y, int16_t sectnum)
|
||||||
{
|
{
|
||||||
walltype *wal;
|
if (sectnum >= 0 && sectnum < numsectors)
|
||||||
int32_t i, x1, y1, x2, y2;
|
|
||||||
uint32_t cnt;
|
|
||||||
|
|
||||||
if (sectnum < 0 || sectnum >= numsectors)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
cnt = 0;
|
|
||||||
wal = &wall[sector[sectnum].wallptr];
|
|
||||||
i = sector[sectnum].wallnum;
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
y1 = wal->y-y; y2 = wall[wal->point2].y-y;
|
uint32_t cnt = 0;
|
||||||
if ((y1^y2) < 0)
|
walltype *wal = &wall[sector[sectnum].wallptr];
|
||||||
|
int32_t i = sector[sectnum].wallnum;
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
x1 = wal->x-x; x2 = wall[wal->point2].x-x;
|
// Get the y components of the [tested point]-->[wall point{1,2}]
|
||||||
if ((x1^x2) >= 0) cnt ^= x1; else cnt ^= (x1*y2-x2*y1)^y2;
|
// vectors.
|
||||||
|
const int32_t y1 = wal->y - y;
|
||||||
|
const int32_t y2 = wall[wal->point2].y - y;
|
||||||
|
|
||||||
|
// If their signs differ[*], ...
|
||||||
|
//
|
||||||
|
// [*] where '-' corresponds to <0 and '+' corresponds to >=0.
|
||||||
|
// Equivalently, the branch is taken iff
|
||||||
|
// y1 != y2 AND y_m <= wal->y < y_M,
|
||||||
|
// where y_m := min(y1, y2) and y_M := max(y1, y2).
|
||||||
|
if ((y1^y2) < 0)
|
||||||
|
{
|
||||||
|
// ... get the x components.
|
||||||
|
const int32_t x1 = wal->x - x;
|
||||||
|
const int32_t x2 = wall[wal->point2].x - x;
|
||||||
|
|
||||||
|
if ((x1^x2) >= 0)
|
||||||
|
cnt ^= x1;
|
||||||
|
else
|
||||||
|
cnt ^= (x1*y2-x2*y1)^y2;
|
||||||
|
}
|
||||||
|
|
||||||
|
wal++; i--;
|
||||||
}
|
}
|
||||||
wal++; i--;
|
while (i);
|
||||||
|
|
||||||
|
return cnt>>31;
|
||||||
}
|
}
|
||||||
while (i);
|
|
||||||
return(cnt>>31);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t __fastcall getangle(int32_t xvect, int32_t yvect)
|
int32_t __fastcall getangle(int32_t xvect, int32_t yvect)
|
||||||
|
|
Loading…
Reference in a new issue