viewx/viewy also need to be stored/restored.

This commit is contained in:
Nev3r 2019-06-06 13:30:50 +02:00
parent 0d77e8afaf
commit d2692ddd24
6 changed files with 24 additions and 10 deletions

View File

@ -31,6 +31,7 @@ sector_t *backsector;
// very ugly realloc() of drawsegs at run-time, I upped it to 512
// instead of 256.. and someone managed to send me a level with
// 896 drawsegs! So too bad here's a limit removal a-la-Boom
drawseg_t *curdrawsegs = NULL;
drawseg_t *drawsegs = NULL;
drawseg_t *ds_p = NULL;
@ -1377,13 +1378,5 @@ void R_RenderBSPNode(INT32 bspnum)
bspnum = bsp->children[side^1];
}
// PORTAL CULLING
if (portalcullsector) {
sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector;
if (sect != portalcullsector)
return;
portalcullsector = NULL;
}
R_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR);
}

View File

@ -29,6 +29,7 @@ extern boolean portalline; // is curline a portal seg?
extern INT32 checkcoord[12][4];
extern drawseg_t *curdrawsegs;
extern drawseg_t *drawsegs;
extern drawseg_t *ds_p;
extern INT32 doorclosed;

View File

@ -1056,7 +1056,11 @@ void R_RenderPlayerView(player_t *player)
masks[nummasks - 1].drawsegs[0] = 0;
masks[nummasks - 1].vissprites[0] = 0;
masks[nummasks - 1].viewx = viewx;
masks[nummasks - 1].viewy = viewy;
masks[nummasks - 1].viewz = viewz;
masks[nummasks - 1].viewsector = viewsector;
curdrawsegs = ds_p;
R_RenderBSPNode((INT32)numnodes - 1);
masks[nummasks - 1].drawsegs[1] = ds_p - drawsegs;
masks[nummasks - 1].vissprites[1] = visspritecount;
@ -1103,7 +1107,12 @@ void R_RenderPlayerView(player_t *player)
masks[nummasks - 1].drawsegs[0] = ds_p - drawsegs;
masks[nummasks - 1].vissprites[0] = visspritecount;
masks[nummasks - 1].viewx = viewx;
masks[nummasks - 1].viewy = viewy;
masks[nummasks - 1].viewz = viewz;
masks[nummasks - 1].viewsector = viewsector;
curdrawsegs = ds_p;
R_RenderBSPNode((INT32)numnodes - 1);
masks[nummasks - 1].drawsegs[1] = ds_p - drawsegs;
masks[nummasks - 1].vissprites[1] = visspritecount;

View File

@ -1738,6 +1738,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (ds_p == drawsegs+maxdrawsegs)
{
size_t curpos = curdrawsegs - drawsegs;
size_t pos = ds_p - drawsegs;
size_t newmax = maxdrawsegs ? maxdrawsegs*2 : 128;
if (firstseg)
@ -1745,6 +1746,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
drawsegs = Z_Realloc(drawsegs, newmax*sizeof (*drawsegs), PU_STATIC, NULL);
ds_p = drawsegs + pos;
maxdrawsegs = newmax;
curdrawsegs = drawsegs + curpos;
if (firstseg)
firstseg = drawsegs + (size_t)firstseg;
}
@ -1794,7 +1796,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
// borrowed fix from *cough* zdoom *cough*
// [RH] We also need to adjust the openings pointers that
// were already stored in drawsegs.
for (ds = drawsegs; ds < ds_p; ds++)
for (ds = curdrawsegs; ds < ds_p; ds++)
{
#define ADJUST(p) if (ds->p + ds->x1 >= oldopenings && ds->p + ds->x1 <= oldlast) ds->p = ds->p - oldopenings + openings;
ADJUST(maskedtexturecol);

View File

@ -2454,7 +2454,12 @@ void R_DrawMasked(maskcount_t* masks, UINT8 nummasks)
for (i = 0; i < nummasks; i++)
{
heads[i].next = heads[i].prev = &heads[i];
viewx = masks[i].viewx;
viewy = masks[i].viewy;
viewz = masks[i].viewz;
viewsector = masks[i].viewsector;
R_CreateDrawNodes(&masks[i], &heads[i], false);
}
@ -2463,7 +2468,10 @@ void R_DrawMasked(maskcount_t* masks, UINT8 nummasks)
for (; nummasks > 0; nummasks--)
{
viewx = masks[nummasks - 1].viewx;
viewy = masks[nummasks - 1].viewy;
viewz = masks[nummasks - 1].viewz;
viewsector = masks[nummasks - 1].viewsector;
R_DrawMaskedList(&heads[nummasks - 1]);
R_ClearDrawNodes(&heads[nummasks - 1]);

View File

@ -65,7 +65,8 @@ typedef struct
{
size_t drawsegs[2];
size_t vissprites[2];
fixed_t viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */
fixed_t viewx, viewy, viewz; /**< View z stored at the time of the BSP traversal for the view/portal. Masked sorting/drawing needs it. */
sector_t* viewsector;
} maskcount_t;
void R_DrawMasked(maskcount_t* masks, UINT8 nummasks);