From d258b7c1865a29595fd9cd4b88e9e1fbce264f0a Mon Sep 17 00:00:00 2001 From: ac-stef Date: Thu, 30 Jan 2014 19:38:41 +0100 Subject: [PATCH] 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 --- config/resetbinds.cfg | 1 + source/src/editing.cpp | 45 ++++++++++++++++++++++++++++++++-- source/src/physics.cpp | 2 +- source/src/rendergl.cpp | 2 ++ source/src/renderparticles.cpp | 2 +- source/src/world.h | 1 + source/src/worldrender.cpp | 20 +++++++++++++++ 7 files changed, 69 insertions(+), 4 deletions(-) diff --git a/config/resetbinds.cfg b/config/resetbinds.cfg index 54fa0830..6dda235a 100644 --- a/config/resetbinds.cfg +++ b/config/resetbinds.cfg @@ -67,6 +67,7 @@ bind UNDERSCORE [] bind BACKQUOTE [ saycommand "/" ] bind A left bind B [ showmenu Weapons ] +editbind B [showtagclipfocus] bind C [] editbind C copy bind D right diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 81d12a03..a96a4b10 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -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 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); } diff --git a/source/src/physics.cpp b/source/src/physics.cpp index dca873a2..1e23f8dc 100644 --- a/source/src/physics.cpp +++ b/source/src/physics.cpp @@ -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 { diff --git a/source/src/rendergl.cpp b/source/src/rendergl.cpp index f532eee5..9df7f366 100644 --- a/source/src/rendergl.cpp +++ b/source/src/rendergl.cpp @@ -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 tagclipcubes; + tagclipcubes.setsize(0); extern vector verts; gl_drawhud(w, h, (int)round(curfps), nquads, verts.length(), underwater); diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index ce617db6..6e76f914 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -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); diff --git a/source/src/world.h b/source/src/world.h index 24c75f4a..4f628d7a 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -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) diff --git a/source/src/worldrender.cpp b/source/src/worldrender.cpp index 11d23255..99e4b996 100644 --- a/source/src/worldrender.cpp +++ b/source/src/worldrender.cpp @@ -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 tagclipcubes; + extern bool showtagclipfocus; + extern int showtagclips; + if(editmode && !showtagclipfocus && showtagclips) LOOPH continue; // tag clips + loopi(1<tag & TAGANYCLIP) + { + tagclipcubes.add(ix); + tagclipcubes.add(iy); + } + } + } + }} } void distlod(int &low, int &high, int angle, float widef)