Merge remote-tracking branch 'public-gl/master' into md3-vanilla

This commit is contained in:
mazmazz 2019-05-08 17:56:05 -04:00
commit 6d803decb6
9 changed files with 151 additions and 44 deletions

View file

@ -148,6 +148,20 @@ void COM_BufInsertText(const char *ptext)
} }
} }
/** Progress the wait timer and flush waiting console commands when ready.
*/
void
COM_BufTicker(void)
{
if (com_wait)
{
com_wait--;
return;
}
COM_BufExecute();
}
/** Flushes (executes) console commands in the buffer. /** Flushes (executes) console commands in the buffer.
*/ */
void COM_BufExecute(void) void COM_BufExecute(void)
@ -157,12 +171,6 @@ void COM_BufExecute(void)
char line[1024] = ""; char line[1024] = "";
INT32 quotes; INT32 quotes;
if (com_wait)
{
com_wait--;
return;
}
while (com_text.cursize) while (com_text.cursize)
{ {
// find a '\n' or; line break // find a '\n' or; line break
@ -514,7 +522,6 @@ static void COM_ExecuteString(char *ptext)
{ {
if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
recursion = 0;
cmd->function(); cmd->function();
return; return;
} }
@ -526,19 +533,17 @@ static void COM_ExecuteString(char *ptext)
if (!stricmp(com_argv[0], a->name)) if (!stricmp(com_argv[0], a->name))
{ {
if (recursion > MAX_ALIAS_RECURSION) if (recursion > MAX_ALIAS_RECURSION)
{
CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n"));
recursion = 0; else
return; { // Monster Iestyn: keep track of how many levels of recursion we're in
recursion++;
COM_BufInsertText(a->value);
recursion--;
} }
recursion++;
COM_BufInsertText(a->value);
return; return;
} }
} }
recursion = 0;
// check cvars // check cvars
// Hurdler: added at Ebola's request ;) // Hurdler: added at Ebola's request ;)
// (don't flood the console in software mode with bad gr_xxx command) // (don't flood the console in software mode with bad gr_xxx command)

View file

@ -45,6 +45,9 @@ void COM_ImmedExecute(const char *ptext);
// Execute commands in buffer, flush them // Execute commands in buffer, flush them
void COM_BufExecute(void); void COM_BufExecute(void);
// As above; and progress the wait timer.
void COM_BufTicker(void);
// setup command buffer, at game tartup // setup command buffer, at game tartup
void COM_Init(void); void COM_Init(void);

View file

@ -4563,7 +4563,7 @@ void TryRunTics(tic_t realtics)
if (realtics >= 1) if (realtics >= 1)
{ {
COM_BufExecute(); COM_BufTicker();
if (mapchangepending) if (mapchangepending)
D_MapChange(-1, 0, ultimatemode, false, 2, false, fromlevelselect); // finish the map change D_MapChange(-1, 0, ultimatemode, false, 2, false, fromlevelselect); // finish the map change
} }

View file

