command to automatically convert all suitable clip entities into tag clips

also: fix sparklies in heightfields
This commit is contained in:
ac-stef
2014-01-29 00:03:50 +01:00
parent 3add3a4876
commit 7f12ef4131
2 changed files with 43 additions and 3 deletions
+39
View File
@@ -760,3 +760,42 @@ COMMANDF(selectionrotate, "i", (int *d) { selectionrotate(*d); });
COMMAND(selectionflip, "s");
COMMAND(countwalls, "i");
COMMANDF(settex, "ii", (int *texture, int *type) { settex(*texture, *type); });
void transformclipentities() // transforms all clip entities to tag clips, if they are big enough (so, that no player could be above or below them)
{
EDITMP;
int entsdone = 0;
loopv(ents)
{
entity &e = ents[i];
if((e.type == CLIP || e.type == PLCLIP) && e.attr2 && e.attr3 && e.attr4)
{
int allowedspace = e.type == CLIP ? 1 : 4;
int x1 = e.x - e.attr2, x2 = e.x + e.attr2 - 1, y1 = e.y - e.attr3, y2 = e.y + e.attr3 - 1;
int z1 = S(e.x, e.y)->floor + e.attr1, z2 = z1 + e.attr4;
bool bigenough = true;
for(int xx = x1; xx <= x2; xx++) for(int yy = y1; yy <= y2; yy++)
{
if(OUTBORD(xx,yy) || SOLID(S(xx,yy))) continue;
sqr *s[4] = { S(xx, yy), S(xx + 1, yy), S(xx, yy + 1), S(xx + 1, yy + 1) };
int vdeltamax = 0;
loopj(4) if(s[j]->vdelta > vdeltamax) vdeltamax = s[j]->vdelta;
int floor = s[0]->floor - (s[0]->type == FHF ? (vdeltamax + 3) / 4 : 0),
ceil = s[0]->ceil - (s[0]->type == CHF ? (vdeltamax + 3) / 4 : 0);
if(z1 - floor > allowedspace || ceil - z2 > allowedspace) bigenough = false;
}
if(bigenough)
{
for(int xx = x1; xx <= x2; xx++) for(int yy = y1; yy <= y2; yy++)
{
if(!OUTBORD(xx,yy) && !SOLID(S(xx,yy))) S(xx, yy)->tag |= e.type == CLIP ? TAGCLIP : TAGPLCLIP;
}
e.type = NOTUSED;
entsdone++;
}
}
}
conoutf("changed %d clip entities to tagged clip areas", entsdone);
}
COMMAND(transformclipentities, "");
+4 -3
View File
@@ -258,7 +258,7 @@ static struct parttype { int type; float r, g, b; int gr, tex; float sz; } partt
{ PT_FIREBALL, 1.0f, 0.5f, 0.5f, 0, 2, 7.0f }, // explosion fireball
{ PT_SHOTLINE, 1.0f, 1.0f, 0.7f, 0, -1, 0.0f }, // yellow: shotline
{ PT_BULLETHOLE, 1.0f, 1.0f, 1.0f, 0, 3, 0.3f }, // hole decal
{ PT_STAIN, 0.5f, 0.0f, 0.0f, 0, 4, 0.6f }, // red: blood stain
{ PT_DECAL, 1.0f, 1.0f, 1.0f, 0, 5, 1.5f }, // scorch decal
{ PT_HUDFLASH, 1.0f, 1.0f, 1.0f, 0, 6, 0.7f }, // hudgun muzzle flash
@@ -585,11 +585,12 @@ 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;
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)
{
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);
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);
}
}