I think this speeds up software occlusion checking a bit

git-svn-id: https://svn.eduke32.com/eduke32@925 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2008-07-30 11:01:39 +00:00
parent 2b13bec0ab
commit 9465dcfa02
6 changed files with 82 additions and 89 deletions

View file

@ -551,7 +551,7 @@ extern int r_vbocount;
extern int r_animsmoothing; extern int r_animsmoothing;
extern int r_parallaxskyclamping; extern int r_parallaxskyclamping;
extern int r_parallaxskypanning; extern int r_parallaxskypanning;
extern int r_cullobstructedmodels; extern int r_modelocclusionchecking;
extern int r_fullbrights; extern int r_fullbrights;
extern int r_downsize; extern int r_downsize;
extern int mdtims, omdtims; extern int mdtims, omdtims;

View file

@ -6345,7 +6345,12 @@ killsprite:
if (tspriteptr[spritesortcnt] != NULL) if (tspriteptr[spritesortcnt] != NULL)
drawsprite(spritesortcnt); drawsprite(spritesortcnt);
} }
#if defined(USE_OPENGL) && defined(POLYMOST)
if (totalclock < lastcullcheck - CULL_DELAY)
lastcullcheck = totalclock;
if (totalclock >= lastcullcheck + CULL_DELAY)
lastcullcheck = (totalclock + CULL_DELAY);
#endif
} /* depthpeeling */ } /* depthpeeling */
#if defined(USE_OPENGL) && defined(POLYMOST) #if defined(USE_OPENGL) && defined(POLYMOST)
else else
@ -6356,6 +6361,8 @@ killsprite:
while (j > 0) drawsprite(--j); while (j > 0) drawsprite(--j);
while (k > 0) drawmaskwall(--k); while (k > 0) drawmaskwall(--k);
if (totalclock >= lastcullcheck + CULL_DELAY)
lastcullcheck = (totalclock + CULL_DELAY);
} }
#endif #endif

View file

