less annoying visualisation for tagclips

- press B to get the former filled volume view
- raise the value of tagnumfull to get both views simultaneously
- cubescript parameters should be cleaned up before release
This commit is contained in:
ac-stef
2014-01-30 19:38:41 +01:00
parent a8d2ab1c65
commit d258b7c186
7 changed files with 69 additions and 4 deletions
+43 -2
View File
@@ -157,10 +157,17 @@ VARP(showgrid,0,1,1);
#define sheight(s,t,z) (!flrceil ? (s->type==FHF ? s->floor-t->vdelta/4.0f : (float)s->floor) : (s->type==CHF ? s->ceil+t->vdelta/4.0f : (float)s->ceil))
// remove those two after playing with the values a bit :)
VAR(tagnum, 1, 3, 100);
VAR(tagnum, 1, 14, 100);
VAR(tagnumfull, 0, 0, 100);
VAR(taglife, 1, 30, 1000);
// and have mercy with old graphics cards...
vector<short> tagclipcubes;
bool showtagclipfocus = false;
COMMANDF(showtagclipfocus, "d", (bool on) { showtagclipfocus = on; } );
VAR(showtagclips, 0, 1, 1);
FVAR(tagcliplinewidth, 0.2, 1, 3);
void cursorupdate() // called every frame from hud
{
flrceil = ((int)(camera1->pitch>=0))*2;
@@ -214,7 +221,8 @@ void cursorupdate() // called every frame fr
float h2 = sheight(s, SWS(s,1,0,sfactor), z);
float h3 = sheight(s, SWS(s,1,1,sfactor), z);
float h4 = sheight(s, SWS(s,0,1,sfactor), z);
if(sparkletime && s->tag & (TAGCLIP|TAGPLCLIP)) particle_cube(s->tag & TAGCLIP ? PART_EPICKUP : PART_EMODEL, tagnum, taglife, ix, iy);
if(sparkletime && showtagclips && showtagclipfocus && s->tag & TAGANYCLIP)
particle_cube(s->tag & TAGCLIP ? PART_EPICKUP : PART_EMODEL, tagnum, taglife, ix, iy);
if(s->tag) linestyle(GRIDW, 0xFF, 0x40, 0x40);
else if(s->type==FHF || s->type==CHF) linestyle(GRIDW, 0x80, 0xFF, 0x80);
else linestyle(GRIDW, 0x80, 0x80, 0x80);
@@ -245,6 +253,39 @@ void cursorupdate() // called every frame fr
loopv(sels) box(sels[i], (float)sels[i].h, (float)sels[i].h, (float)sels[i].h, (float)sels[i].h);
}
if(!showtagclipfocus && showtagclips)
{
const int xo[] = { 0, 0, 1, 1, 0 }, yo[] = {0, 1, 1, 0, 0 };
loopv(tagclipcubes) // all non-solid & have clips
{
int x = tagclipcubes[i++]; int y = tagclipcubes[i];
ASSERT(!OUTBORD(x, y));
sqr *s = S(x,y), *o[9];
if(s->tag & TAGCLIP) linestyle(tagcliplinewidth, 0xFF, 0xFF, 0); // yello
else linestyle(tagcliplinewidth, 0xFF, 0, 0xFF); // magenta
o[8] = SWS(s,-1,-1,sfactor);
o[3] = o[8] + 1; // 837
o[7] = o[3] + 1; // 0s2
o[0] = o[4] = SWS(s,-1,0,sfactor); // 516
o[2] = o[0] + 2;
o[5] = SWS(s,-1,1,sfactor);
o[1] = o[5] + 1;
o[6] = o[1] + 1;
bool clipped[9];
loopj(9) clipped[j] = !SOLID(o[j]) && (o[j]->tag & TAGANYCLIP) > 0;
int h = s->floor - (s->type == FHF ? (s->vdelta + 3) / 4 : 0), c = s->ceil + (s->type == CHF ? (s->vdelta + 3) / 4 : 0);
loopk(4) if((!clipped[k] && !clipped[k+1]) || (clipped[k] && clipped[k+1] && !clipped[k + 5])) line(x + xo[k+1], y + yo[k+1], h, x + xo[k+1], y + yo[k+1], c);
for( ; h <= c; h++)
{
int k = (h + x + y) & 3;
if(k < 2 && !clipped[k]) line(x + xo[k], y + yo[k], h + 1, x + xo[k+1], y + yo[k+1], h);
k = (h - x - y) & 3;
if(k > 1 && !clipped[k]) line(x + xo[k], y + yo[k], h + 1, x + xo[k+1], y + yo[k+1], h);
}
if(sparkletime && tagnumfull) particle_cube(s->tag & TAGCLIP ? PART_EPICKUP : PART_EMODEL, tagnumfull, 30, x, y);
}
}
glLineWidth(1);
}
+1 -1
View File
@@ -178,7 +178,7 @@ bool collide(physent *d, bool spawn, float drop, float rise, int level) // level
float hi = 127, lo = -128;
const float eyeheight = d->eyeheight;
const float playerheight = eyeheight + d->aboveeye;
const int applyclip = d->type == ENT_BOT || d->type == ENT_PLAYER || (d->type == ENT_BOUNCE && ((bounceent *)d)->plclipped) ? TAGCLIP|TAGPLCLIP : TAGCLIP;
const int applyclip = d->type == ENT_BOT || d->type == ENT_PLAYER || (d->type == ENT_BOUNCE && ((bounceent *)d)->plclipped) ? TAGANYCLIP : TAGCLIP;
if(level&1) for(int y = y1; y<=y2; y++) for(int x = x1; x<=x2; x++) // collide with map
{
+2
View File
@@ -1125,6 +1125,8 @@ void gl_drawframe(int w, int h, float changelod, float curfps)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
disablepolygonoffset(GL_POLYGON_OFFSET_LINE, false);
}
extern vector<short> tagclipcubes;
tagclipcubes.setsize(0);
extern vector<vertex> verts;
gl_drawhud(w, h, (int)round(curfps), nquads, verts.length(), underwater);
+1 -1
View File
@@ -588,7 +588,7 @@ void particle_cube(int type, int num, int fade, int x, int y)
const int fc = s->ceil - s->floor + (s->vdelta + 3) / 4;
const float floor = s->floor - (s->type == FHF ? float(s->vdelta) / 4 : 0);
if(SOLID(s) || fc < 1) return;
loopi(num * fc / 3)
loopi(num * fc / 12)
{
vec p(float(rnd(100)) / 100.0 + x, float(rnd(100)) / 100.0 + y, float(rnd(100) * fc) / 100 + floor), d(0, 0, 0);
newparticle(p, d, rnd(fade*3), type);
+1
View File
@@ -38,6 +38,7 @@ enum // stuff encoded in sqr.tag
TAGCLIP = 0x40, // clips all objects
TAGPLCLIP = 0x80 // clips only players
};
#define TAGANYCLIP (TAGCLIP|TAGPLCLIP)
#define MAXMAPVERSION 10 // defines the highest readable format
#define MAPVERSION 9 // default map format version to be written (bump if map format changes, see worldio.cpp)
+20
View File
@@ -252,6 +252,26 @@ void render_seg_new(float vx, float vy, float vh, int mip, int x, int y, int xs,
render_wall(s, v, xx, yy+1, xx+1, yy+1, mip, v, u, true, 3); // bot
}
}}
extern vector<short> tagclipcubes;
extern bool showtagclipfocus;
extern int showtagclips;
if(editmode && !showtagclipfocus && showtagclips) LOOPH continue; // tag clips
loopi(1<<mip)
{
int iy = (yy<<mip) + i;
loopj(1<<mip)
{
int ix = (xx<<mip) + j;
sqr *t = S(ix, iy);
if(!SOLID(t) && t->tag & TAGANYCLIP)
{
tagclipcubes.add(ix);
tagclipcubes.add(iy);
}
}
}
}}
}
void distlod(int &low, int &high, int angle, float widef)