* Auto-grayout for plain old sectors toggled with Ctrl-A. When it is in effect, _all_ sectors which fall outside the [min ceiling z, max floor z] bounds of all active extended sectors are deactivated.

* make it possible to duplicate from extended sectors; all extensions are cleared from them
* lazy hightile loading in tile selector can now be disabled in mapster32.cfg
* fixes USE_OPENGL=0 build


git-svn-id: https://svn.eduke32.com/eduke32@1890 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-05-18 22:44:09 +00:00
parent 219dc6dd26
commit 0c190bfa55
7 changed files with 118 additions and 62 deletions

View file

@ -97,6 +97,7 @@ extern const char *g_namesFileName;
extern const char *defsfilename; // set in bstub.c
extern int32_t g_lazy_tileselector;
extern int32_t m32_osd_tryscript;
extern int32_t showheightindicators;
extern int32_t showambiencesounds;
@ -105,6 +106,7 @@ extern uint8_t graysectbitmap[MAXSECTORS>>3];
extern uint8_t graywallbitmap[MAXWALLS>>3];
#ifdef YAX_ENABLE
extern int32_t autogray;
int32_t yax_is121(int16_t bunchnum, int16_t getfloor);
#endif

View file

@ -1595,17 +1595,7 @@ static void duplicate_selected_sectors(void)
int32_t i, j, startwall, endwall, newnumsectors, newwalls = 0;
int32_t minx=INT32_MAX, maxx=INT32_MIN, miny=INT32_MAX, maxy=INT32_MIN, dx, dy;
#ifdef YAX_ENABLE
int16_t cb, fb;
for (i=0; i<highlightsectorcnt; i++)
{
yax_getbunches(highlightsector[i], &cb, &fb);
if (cb>=0 || fb>=0)
{
printmessage16("Cannot duplicate extended sectors!");
return;
}
}
int16_t cb, fb, hadextended=0;
#endif
for (i=0; i<highlightsectorcnt; i++)
@ -1630,6 +1620,19 @@ static void duplicate_selected_sectors(void)
for (i=0; i<highlightsectorcnt; i++)
{
copysector(highlightsector[i], newnumsectors, newnumwalls, 1, oldtonewsect);
#ifdef YAX_ENABLE
yax_getbunches(highlightsector[i], &cb, &fb);
if (cb>=0 || fb>=0)
{
hadextended = 1;
yax_setbunches(newnumsectors, -1, -1);
for (WALLS_OF_SECTOR(newnumsectors, j))
{
yax_setnextwall(j, 0, -1);
yax_setnextwall(j, 1, -1);
}
}
#endif
newnumsectors++;
newnumwalls += sector[highlightsector[i]].wallnum;
}
@ -1695,6 +1698,11 @@ static void duplicate_selected_sectors(void)
newnumsectors = -1;
updatenumsprites();
#ifdef YAX_ENABLE
if (hadextended)
printmessage16("Sectors duplicated and stamped, clearing extensions.");
else
#endif
printmessage16("Sectors duplicated and stamped.");
asksave = 1;
}

View file

@ -169,6 +169,7 @@ int32_t loadsetup(const char *fn)
#ifdef USE_OPENGL
if (readconfig(fp, "usemodels", val, VL) > 0) usemodels = !!atoi_safe(val);
if (readconfig(fp, "usehightile", val, VL) > 0) usehightile = !!atoi_safe(val);
if (readconfig(fp, "lazytileselector", val, VL) > 0) g_lazy_tileselector = !!atoi_safe(val);
glusetexcache = -1;
if (readconfig(fp, "glusetexcache", val, VL) > 0)
@ -364,6 +365,7 @@ int32_t writesetup(const char *fn)
"; OpenGL mode options\n"
"usemodels = %d\n"
"usehightile = %d\n"
"lazytileselector = %d\n"
"; glusetexcache: 0:no, 1:yes, 2:compressed\n"
"glusetexcache = %d\n"
"gltexfiltermode = %d\n"
@ -523,7 +525,7 @@ int32_t writesetup(const char *fn)
#endif
editorgridextent, clamp(default_grid, 0, 9),
#ifdef USE_OPENGL
usemodels, usehightile,
usemodels, usehightile, g_lazy_tileselector,
glusetexcache, gltexfiltermode, glanisotropy,r_downsize,glusetexcompr,
shadescale,
#endif

