mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 03:00:46 +00:00
Fix the Polymer hitches first encountered with Parkade.
The cause was a combination of many factors. First, Polymer requires the start-drawing position to be inside the sector to draw (deviations lead to incorrect drawing). This was violated by the game, because it interpolated the current and next tic position without updating the sectnum, leading to inconsistencies especially when passing through narrow sectors. Polymer worked around it by doing an updatesector() each frame, however this works poorly for maps with overlapping geometry such as SoS or RoR. The solution to this is to add a new engine function, updatesector_onlynextwalls(), which searches the sectors (via nextsector) in breadth-first fashion instead of from 0 to numsectors-1, like updatesector does when it fails for the *immediate* nextwall neighbors. Internally, the breadt-first search helpers are moved into the engine. git-svn-id: https://svn.eduke32.com/eduke32@2256 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
87ac6b8406
commit
480690aa1d
5 changed files with 67 additions and 28 deletions
|
@ -576,6 +576,9 @@ void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col);
|
||||||
int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
||||||
void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
||||||
|
|
||||||
|
void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt);
|
||||||
|
void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt);
|
||||||
|
|
||||||
extern int32_t clipmoveboxtracenum;
|
extern int32_t clipmoveboxtracenum;
|
||||||
int32_t clipmove(vec3_t *vect, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2)));
|
int32_t clipmove(vec3_t *vect, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2)));
|
||||||
int32_t clipinsidebox(int32_t x, int32_t y, int16_t wallnum, int32_t walldist);
|
int32_t clipinsidebox(int32_t x, int32_t y, int16_t wallnum, int32_t walldist);
|
||||||
|
@ -586,6 +589,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int
|
||||||
int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch) ATTRIBUTE((nonnull(6,7,8)));
|
int32_t neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch) ATTRIBUTE((nonnull(6,7,8)));
|
||||||
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
|
int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
|
||||||
void updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3)));
|
void updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3)));
|
||||||
|
void updatesector_onlynextwalls(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3)));
|
||||||
void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *excludesectbitmap) ATTRIBUTE((nonnull(3)));
|
void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *excludesectbitmap) ATTRIBUTE((nonnull(3)));
|
||||||
void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) ATTRIBUTE((nonnull(4)));
|
void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) ATTRIBUTE((nonnull(4)));
|
||||||
int32_t inside(int32_t x, int32_t y, int16_t sectnum);
|
int32_t inside(int32_t x, int32_t y, int16_t sectnum);
|
||||||
|
|
|
@ -139,9 +139,6 @@ extern int32_t getinvdisplacement(int32_t *dx, int32_t *dy, int32_t dz) ATTRIBUT
|
||||||
extern int32_t getscreenvdisp(int32_t bz, int32_t zoome);
|
extern int32_t getscreenvdisp(int32_t bz, int32_t zoome);
|
||||||
extern void setup_sideview_sincos(void);
|
extern void setup_sideview_sincos(void);
|
||||||
|
|
||||||
extern void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt);
|
|
||||||
extern void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt);
|
|
||||||
|
|
||||||
extern int32_t wallength(int16_t i);
|
extern int32_t wallength(int16_t i);
|
||||||
extern void fixrepeats(int16_t i);
|
extern void fixrepeats(int16_t i);
|
||||||
extern uint32_t getlenbyrep(int32_t len, int32_t repeat);
|
extern uint32_t getlenbyrep(int32_t len, int32_t repeat);
|
||||||
|
|
|
@ -2421,29 +2421,6 @@ static int32_t compare_wall_coords(const void *w1, const void *w2)
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
// breadth-first search helpers
|
|
||||||
void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt)
|
|
||||||
{
|
|
||||||
Bmemset(bitmap, 0, (maxnum+7)>>3);
|
|
||||||
|
|
||||||
list[0] = firstelt;
|
|
||||||
bitmap[firstelt>>3] |= (1<<(firstelt&7));
|
|
||||||
*eltnumptr = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt)
|
|
||||||
{
|
|
||||||
if (elt < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((bitmap[elt>>3]&(1<<(elt&7)))==0)
|
|
||||||
{
|
|
||||||
bitmap[elt>>3] |= (1<<(elt&7));
|
|
||||||
list[*eltnumptr] = elt;
|
|
||||||
(*eltnumptr)++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef YAX_ENABLE
|
#ifdef YAX_ENABLE
|
||||||
static int32_t collnumsects[2];
|
static int32_t collnumsects[2];
|
||||||
static int16_t collsectlist[2][MAXSECTORS];
|
static int16_t collsectlist[2][MAXSECTORS];
|
||||||
|
|
|
@ -12362,6 +12362,30 @@ int32_t pushmove(vec3_t *vect, int16_t *sectnum,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// breadth-first search helpers
|
||||||
|
void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt)
|
||||||
|
{
|
||||||
|
Bmemset(bitmap, 0, (maxnum+7)>>3);
|
||||||
|
|
||||||
|
list[0] = firstelt;
|
||||||
|
bitmap[firstelt>>3] |= (1<<(firstelt&7));
|
||||||
|
*eltnumptr = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt)
|
||||||
|
{
|
||||||
|
if (elt < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((bitmap[elt>>3]&(1<<(elt&7)))==0)
|
||||||
|
{
|
||||||
|
bitmap[elt>>3] |= (1<<(elt&7));
|
||||||
|
list[*eltnumptr] = elt;
|
||||||
|
(*eltnumptr)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// updatesector[z]
|
// updatesector[z]
|
||||||
//
|
//
|
||||||
|
@ -12401,6 +12425,39 @@ void updatesector(int32_t x, int32_t y, int16_t *sectnum)
|
||||||
*sectnum = -1;
|
*sectnum = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updatesector_onlynextwalls(int32_t x, int32_t y, int16_t *sectnum)
|
||||||
|
{
|
||||||
|
static int16_t sectlist[MAXSECTORS];
|
||||||
|
static uint8_t sectbitmap[MAXSECTORS>>3];
|
||||||
|
int32_t nsecs, sectcnt, j;
|
||||||
|
|
||||||
|
if ((unsigned)(*sectnum) >= (unsigned)numsectors)
|
||||||
|
return;
|
||||||
|
|
||||||
|
bfirst_search_init(sectlist, sectbitmap, &nsecs, numsectors, *sectnum);
|
||||||
|
|
||||||
|
for (sectcnt=0; sectcnt<nsecs; sectcnt++)
|
||||||
|
{
|
||||||
|
const sectortype *sec = §or[sectlist[sectcnt]];
|
||||||
|
int32_t startwall = sec->wallptr;
|
||||||
|
int32_t endwall = sec->wallptr + sec->wallnum;
|
||||||
|
|
||||||
|
if (inside(x,y, sectlist[sectcnt]) == 1)
|
||||||
|
{
|
||||||
|
*sectnum = sectlist[sectcnt];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j=startwall; j<endwall; j++)
|
||||||
|
{
|
||||||
|
if (wall[j].nextsector >= 0)
|
||||||
|
bfirst_search_try(sectlist, sectbitmap, &nsecs, wall[j].nextsector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*sectnum = -1;
|
||||||
|
}
|
||||||
|
|
||||||
void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *excludesectbitmap)
|
void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *excludesectbitmap)
|
||||||
{
|
{
|
||||||
walltype *wal;
|
walltype *wal;
|
||||||
|
|
|
@ -993,10 +993,11 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
|
||||||
bglGetFloatv(GL_MODELVIEW_MATRIX, rootmodelviewmatrix);
|
bglGetFloatv(GL_MODELVIEW_MATRIX, rootmodelviewmatrix);
|
||||||
|
|
||||||
cursectnum = dacursectnum;
|
cursectnum = dacursectnum;
|
||||||
updatesector(daposx, daposy, &cursectnum);
|
updatesector_onlynextwalls(daposx, daposy, &cursectnum);
|
||||||
|
|
||||||
if ((cursectnum >= 0) && (cursectnum < numsectors))
|
if ((cursectnum >= 0) && (cursectnum < numsectors))
|
||||||
dacursectnum = cursectnum;
|
dacursectnum = cursectnum;
|
||||||
|
else if (pr_verbosity>=2)
|
||||||
|
OSD_Printf("PR : got sector %d after update!\n", cursectnum);
|
||||||
|
|
||||||
// unflag all sectors
|
// unflag all sectors
|
||||||
i = numsectors-1;
|
i = numsectors-1;
|
||||||
|
@ -1034,6 +1035,9 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da
|
||||||
(daposz > cursectflorz) ||
|
(daposz > cursectflorz) ||
|
||||||
(daposz < cursectceilz))
|
(daposz < cursectceilz))
|
||||||
{
|
{
|
||||||
|
if (!editstatus && pr_verbosity>=1)
|
||||||
|
OSD_Printf("PR : EXT sec=%d z=%d (%d, %d)\n", dacursectnum, daposz, cursectflorz, cursectceilz);
|
||||||
|
|
||||||
curmodelviewmatrix = rootmodelviewmatrix;
|
curmodelviewmatrix = rootmodelviewmatrix;
|
||||||
i = numsectors-1;
|
i = numsectors-1;
|
||||||
while (i >= 0)
|
while (i >= 0)
|
||||||
|
|
Loading…
Reference in a new issue