@ -4246,10 +4246,43 @@ static void HWR_DrawSpriteShadow(gr_vissprite_t *spr, GLPatch_t *gpatch, float t
} }
} }
// This is expecting a pointer to an array containing 4 wallVerts for a sprite
static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts)
{
if (cv_grspritebillboarding.value && spr && spr->mobj && wallVerts)
{
float basey = FIXED_TO_FLOAT(spr->mobj->z);
float lowy = wallVerts[0].y;
if (P_MobjFlip(spr->mobj) == -1)
{
basey = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height);
}
// Rotate sprites to fully billboard with the camera
// X, Y, AND Z need to be manipulated for the polys to rotate around the
// origin, because of how the origin setting works I believe that should
// be mobj->z or mobj->z + mobj->height
wallVerts[2].y = wallVerts[3].y = (spr->ty - basey) * gr_viewludsin + basey;
wallVerts[0].y = wallVerts[1].y = (lowy - basey) * gr_viewludsin + basey;
// translate back to be around 0 before translating back
wallVerts[3].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos;
wallVerts[2].x += ((spr->ty - basey) * gr_viewludcos) * gr_viewcos;
wallVerts[0].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos;
wallVerts[1].x += ((lowy - basey) * gr_viewludcos) * gr_viewcos;
wallVerts[3].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin;
wallVerts[2].z += ((spr->ty - basey) * gr_viewludcos) * gr_viewsin;
wallVerts[0].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin;
wallVerts[1].z += ((lowy - basey) * gr_viewludcos) * gr_viewsin;
}
}
static void HWR_SplitSprite(gr_vissprite_t *spr) static void HWR_SplitSprite(gr_vissprite_t *spr)
{ {
float this_scale = 1.0f; float this_scale = 1.0f;
FOutVector wallVerts[4]; FOutVector wallVerts[4];
FOutVector baseWallVerts[4]; // This is what the verts should end up as
GLPatch_t *gpatch; GLPatch_t *gpatch;
FSurfaceInfo Surf; FSurfaceInfo Surf;
const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES); const boolean hires = (spr->mobj && spr->mobj->skin && ((skin_t *)spr->mobj->skin)->flags & SF_HIRES);
@ -4262,11 +4295,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
float realtop, realbot, top, bot; float realtop, realbot, top, bot;
float towtop, towbot, towmult; float towtop, towbot, towmult;
float bheight; float bheight;
float realheight, heightmult;
const sector_t *sector = spr->mobj->subsector->sector; const sector_t *sector = spr->mobj->subsector->sector;
const lightlist_t *list = sector->lightlist; const lightlist_t *list = sector->lightlist;
#ifdef ESLOPE #ifdef ESLOPE
float endrealtop, endrealbot, endtop, endbot; float endrealtop, endrealbot, endtop, endbot;
float endbheight; float endbheight;
float endrealheight;
fixed_t temp; fixed_t temp;
fixed_t v1x, v1y, v2x, v2y; fixed_t v1x, v1y, v2x, v2y;
#endif #endif
@ -4299,16 +4334,16 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
HWR_DrawSpriteShadow(spr, gpatch, this_scale); HWR_DrawSpriteShadow(spr, gpatch, this_scale);
} }
wallVerts[0].x = wallVerts[3].x = spr->x1; baseWallVerts[0].x = baseWallVerts[3].x = spr->x1;
wallVerts[2].x = wallVerts[1].x = spr->x2; baseWallVerts[2].x = baseWallVerts[1].x = spr->x2;
wallVerts[0].z = wallVerts[3].z = spr->z1; baseWallVerts[0].z = baseWallVerts[3].z = spr->z1;
wallVerts[1].z = wallVerts[2].z = spr->z2; baseWallVerts[1].z = baseWallVerts[2].z = spr->z2;
wallVerts[2].y = wallVerts[3].y = spr->ty; baseWallVerts[2].y = baseWallVerts[3].y = spr->ty;
if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f) if (spr->mobj && fabsf(this_scale - 1.0f) > 1.0E-36f)
wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height * this_scale; baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height * this_scale;
else else
wallVerts[0].y = wallVerts[1].y = spr->ty - gpatch->height; baseWallVerts[0].y = baseWallVerts[1].y = spr->ty - gpatch->height;
v1x = FLOAT_TO_FIXED(spr->x1); v1x = FLOAT_TO_FIXED(spr->x1);
v1y = FLOAT_TO_FIXED(spr->z1); v1y = FLOAT_TO_FIXED(spr->z1);
@ -4317,44 +4352,56 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
if (spr->flip) if (spr->flip)
{ {
wallVerts[0].sow = wallVerts[3].sow = gpatch->max_s; baseWallVerts[0].sow = baseWallVerts[3].sow = gpatch->max_s;
wallVerts[2].sow = wallVerts[1].sow = 0; baseWallVerts[2].sow = baseWallVerts[1].sow = 0;
}else{ }
wallVerts[0].sow = wallVerts[3].sow = 0; else
wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s; {
baseWallVerts[0].sow = baseWallVerts[3].sow = 0;
baseWallVerts[2].sow = baseWallVerts[1].sow = gpatch->max_s;
} }
// flip the texture coords (look familiar?) // flip the texture coords (look familiar?)
if (spr->vflip) if (spr->vflip)
{ {
wallVerts[3].tow = wallVerts[2].tow = gpatch->max_t; baseWallVerts[3].tow = baseWallVerts[2].tow = gpatch->max_t;
wallVerts[0].tow = wallVerts[1].tow = 0; baseWallVerts[0].tow = baseWallVerts[1].tow = 0;
}else{ }
wallVerts[3].tow = wallVerts[2].tow = 0; else
wallVerts[0].tow = wallVerts[1].tow = gpatch->max_t; {
baseWallVerts[3].tow = baseWallVerts[2].tow = 0;
baseWallVerts[0].tow = baseWallVerts[1].tow = gpatch->max_t;
} }
// if it has a dispoffset, push it a little towards the camera // if it has a dispoffset, push it a little towards the camera
if (spr->dispoffset) { if (spr->dispoffset) {
float co = -gr_viewcos*(0.05f*spr->dispoffset); float co = -gr_viewcos*(0.05f*spr->dispoffset);
float si = -gr_viewsin*(0.05f*spr->dispoffset); float si = -gr_viewsin*(0.05f*spr->dispoffset);
wallVerts[0].z = wallVerts[3].z = wallVerts[0].z+si; baseWallVerts[0].z = baseWallVerts[3].z = baseWallVerts[0].z+si;
wallVerts[1].z = wallVerts[2].z = wallVerts[1].z+si; baseWallVerts[1].z = baseWallVerts[2].z = baseWallVerts[1].z+si;
wallVerts[0].x = wallVerts[3].x = wallVerts[0].x+co; baseWallVerts[0].x = baseWallVerts[3].x = baseWallVerts[0].x+co;
wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; baseWallVerts[1].x = baseWallVerts[2].x = baseWallVerts[1].x+co;
} }
realtop = top = wallVerts[3].y; // Let dispoffset work first since this adjust each vertex
realbot = bot = wallVerts[0].y; HWR_RotateSpritePolyToAim(spr, baseWallVerts);
towtop = wallVerts[3].tow;
towbot = wallVerts[0].tow; realtop = top = baseWallVerts[3].y;
realbot = bot = baseWallVerts[0].y;
towtop = baseWallVerts[3].tow;
towbot = baseWallVerts[0].tow;
towmult = (towbot - towtop) / (top - bot); towmult = (towbot - towtop) / (top - bot);
#ifdef ESLOPE #ifdef ESLOPE
endrealtop = endtop = wallVerts[2].y; endrealtop = endtop = baseWallVerts[2].y;
endrealbot = endbot = wallVerts[1].y; endrealbot = endbot = baseWallVerts[1].y;
#endif #endif
// copy the contents of baseWallVerts into the drawn wallVerts array
// baseWallVerts is used to know the final shape to easily get the vertex
// co-ordinates
memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts));
if (!cv_translucency.value) // translucency disabled if (!cv_translucency.value) // translucency disabled
{ {
Surf.FlatColor.s.alpha = 0xFF; Surf.FlatColor.s.alpha = 0xFF;
@ -4481,12 +4528,53 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
wallVerts[2].y = endtop; wallVerts[2].y = endtop;
wallVerts[0].y = bot; wallVerts[0].y = bot;
wallVerts[1].y = endbot; wallVerts[1].y = endbot;
// The x and y only need to be adjusted in the case that it's not a papersprite
if (cv_grspritebillboarding.value && spr->mobj)
{
// Get the x and z of the vertices so billboarding draws correctly
realheight = realbot - realtop;
endrealheight = endrealbot - endrealtop;
heightmult = (realtop - top) / realheight;
wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult;
wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult;
heightmult = (endrealtop - endtop) / endrealheight;
wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult;
wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult;
heightmult = (realtop - bot) / realheight;
wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult;
wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult;
heightmult = (endrealtop - endbot) / endrealheight;
wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult;
wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult;
}
#else #else
wallVerts[3].tow = wallVerts[2].tow = towtop + ((realtop - top) * towmult); wallVerts[3].tow = wallVerts[2].tow = towtop + ((realtop - top) * towmult);
wallVerts[0].tow = wallVerts[1].tow = towtop + ((realtop - bot) * towmult); wallVerts[0].tow = wallVerts[1].tow = towtop + ((realtop - bot) * towmult);
wallVerts[2].y = wallVerts[3].y = top; wallVerts[2].y = wallVerts[3].y = top;
wallVerts[0].y = wallVerts[1].y = bot; wallVerts[0].y = wallVerts[1].y = bot;
// The x and y only need to be adjusted in the case that it's not a papersprite
if (cv_grspritebillboarding.value && spr->mobj)
{
// Get the x and z of the vertices so billboarding draws correctly
realheight = realbot - realtop;
heightmult = (realtop - top) / realheight;
wallVerts[3].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult;
wallVerts[3].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult;
wallVerts[2].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult;
wallVerts[2].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult;
heightmult = (realtop - bot) / realheight;
wallVerts[0].x = baseWallVerts[3].x + (baseWallVerts[3].x - baseWallVerts[0].x) * heightmult;
wallVerts[0].z = baseWallVerts[3].z + (baseWallVerts[3].z - baseWallVerts[0].z) * heightmult;
wallVerts[1].x = baseWallVerts[2].x + (baseWallVerts[2].x - baseWallVerts[1].x) * heightmult;
wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult;
}
#endif #endif
if (colormap) if (colormap)
@ -4655,6 +4743,9 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co; wallVerts[1].x = wallVerts[2].x = wallVerts[1].x+co;
} }
// Let dispoffset work first since this adjust each vertex
HWR_RotateSpritePolyToAim(spr, wallVerts);
// This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black. // This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black.
// sprite lighting by modulating the RGB components // sprite lighting by modulating the RGB components
/// \todo coloured /// \todo coloured
@ -4736,6 +4827,9 @@ static inline void HWR_DrawPrecipitationSprite(gr_vissprite_t *spr)
wallVerts[0].z = wallVerts[3].z = spr->z1; wallVerts[0].z = wallVerts[3].z = spr->z1;
wallVerts[1].z = wallVerts[2].z = spr->z2; wallVerts[1].z = wallVerts[2].z = spr->z2;
// Let dispoffset work first since this adjust each vertex
HWR_RotateSpritePolyToAim(spr, wallVerts);
wallVerts[0].sow = wallVerts[3].sow = 0; wallVerts[0].sow = wallVerts[3].sow = 0;
wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s; wallVerts[2].sow = wallVerts[1].sow = gpatch->max_s;