@ -175,9 +175,9 @@ int r_parallaxskyclamping = 1;
int r_parallaxskypanning = 0; int r_parallaxskypanning = 0;
// line of sight checks before mddraw() // line of sight checks before mddraw()
int r_cullobstructedmodels = 0; int r_modelocclusionchecking = 0;
#define CULL_DELAY 5
#define CULL_OFFSET 384 #define CULL_OFFSET 384
#define CULL_DELAY 3
// fullbright cvar // fullbright cvar
int r_fullbrights = 1; int r_fullbrights = 1;
@ -4439,35 +4439,38 @@ void polymost_drawmaskwall(int damaskwallcnt)
drawpoly(dpx,dpy,n,method); drawpoly(dpx,dpy,n,method);
} }
// int lastcullcheck[MAXSPRITES]; int lastcullcheck = 0;
char cullmodel[MAXSPRITES]; char cullmodel[MAXSPRITES];
int polymost_checkcoordinates(int x, int y, spritetype *tspr) int polymost_checkcoordinates(int x, int y, spritetype *tspr)
{ {
short datempsectnum = tspr->sectnum; short datempsectnum = tspr->sectnum;
int i; int oldx = x, i, j = (tilesizy[tspr->picnum]*tspr->yrepeat);
RECHECK:
updatesector(tspr->x+x,tspr->y+y,&datempsectnum); updatesector(tspr->x+x,tspr->y+y,&datempsectnum);
if (datempsectnum == -1) if (datempsectnum == -1)
{
if (x == y || x != oldx)
return 0; return 0;
/* if (cansee(globalposx, globalposy, globalposz, globalcursectnum, swaplong(&x,&y);
tspr->x+x, tspr->y+y, sector[datempsectnum].floorz, datempsectnum)) updatesector(tspr->x+x,tspr->y+y,&datempsectnum);
return 1; }
if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x+x, tspr->y+y, sector[datempsectnum].ceilingz, datempsectnum))
return 1; */
if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x+x, tspr->y+y, tspr->z, datempsectnum))
return 1;
for (i=4;i>-1;i--) for (i=4;i>-1;i--)
{ {
if (cansee(globalposx, globalposy, globalposz, globalcursectnum, if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x+x, tspr->y+y, tspr->z-((tilesizy[tspr->picnum]*tspr->yrepeat)*i)-512, datempsectnum)) tspr->x+x, tspr->y+y, tspr->z-(j*i)-512, datempsectnum))
return 1; return 1;
/* if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x+x, tspr->y+y, tspr->z+((tilesizy[tspr->picnum]*tspr->yrepeat)*i), datempsectnum))
return 1; */
} }
if (x != y && x == oldx)
{
swaplong(&x,&y);
goto RECHECK;
}
return 0; return 0;
} }
@ -4481,7 +4484,6 @@ void polymost_drawsprite(int snum)
int posx,posy; int posx,posy;
int oldsizx, oldsizy; int oldsizx, oldsizy;
int tsizx, tsizy; int tsizx, tsizy;
md2model *modelptr = NULL;
tspr = tspriteptr[snum]; tspr = tspriteptr[snum];
if (tspr->owner < 0 || tspr->picnum < 0) return; if (tspr->owner < 0 || tspr->picnum < 0) return;
@ -4530,57 +4532,41 @@ void polymost_drawsprite(int snum)
if (mddraw(tspr)) return; if (mddraw(tspr)) return;
break; // else, render as flat sprite break; // else, render as flat sprite
} }
modelptr = (md2model *)models[tile2model[Ptile2tile(tspr->picnum,tspr->pal)].modelid]; if (r_modelocclusionchecking)
if (r_cullobstructedmodels == 1 || (r_cullobstructedmodels == 2 && (modelptr->usesalpha))) {
if (totalclock >= lastcullcheck + CULL_DELAY)
{ {
do // this is so gay do // this is so gay
{ {
if (/*totalclock < lastcullcheck[tspr->owner] ||*/ tspr->statnum == TSPR_TEMP) // don't bother with shadows because processing its owner will take care of it
if (tspr->statnum == TSPR_TEMP)
break; break;
cullmodel[tspr->owner] = 1; cullmodel[tspr->owner] = 1;
/* if (cansee(globalposx, globalposy, sector[globalcursectnum].ceilingz, globalcursectnum,
tspr->x, tspr->y, tspr->z, tspr->sectnum))
{ cullmodel[tspr->owner] = 0; break; }
if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x, tspr->y, tspr->z-((tilesizy[tspr->picnum]*tspr->yrepeat)<<2),tspr->sectnum))
{ cullmodel[tspr->owner] = 0; break; } */
if (cansee(globalposx, globalposy, globalposz, globalcursectnum, if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x, tspr->y, tspr->z,tspr->sectnum)) tspr->x, tspr->y, tspr->z,tspr->sectnum))
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[tspr->owner] = 0; break; }
/* if (cansee(globalposx, globalposy, globalposz, globalcursectnum,
tspr->x, tspr->y, globalposz,tspr->sectnum)) if (polymost_checkcoordinates(-CULL_OFFSET, 0, tspr))
{ cullmodel[tspr->owner] = 0; break; } */ { cullmodel[tspr->owner] = 0; break; }
/* if (cansee(globalposx, globalposy, sector[globalcursectnum].floorz, globalcursectnum, if (polymost_checkcoordinates(-CULL_OFFSET, -CULL_OFFSET, tspr))
tspr->x, tspr->y, tspr->z, tspr->sectnum)) { cullmodel[tspr->owner] = 0; break; }
{ cullmodel[tspr->owner] = 0; break; } */
if (polymost_checkcoordinates(CULL_OFFSET, 0, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(CULL_OFFSET, CULL_OFFSET, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(-CULL_OFFSET, CULL_OFFSET, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(0, 0, tspr)) if (polymost_checkcoordinates(0, 0, tspr))
{ cullmodel[tspr->owner] = 0; break; } { cullmodel[tspr->owner] = 0; break; }
i = CULL_OFFSET;
if (polymost_checkcoordinates(-i, 0, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(-i, -i, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(0, -i, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(i, 0, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(i, i, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(0, i, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(-i, i, tspr))
{ cullmodel[tspr->owner] = 0; break; }
if (polymost_checkcoordinates(i, -i, tspr))
{ cullmodel[tspr->owner] = 0; break; }
break; break;
} }
while (1); while (1);
/* if (totalclock >= lastcullcheck[tspr->owner]) }
lastcullcheck[tspr->owner] = totalclock + CULL_DELAY; */
} }
else cullmodel[tspr->owner] = 0; else cullmodel[tspr->owner] = 0;
if (cullmodel[tspr->owner]) break; if (cullmodel[tspr->owner]) break;
@ -5980,10 +5966,10 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm)
} }
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->name, "r_cullobstructedmodels")) else if (!Bstrcasecmp(parm->name, "r_modelocclusionchecking"))
{ {
if (showval) { OSD_Printf("r_cullobstructedmodels is %d\n", r_cullobstructedmodels); } if (showval) { OSD_Printf("r_modelocclusionchecking is %d\n", r_modelocclusionchecking); }
else r_cullobstructedmodels = max(0,min(val,2)); else r_modelocclusionchecking = max(0,min(val,2));
return OSDCMD_OK; return OSDCMD_OK;
} }
else if (!Bstrcasecmp(parm->name, "r_fullbrights")) else if (!Bstrcasecmp(parm->name, "r_fullbrights"))
@ -6050,7 +6036,7 @@ void polymost_initosdfuncs(void)
{ {
#ifdef USE_OPENGL #ifdef USE_OPENGL
OSD_RegisterFunction("r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",osdcmd_polymostvars); OSD_RegisterFunction("r_animsmoothing","r_animsmoothing: enable/disable model animation smoothing",osdcmd_polymostvars);
OSD_RegisterFunction("r_cullobstructedmodels","r_cullobstructedmodels: enable/disable hack to cull \"obstructed\" models",osdcmd_polymostvars); OSD_RegisterFunction("r_modelocclusionchecking","r_modelocclusionchecking: enable/disable hack to cull \"obstructed\" models",osdcmd_polymostvars);
OSD_RegisterFunction("r_curpeel","r_curpeel: allows to display one depth layer at a time (for development purposes)",osdcmd_polymostvars); OSD_RegisterFunction("r_curpeel","r_curpeel: allows to display one depth layer at a time (for development purposes)",osdcmd_polymostvars);
OSD_RegisterFunction("r_depthpeeling","r_depthpeeling: enable/disable order-independant transparency",osdcmd_polymostvars); OSD_RegisterFunction("r_depthpeeling","r_depthpeeling: enable/disable order-independant transparency",osdcmd_polymostvars);
OSD_RegisterFunction("r_detailmapping","r_detailmapping: enable/disable detail mapping",osdcmd_polymostvars); OSD_RegisterFunction("r_detailmapping","r_detailmapping: enable/disable detail mapping",osdcmd_polymostvars);

View file

@ -705,7 +705,7 @@ int32 CONFIG_ReadSetup(void)
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning", &r_parallaxskypanning); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning", &r_parallaxskypanning);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", &r_cullobstructedmodels); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLOcclusionChecking", &r_modelocclusionchecking);
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", &r_downsize); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", &r_downsize);
dummy = usemodels; dummy = usemodels;
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy); SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy);
@ -926,7 +926,7 @@ void CONFIG_WriteSetup(void)
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning",r_parallaxskypanning,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyPanning",r_parallaxskypanning,false,false);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLCullObstructedModels", r_cullobstructedmodels,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLOcclusionChecking", r_modelocclusionchecking,false,false);
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", r_downsize,false,false); SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLTextureQuality", r_downsize,false,false);
#endif #endif
#ifdef RENDERTYPEWIN #ifdef RENDERTYPEWIN

