diff --git a/polymer/build/include/build.h b/polymer/build/include/build.h index 6dbb754de..5f09ceff7 100644 --- a/polymer/build/include/build.h +++ b/polymer/build/include/build.h @@ -546,6 +546,7 @@ extern int r_vbocount; extern int r_animsmoothing; extern int r_parallaxskyclamping; extern int r_parallaxskypanning; +extern int r_cullobstructedmodels; extern int mdtims, omdtims; #endif diff --git a/polymer/build/src/polymost.c b/polymer/build/src/polymost.c index 730555abf..784ecb5ca 100644 --- a/polymer/build/src/polymost.c +++ b/polymer/build/src/polymost.c @@ -176,6 +176,7 @@ int r_parallaxskypanning = 0; // line of sight checks before mddraw() int r_cullobstructedmodels = 0; +#define CULL_DELAY 5 static float fogresult, fogcol[4]; @@ -4416,6 +4417,9 @@ void polymost_drawmaskwall(int damaskwallcnt) drawpoly(dpx,dpy,n,method); } +int lastcullcheck[MAXSPRITES]; +char cullmodel[MAXSPRITES]; + void polymost_drawsprite(int snum) { double px[6], py[6]; @@ -4473,44 +4477,79 @@ void polymost_drawsprite(int snum) { if (r_cullobstructedmodels) { - i = 0; do // this is so gay { - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x, tspr->y, tspr->z, tspr->sectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, globalposz+6144, globalcursectnum, tspr->x, tspr->y, tspr->z, tspr->sectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, globalposz-6144, globalcursectnum, tspr->x, tspr->y, tspr->z, tspr->sectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, sector[globalcursectnum].ceilingz, globalcursectnum, tspr->x, tspr->y, tspr->z, tspr->sectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, sector[globalcursectnum].floorz, globalcursectnum, tspr->x, tspr->y, tspr->z, tspr->sectnum)) - { i++; break; } + if (totalclock < lastcullcheck[tspr->owner]) + break; + 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, tspr->sectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, sector[globalcursectnum].floorz, + globalcursectnum, tspr->x, tspr->y, tspr->z, tspr->sectnum)) + { cullmodel[tspr->owner] = 0; break; } + + if (cansee(globalposx, globalposy, globalposz+6144, globalcursectnum, + tspr->x, tspr->y, tspr->z, tspr->sectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz-6144, globalcursectnum, + tspr->x, tspr->y, tspr->z, tspr->sectnum)) + { cullmodel[tspr->owner] = 0; break; } + updatesector(tspr->x+384,tspr->y,&datempsectnum); - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x+384, tspr->y, sector[datempsectnum].ceilingz, datempsectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x+384, tspr->y, sector[datempsectnum].floorz, datempsectnum)) - { i++; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x+384, tspr->y, sector[datempsectnum].floorz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x+384, tspr->y, sector[datempsectnum].ceilingz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x+384, tspr->y, tspr->z, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + updatesector(tspr->x-384,tspr->y,&datempsectnum); - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x-384, tspr->y, sector[datempsectnum].ceilingz, datempsectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x-384, tspr->y, sector[datempsectnum].floorz, datempsectnum)) - { i++; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x-384, tspr->y, sector[datempsectnum].floorz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x-384, tspr->y, sector[datempsectnum].ceilingz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x-384, tspr->y, tspr->z, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + updatesector(tspr->x,tspr->y+384,&datempsectnum); - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x, tspr->y+384, sector[datempsectnum].ceilingz, datempsectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x, tspr->y+384, sector[datempsectnum].floorz, datempsectnum)) - { i++; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x, tspr->y+384, sector[datempsectnum].floorz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x, tspr->y+384, sector[datempsectnum].ceilingz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x, tspr->y+384, tspr->z, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + updatesector(tspr->x,tspr->y-384,&datempsectnum); - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x, tspr->y-384, sector[datempsectnum].ceilingz, datempsectnum)) - { i++; break; } - if (cansee(globalposx, globalposy, globalposz, globalcursectnum, tspr->x, tspr->y-384, sector[datempsectnum].floorz, datempsectnum)) - { i++; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x, tspr->y-384, sector[datempsectnum].floorz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x, tspr->y-384, sector[datempsectnum].ceilingz, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + if (cansee(globalposx, globalposy, globalposz, globalcursectnum, + tspr->x, tspr->y-384, tspr->z, datempsectnum)) + { cullmodel[tspr->owner] = 0; break; } + cullmodel[tspr->owner] = 1; break; } while (1); - } else i = 1; + if (totalclock > lastcullcheck[tspr->owner]) + lastcullcheck[tspr->owner] = totalclock + CULL_DELAY; + } + else cullmodel[tspr->owner] = 0; - if (i && mddraw(tspr)) return; + if (!cullmodel[tspr->owner] && mddraw(tspr)) return; break; // else, render as flat sprite } if (usevoxels && (tspr->cstat&48)!=48 && tiletovox[tspr->picnum] >= 0 && voxmodels[ tiletovox[tspr->picnum] ]) diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 41cbfd888..2c2ed4877 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -695,6 +695,7 @@ int32 CONFIG_ReadSetup(void) 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", "GLCullObstructedModels", &r_cullobstructedmodels); dummy = usemodels; SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "UseModels",&dummy); usemodels = dummy != 0; @@ -903,6 +904,7 @@ void CONFIG_WriteSetup(void) 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", "GLCullObstructedModels", r_cullobstructedmodels,false,false); #endif #ifdef RENDERTYPEWIN SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "MaxRefreshFreq",maxrefreshfreq,false,false); diff --git a/polymer/eduke32/source/osdfuncs.c b/polymer/eduke32/source/osdfuncs.c index cbb5c474f..efa1bfaaa 100644 --- a/polymer/eduke32/source/osdfuncs.c +++ b/polymer/eduke32/source/osdfuncs.c @@ -33,11 +33,11 @@ void GAME_drawosdstr(int x, int y, char *ch, int len, int shade, int pal) // use the format byte if the text falls within the bounds of the console buffer if (ch > ptr && ch < (ptr + TEXTSIZE)) { - rotatesprite(x<<16, (y<<3)<<16, 65536l, 0, ac, (*(ch-ptr+fmt)&~0x1F)>>4, + rotatesprite(x<<16, (y<<3)<<16, 65536, 0, ac, (*(ch-ptr+fmt)&~0x1F)>>4, *(ch-ptr+fmt)&~0xE0, 8|16, 0, 0, xdim-1, ydim-1); } else - rotatesprite(x<<16, (y<<3)<<16, 65536l, 0, ac, shade, + rotatesprite(x<<16, (y<<3)<<16, 65536, 0, ac, shade, pal, 8|16, 0, 0, xdim-1, ydim-1); x += OSDCHAR_WIDTH; }