View file

@ -93,6 +93,7 @@ extern consvar_t cv_granisotropicmode;
extern consvar_t cv_grcorrecttricks; extern consvar_t cv_grcorrecttricks;
extern consvar_t cv_grfovchange; extern consvar_t cv_grfovchange;
extern consvar_t cv_grsolvetjoin; extern consvar_t cv_grsolvetjoin;
extern consvar_t cv_grspritebillboarding;
extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy; extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy;

View file

@ -1406,6 +1406,7 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_grcoronasize); CV_RegisterVar(&cv_grcoronasize);
#endif #endif
CV_RegisterVar(&cv_grmd2); CV_RegisterVar(&cv_grmd2);
CV_RegisterVar(&cv_grspritebillboarding);
#endif #endif
#ifdef HWRENDER #ifdef HWRENDER

View file

@ -854,8 +854,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights)
{ {
lightlist_t *nextlight = &frontsector->lightlist[i+1]; lightlist_t *nextlight = &frontsector->lightlist[i+1];
if (nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height > pfloorleft if ((nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height) > pfloorleft
&& nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height > pfloorright) && (nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height) > pfloorright)
continue; continue;
} }

View file

@ -80,6 +80,7 @@ consvar_t cv_grcoronasize = {"gr_coronasize", "1", CV_SAVE| CV_FLOAT, 0, NULL, 0
static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}}; static CV_PossibleValue_t CV_MD2[] = {{0, "Off"}, {1, "On"}, {2, "Old"}, {0, NULL}};
// console variables in development // console variables in development
consvar_t cv_grmd2 = {"gr_md2", "Off", CV_SAVE, CV_MD2, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grmd2 = {"gr_md2", "Off", CV_SAVE, CV_MD2, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif #endif
const UINT8 gammatable[5][256] = const UINT8 gammatable[5][256] =

View file

@ -24,8 +24,10 @@ ifndef NOASM
USEASM=1 USEASM=1
endif endif
ifndef NONET
ifndef MINGW64 #miniupnc is broken with MINGW64 ifndef MINGW64 #miniupnc is broken with MINGW64
HAVE_MINIUPNPC=1 HAVE_MINIUPNPC=1
endif
endif endif
OPTS=-DSTDC_HEADERS OPTS=-DSTDC_HEADERS