View file

@ -2355,13 +2355,13 @@ static void coolgaugetext(int snum)
} }
} }
#define AVERAGEFRAMES 16 #define AVERAGEFRAMES 128
static int frameval[AVERAGEFRAMES], framecnt = 0;
static void tics(void) static void tics(void)
{ {
int i = totalclock,j; int i = totalclock,j;
char b[10]; static int frameval[AVERAGEFRAMES], framecnt = 0;
char b[4];
if (i != frameval[framecnt]) if (i != frameval[framecnt])
{ {
@ -3530,7 +3530,7 @@ void displayrest(int smoothratio)
if (ud.screen_size == 4) if (ud.screen_size == 4)
{ {
i = scale(tilesizy[INVENTORYBOX]+2,ud.statusbarscale,100); i = scale(tilesizy[INVENTORYBOX]+2,ud.statusbarscale,100);
j = scale(scale(5,ud.config.ScreenWidth,320),ud.statusbarscale,100); j = scale(scale(6,ud.config.ScreenWidth,320),ud.statusbarscale,100);
} }
else if (ud.screen_size > 2) else if (ud.screen_size > 2)
{ {

View file

@ -2450,7 +2450,7 @@ cheat_for_port_credits:
"-", "-",
"Use models", "Use models",
"Blend model animations", "Blend model animations",
"Cull obstructed models", "Model occlusion checking",
NULL NULL
}; };
@ -2553,37 +2553,37 @@ cheat_for_port_credits:
enabled = usehightile; enabled = usehightile;
if (enabled && x==io) ud.config.useprecache = !ud.config.useprecache; if (enabled && x==io) ud.config.useprecache = !ud.config.useprecache;
if (enabled) modval(0,1,(int *)&ud.config.useprecache,1,probey==io); if (enabled) modval(0,1,(int *)&ud.config.useprecache,1,probey==io);
mgametextpal(d,yy, ud.config.useprecache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, ud.config.useprecache ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
case 7: case 7:
enabled = usehightile; enabled = usehightile;
if (enabled && x==io) glusetexcompr = !glusetexcompr; if (enabled && x==io) glusetexcompr = !glusetexcompr;
if (enabled) modval(0,1,(int *)&glusetexcompr,1,probey==io); if (enabled) modval(0,1,(int *)&glusetexcompr,1,probey==io);
mgametextpal(d,yy, glusetexcompr && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, glusetexcompr ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
case 8: case 8:
enabled = (glusetexcompr && usehightile); enabled = (glusetexcompr && usehightile);
if (enabled && x==io) glusetexcache = !glusetexcache; if (enabled && x==io) glusetexcache = !glusetexcache;
if (enabled) modval(0,1,(int *)&glusetexcache,1,probey==io); if (enabled) modval(0,1,(int *)&glusetexcache,1,probey==io);
mgametextpal(d,yy, glusetexcache && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, glusetexcache ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
case 9: case 9:
enabled = (glusetexcompr && usehightile && glusetexcache); enabled = (glusetexcompr && usehightile && glusetexcache);
if (enabled && x==io) glusetexcachecompression = !glusetexcachecompression; if (enabled && x==io) glusetexcachecompression = !glusetexcachecompression;
if (enabled) modval(0,1,(int *)&glusetexcachecompression,1,probey==io); if (enabled) modval(0,1,(int *)&glusetexcachecompression,1,probey==io);
mgametextpal(d,yy, glusetexcachecompression && enabled ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, glusetexcachecompression ? "On" : "Off", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
case 10: case 10:
enabled = usehightile; enabled = usehightile;
if (enabled && x==io) r_detailmapping = !r_detailmapping; if (enabled && x==io) r_detailmapping = !r_detailmapping;
if (enabled) modval(0,1,(int *)&r_detailmapping,1,probey==io); if (enabled) modval(0,1,(int *)&r_detailmapping,1,probey==io);
mgametextpal(d,yy, r_detailmapping && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, r_detailmapping ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
case 11: case 11:
enabled = usehightile; enabled = usehightile;
if (enabled && x==io) r_glowmapping = !r_glowmapping; if (enabled && x==io) r_glowmapping = !r_glowmapping;
if (enabled) modval(0,1,(int *)&r_glowmapping,1,probey==io); if (enabled) modval(0,1,(int *)&r_glowmapping,1,probey==io);
mgametextpal(d,yy, r_glowmapping && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, r_glowmapping ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
case 12: case 12:
if (x==io) usemodels = 1-usemodels; if (x==io) usemodels = 1-usemodels;
@ -2594,13 +2594,13 @@ cheat_for_port_credits:
enabled = usemodels; enabled = usemodels;
if (enabled && x==io) r_animsmoothing = !r_animsmoothing; if (enabled && x==io) r_animsmoothing = !r_animsmoothing;
if (enabled) modval(0,1,(int *)&r_animsmoothing,1,probey==io); if (enabled) modval(0,1,(int *)&r_animsmoothing,1,probey==io);
mgametextpal(d,yy, r_animsmoothing && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, r_animsmoothing ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
case 14: case 14:
enabled = usemodels; enabled = usemodels;
if (enabled && x==io) r_cullobstructedmodels = !r_cullobstructedmodels; if (enabled && x==io) r_modelocclusionchecking = !r_modelocclusionchecking;
if (enabled) modval(0,1,(int *)&r_cullobstructedmodels,1,probey==io); if (enabled) modval(0,1,(int *)&r_modelocclusionchecking,1,probey==io);
mgametextpal(d,yy, r_cullobstructedmodels && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0); mgametextpal(d,yy, r_modelocclusionchecking ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
break; break;
default: default:
break; break;