From 6f5635917f3903c8f8a302a610518dd7e6a35f1f Mon Sep 17 00:00:00 2001 From: ac-stef Date: Tue, 28 Jan 2014 14:28:43 +0100 Subject: [PATCH] visualisation for tagclips To keep things cheap, only tagged areas inside the editing grid are shown. I added two variables, tagnum and taglife, to allow playing with the parameters of the sparklies. Those should be removed later. The default values work quite well on my really crappy onboard graphics card. Higher values start dropping fps. Also, the edit status line now shows the tag value of the cube pointed at. The patch also fixes the bug, that the edit status line did not show details about the selection, unless there was at least one entity in the map. --- source/src/editing.cpp | 21 ++++++++++++++++----- source/src/protos.h | 1 + source/src/renderparticles.cpp | 12 ++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/source/src/editing.cpp b/source/src/editing.cpp index 21ce8fc5..8e723092 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -86,12 +86,17 @@ char *editinfo() { static string info; if(!editmode) return NULL; + info[0] = '\0'; int e = closestent(); - if(e<0) return NULL; - entity &c = ents[e]; - string selinfo = "no selection"; - if(selset()) formatstring(selinfo)("selection = (%d, %d)", (sels.last()).xs, (sels.last()).ys); - formatstring(info)("closest entity = %s (%d, %d, %d, %d), %s", entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4, selinfo); + if(e >= 0) + { + entity &c = ents[e]; + formatstring(info)("closest entity = %s (%d, %d, %d, %d), ", entnames[c.type], c.attr1, c.attr2, c.attr3, c.attr4); + } + if(selset()) concatformatstring(info, "selection = (%d, %d)", (sels.last()).xs, (sels.last()).ys); + else concatformatstring(info, "no selection"); + sqr *s; + if(!OUTBORD(cx, cy) && (s = S(cx,cy)) && !SOLID(s) && s->tag) concatformatstring(info, ", tag 0x%02X", s->tag); return info; } @@ -151,6 +156,11 @@ VARP(showgrid,0,1,1); // VC8 optimizer screws up rendering somehow if this is an actual function #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(taglife, 1, 30, 1000); +// and have mercy with old graphics cards... + void cursorupdate() // called every frame from hud { flrceil = ((int)(camera1->pitch>=0))*2; @@ -200,6 +210,7 @@ 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(s->tag & (TAGCLIP|TAGPLCLIP)) 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); diff --git a/source/src/protos.h b/source/src/protos.h index 7d46b481..e6e8929a 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -650,6 +650,7 @@ extern void particleinit(); extern void particlereset(); extern void particle_flash(int type, float scale, float angle, const vec &p); extern void particle_splash(int type, int num, int fade, const vec &p); +extern void particle_cube(int type, int num, int fade, int x, int y); extern void particle_trail(int type, int fade, const vec &from, const vec &to); extern void particle_emit(int type, int *args, int basetime, int seed, const vec &p); extern void particle_fireball(int type, const vec &o); diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index c3ee3422..cca4a41b 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -582,6 +582,18 @@ void particle_splash(int type, int num, int fade, const vec &p) } } +void particle_cube(int type, int num, int fade, int x, int y) +{ + sqr *s = S(x, y); + const int fc = s->ceil - s->floor; + if(SOLID(s) || fc < 1) return; + loopi(num * fc / 3) + { + vec p(float(rnd(100)) / 100.0 + x, float(rnd(100)) / 100.0 + y, float(rnd(100) * fc) / 100 + s->floor), d(0, 0, 0); + newparticle(p, d, rnd(fade*3), type); + } +} + VARP(maxtrail, 1, 500, 10000); void particle_trail(int type, int fade, const vec &s, const vec &e)