View file

@ -200,6 +200,7 @@ extern int32_t m32_numdebuglines;
uint8_t graysectbitmap[MAXSECTORS>>3];
uint8_t graywallbitmap[MAXWALLS>>3];
int32_t autogray = 0;
#ifdef ENGINE_SCREENSHOT_DEBUG
int32_t engine_screenshot = 0;
@ -208,9 +209,12 @@ int32_t engine_screenshot = 0;
void yax_updategrays(int32_t posze)
{
int32_t i, j, k=1;
#ifndef YAX_ENABLE
#ifdef YAX_ENABLE
int32_t mingoodz=INT32_MAX, maxgoodz=INT32_MIN;
#else
UNREFERENCED_PARAMETER(posze);
#endif
Bmemset(graysectbitmap, 0, sizeof(graysectbitmap));
Bmemset(graywallbitmap, 0, sizeof(graywallbitmap));
@ -220,19 +224,37 @@ void yax_updategrays(int32_t posze)
int16_t cb, fb;
yax_getbunches(i, &cb, &fb);
// update grayouts due to yax
// update grayouts due to yax --v-- has to be half-open --v--
// because only one level should v be ever active v
k = ((cb<0 || sector[i].ceilingz < posze) && (fb<0 || posze <= sector[i].floorz));
if (autogray && (cb>=0 || fb>=0) && (sector[i].ceilingz <= posze && posze <= sector[i].floorz))
{
mingoodz = min(mingoodz, sector[i].ceilingz);
maxgoodz = max(maxgoodz, sector[i].floorz);
}
#endif
// update grayouts due to editorzrange
k &= (sector[i].ceilingz >= editorzrange[0] && sector[i].floorz <= editorzrange[1]);
if (!k) // outside bounds, gray out!
{
graysectbitmap[i>>3] |= (1<<(i&7));
}
#ifdef YAX_ENABLE
if (autogray && mingoodz<=maxgoodz)
{
for (i=0; i<numsectors; i++)
if (!(mingoodz <= sector[i].ceilingz && sector[i].floorz <= maxgoodz))
graysectbitmap[i>>3] |= (1<<(i&7));
}
#endif
for (i=0; i<numsectors; i++)
{
if (graysectbitmap[i>>3]&(1<<(i&7)))
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
graywallbitmap[j>>3] |= (1<<(j&7));
}
}
}
@ -611,17 +633,19 @@ static int yax_cmpbunches(const int16_t *b1, const int16_t *b2)
static void yax_tweakpicnums(int32_t bunchnum, int32_t cf, int32_t restore)
{
static int16_t opicnum[2][MAXSECTORS];
int32_t i;
int32_t i, stat;
for (SECTORS_OF_BUNCH(bunchnum, cf, i))
if ((SECTORFLD(i,stat, cf)&(128+256))==0)
{
stat = (SECTORFLD(i,stat, cf)&(128+256+4096));
if ((stat&4096) || stat==0)
{
if (!restore)
{
opicnum[cf][i] = SECTORFLD(i,picnum, cf);
if (editstatus && showinvisibility)
SECTORFLD(i,picnum, cf) = MAXTILES-1-((SECTORFLD(i,stat, cf)&4096)>>12);
else
SECTORFLD(i,picnum, cf) = MAXTILES-1-((stat&4096)>>12);
else if ((stat&(128+256))==0)
SECTORFLD(i,picnum, cf) = 13; //FOF;
}
else
@ -629,6 +653,7 @@ static void yax_tweakpicnums(int32_t bunchnum, int32_t cf, int32_t restore)
SECTORFLD(i,picnum, cf) = opicnum[cf][i];
}
}
}
}
static void yax_copytsprite(int32_t curbunchnum, int32_t resetsortcnt)
@ -682,7 +707,7 @@ static void yax_copytsprite(int32_t curbunchnum, int32_t resetsortcnt)
void yax_preparedrawrooms(void)
{
if (rendmode!=0 || numyaxbunches==0)
if (getrendermode()!=0 || numyaxbunches==0)
return;
g_nodraw = 1;
@ -720,7 +745,7 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
int32_t t;
#endif
if (rendmode!=0 || numyaxbunches==0)
if (getrendermode()!=0 || numyaxbunches==0)
{
#ifdef ENGINE_SCREENSHOT_DEBUG
engine_screenshot = 0;
@ -762,7 +787,7 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
j = yax_getbunch(i, cf);
if (j >= 0 && !(havebunch[j>>3]&(1<<(j&7))))
{
if ((haveymost[j>>3]&(1<<(j&7)))==0)
if (getrendermode()==0 && (haveymost[j>>3]&(1<<(j&7)))==0)
{
yaxdebug("%s, l %d: skipped bunch %d (no *most)", cf?"v":"^", lev, j);
continue;
@ -847,10 +872,13 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
scansector_collectsprites = 0;
#ifdef ENGINE_CLEAR_SCREEN
if (rendmode==0)
{
begindrawing();
for (i=0; i<xdim*ydim; i++)
*((char *)frameplace + i) = i;
enddrawing();
}
#endif
for (cf=0; cf<2; cf++)
@ -916,6 +944,8 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
#endif
#ifdef YAX_DEBUG_YMOSTS
if (rendmode==0)
{
begindrawing();
for (i=0; i<numyaxbunches; i++)
{
@ -938,6 +968,7 @@ void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectn
}
}
enddrawing();
}
#endif
}
@ -7588,7 +7619,7 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz,
i = mulscale16(xdimenscale,viewingrangerecip);
globalpisibility = mulscale16(parallaxvisibility,i);
globalvisibility = rendmode==0 ? mulscale16(visibility,i) : scale(visibility<<2,4,3);
globalvisibility = getrendermode()==0 ? mulscale16(visibility,i) : scale(visibility<<2,4,3);
globalhisibility = mulscale16(globalvisibility,xyaspect);
globalcisibility = mulscale8(globalhisibility,320);
@ -14437,10 +14468,10 @@ void draw2dscreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int32_t z
{
for (i=numwalls-1; i>=0; i--)
#ifdef YAX_ENABLE
if (graywallbitmap[(i)>>3]&(1<<((i)&7)))
if (graywallbitmap[i>>3]&(1<<(i&7)))
drawscreen_drawwall(i,posxe,posye,posze,zoome);
for (i=numwalls-1; i>=0; i--)
if ((graywallbitmap[(i)>>3]&(1<<((i)&7)))==0)
if ((graywallbitmap[i>>3]&(1<<(i&7)))==0)
#endif
drawscreen_drawwall(i,posxe,posye,posze,zoome);
}
@ -14918,11 +14949,13 @@ int32_t screencapture_png(const char *filename, char inverseit, const char *vers
buf = (png_bytep)png_malloc(png_ptr, xdim*ydim);
Bmemcpy(buf, (char *)frameplace, xdim*ydim);
}
#ifdef USE_OPENGL
else
{
buf = (png_bytep)png_malloc(png_ptr, xdim*ydim*3);
bglReadPixels(0,0,xdim,ydim,GL_RGB,GL_UNSIGNED_BYTE,buf);
}
#endif
enddrawing(); //}}}
rowptrs = (png_bytepp)png_malloc(png_ptr, ydim*sizeof(png_bytep));

View file

@ -2186,7 +2186,7 @@ void drawpoly(double *dpx, double *dpy, int32_t n, int32_t method)
{
float pc[4];
int32_t shadebound = (shadescale_unbounded || globalshade>31) ? numpalookups : 31;
int32_t shadebound = (shadescale_unbounded || globalshade>=numpalookups) ? numpalookups : numpalookups-1;
f = ((float)(numpalookups-min(max((globalshade * shadescale),0),shadebound)))/((float)numpalookups);
pc[0] = pc[1] = pc[2] = f;
switch (method&3)
@ -4177,7 +4177,9 @@ void polymost_drawrooms()
if (rendmode >= 3)
{
resizeglcheck();
#ifdef YAX_ENABLE
if (numyaxbunches==0)
#endif
if (editstatus)
bglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
@ -5795,7 +5797,7 @@ void polymost_fillpolygon(int32_t npoints)
pthtyp *pth;
float f,a=0.0;
int32_t i;
int32_t shadebound = (shadescale_unbounded || globalshade>31) ? numpalookups : 31;
int32_t shadebound = (shadescale_unbounded || globalshade>=numpalookups) ? numpalookups : numpalookups-1;
globalx1 = mulscale16(globalx1,xyaspect);
globaly2 = mulscale16(globaly2,xyaspect);

View file

@ -939,11 +939,12 @@ int32_t checkvideomode(int32_t *x, int32_t *y, int32_t c, int32_t fs, int32_t fo
int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
{
int32_t regrab = 0;
#ifdef USE_OPENGL
static int32_t warnonce = 0;
#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
static int32_t ovsync = 1;
#endif
#endif
if ((fs == fullscreen) && (x == xres) && (y == yres) && (c == bpp) &&
!videomodereset)
{

View file

@ -97,6 +97,7 @@ static struct strllist
const char *scripthist[SCRIPTHISTSIZ];
int32_t scripthistend = 0;
int32_t g_lazy_tileselector = 1;
int32_t showambiencesounds=2;
int32_t autocorruptcheck = 0;
@ -3945,8 +3946,9 @@ static int32_t OnSelectTile(int32_t iTile)
bflushchars();
setpolymost2dview();
#ifdef USE_OPENGL
bglEnable(GL_TEXTURE_2D);
#endif
clearview(0);
//
@ -4072,7 +4074,6 @@ static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTi
char markedcol = editorcolors[14];
setpolymost2dview();
bglEnable(GL_TEXTURE_2D);
y1=max(y1, 0);
y2=min(y2, ydim-1);
@ -4157,8 +4158,9 @@ static int32_t DrawTiles(int32_t iTopLeft, int32_t iSelected, int32_t nXTiles, i
static uint8_t loadedhitile[(MAXTILES+7)>>3];
setpolymost2dview();
#ifdef USE_OPENGL
bglEnable(GL_TEXTURE_2D);
#endif
clearview(0);
begindrawing();
@ -4172,8 +4174,7 @@ restart:
if (iTile < 0 || iTile >= localartlookupnum)
continue;
usehitile = runi;
usehitile = (runi || !g_lazy_tileselector);
idTile = localartlookup[ iTile ];
if (loadedhitile[idTile>>3]&(1<<(idTile&7)))
@ -4205,7 +4206,7 @@ restart:
tilescreen_drawbox(iTopLeft, iSelected, nXTiles, TileDim, offset, iTile, idTile);
if (runi==1)
if (runi==1 && g_lazy_tileselector)
{
int32_t k;
@ -4238,7 +4239,7 @@ restart:
tilescreen_drawrest(iSelected, showmsg);
if (rendmode>=3 && qsetmode==200)
if (getrendermode()>=3 && qsetmode==200 && g_lazy_tileselector)
{
if (runi==0)
{
@ -7585,6 +7586,13 @@ static void Keys2d(void)
updatesectorz(pos.x, pos.y, pos.z, &cursectnum);
}
}
if (eitherCTRL && PRESSED_KEYSC(A))
{
autogray = !autogray;
printmessage16("Automatic grayout of plain sectors %s", ONOFF(autogray));
yax_updategrays(pos.z);
}
#endif
// Ctrl-R set editor z range to hightlightsectors' c/f bounds