MCPcopy Create free account
hub / github.com/assaultcube/AC / render_square

Function render_square

source/src/rendercubes.cpp:340–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338}
339
340void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil2, int x1, int y1, int x2, int y2, int size, sqr *l1, sqr *l2, bool flip, int dir) // wall quads
341{
342 if(showmipstats) { l1 = &sbright; l2 = &sdark; }
343
344 Texture *t = lookupworldtexture(wtex);
345 float xf = TEXTURESCALE/t->xs;
346 float yf = -TEXTURESCALE/t->ys;
347 float xs = size*xf;
348 float xo = xf*(x1==x2 ? min(y1,y2) : min(x1,x2));
349
350 bool first = striptype!=STRIP_WALL || striptex!=wtex || ox!=x1 || oy!=y1 || ofloor!=floor1 || oceil!=ceil1 || odir!=dir,
351 hf = floor1!=floor2 || ceil1!=ceil2;
352
353 if(first)
354 {
355 stripend(verts);
356 firstindex = verts.length();
357 striptex = wtex;
358 striptype = STRIP_WALL;
359
360 if(!flip)
361 {
362 vert(x1, y1, ceil1, l1, xo, yf*ceil1);
363 vert(x1, y1, floor1, l1, xo, yf*floor1);
364 }
365 else
366 {
367 vert(x1, y1, floor1, l1, xo, yf*floor1);
368 vert(x1, y1, ceil1, l1, xo, yf*ceil1);
369 }
370 ol1r = l1->r;
371 ol1g = l1->g;
372 ol1b = l1->b;
373 }
374 else // continue strip
375 {
376 int lighterr = lighterror*2;
377 if((!hf && !ohf)
378 && ((iabs(ol1r-l2->r)<lighterr && iabs(ol1g-l2->g)<lighterr && iabs(ol1b-l2->b)<lighterr) || !wtex)) // skip vertices if light values are close enough
379 {
380 verts.setsize(verts.length()-2);
381 nquads--;
382 }
383 else
384 {
385 uchar *p1 = (uchar *)(&verts[verts.length()-1].r);
386 ol1r = p1[0];
387 ol1g = p1[1];
388 ol1b = p1[2];
389 }
390 }
391
392 if(!flip)
393 {
394 vert(x2, y2, ceil2, l2, xo+xs, yf*ceil2);
395 vert(x2, y2, floor2, l2, xo+xs, yf*floor2);
396 }
397 else

Callers 1

render_wallFunction · 0.85

Calls 5

lookupworldtextureFunction · 0.85
minFunction · 0.85
iabsFunction · 0.85
setsizeMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected