loop optimizations

also cut some overshooting lines
This commit is contained in:
ac-stef
2014-01-31 00:53:12 +01:00
parent d258b7c186
commit e69a94cdd8
3 changed files with 14 additions and 14 deletions
+4 -4
View File
@@ -162,7 +162,7 @@ VAR(tagnumfull, 0, 0, 100);
VAR(taglife, 1, 30, 1000);
// and have mercy with old graphics cards...
vector<short> tagclipcubes;
vector<int> tagclipcubes;
bool showtagclipfocus = false;
COMMANDF(showtagclipfocus, "d", (bool on) { showtagclipfocus = on; } );
VAR(showtagclips, 0, 1, 1);
@@ -258,7 +258,7 @@ void cursorupdate() // called every frame fr
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];
int x = tagclipcubes[i] & 0xFFFF, y = tagclipcubes[i] >> 16;
ASSERT(!OUTBORD(x, y));
sqr *s = S(x,y), *o[9];
if(s->tag & TAGCLIP) linestyle(tagcliplinewidth, 0xFF, 0xFF, 0); // yello
@@ -274,8 +274,8 @@ void cursorupdate() // called every frame fr
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++)
loopk(4) if((clipped[k] == clipped[k+1]) && !(clipped[k] && 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);
+1 -1
View File
@@ -1125,7 +1125,7 @@ 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;
extern vector<int> tagclipcubes;
tagclipcubes.setsize(0);
extern vector<vertex> verts;
+9 -9
View File
@@ -253,24 +253,24 @@ void render_seg_new(float vx, float vy, float vh, int mip, int x, int y, int xs,
}
}}
extern vector<short> tagclipcubes;
extern vector<int> tagclipcubes;
extern bool showtagclipfocus;
extern int showtagclips;
if(editmode && !showtagclipfocus && showtagclips) LOOPH continue; // tag clips
loopi(1<<mip)
if(mip)
{
int iy = (yy<<mip) + i;
loopj(1<<mip)
int ix1 = xx<<mip, ix2 = (xx+1)<<mip, iy1 = yy<<mip, iy2 = (yy+1)<<mip;
sqr *tt = S(ix1, iy1), *t;
for(int iy = iy1; iy < iy2; iy++, tt += ssize)
{
int ix = (xx<<mip) + j;
sqr *t = S(ix, iy);
if(!SOLID(t) && t->tag & TAGANYCLIP)
t = tt;
for(int ix = ix1; ix < ix2; ix++, t++)
{
tagclipcubes.add(ix);
tagclipcubes.add(iy);
if(t->tag & TAGANYCLIP && t->type != SOLID) tagclipcubes.add(ix + (iy << 16));
}
}
}
else if(s->tag & TAGANYCLIP && s->type != SOLID) tagclipcubes.add(xx + (yy << 16));
}}
}