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

Function remip

source/src/world.cpp:19–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17// rendering time if this is possible).
18
19void remip(const block &b, int level)
20{
21 if(level>=SMALLEST_FACTOR) return;
22 int lighterr = lighterror*3;
23 sqr *w = wmip[level];
24 sqr *v = wmip[level+1];
25 int wfactor = sfactor - level;
26 int vfactor = sfactor - (level+1);
27 block s = b;
28 if(s.x&1) { s.x--; s.xs++; }
29 if(s.y&1) { s.y--; s.ys++; }
30 s.xs = (s.xs+1)&~1;
31 s.ys = (s.ys+1)&~1;
32 for(int y = s.y; y<s.y+s.ys; y+=2)
33 {
34 sqr *o[4];
35 o[0] = SWS(w,s.x,y,wfactor); // the 4 constituent cubes
36 o[1] = SWS(o[0],1,0,wfactor);
37 o[3] = SWS(o[0],0,1,wfactor);
38 o[2] = SWS(o[3],1,0,wfactor);
39 sqr *r = SWS(v,s.x/2,y/2,vfactor); // the target cube in the higher mip level
40
41 for(int x = s.x; x<s.x+s.xs; x+=2)
42 {
43 *r = *o[0];
44 r->type = o[0]->type == o[1]->type && o[0]->type == o[2]->type && o[0]->type == o[3]->type ? o[0]->type : SEMISOLID;
45 if(!SOLID(r))
46 {
47 int floor = 127, ceil = -128;
48 loopi(4) if(!SOLID(o[i]))
49 {
50 int fh = o[i]->floor;
51 int ch = o[i]->ceil;
52 if(r->type==SEMISOLID)
53 {
54 if(o[i]->type==FHF) fh -= o[i]->vdelta/4+2; // crap hack, needed for rendering large mips next to hfs
55 if(o[i]->type==CHF) ch += o[i]->vdelta/4+2; // FIXME: needs to somehow take into account middle vertices on higher mips
56 }
57 if(fh<floor) floor = fh; // take lowest floor and highest ceil, so we never have to see missing lower/upper from the side
58 if(ch>ceil) ceil = ch;
59 }
60 r->floor = floor;
61 r->ceil = ceil;
62 }
63 if(r->type==CORNER) goto mip; // special case: don't ever split even if textures etc are different
64 r->defer = 1;
65 if(level) { loopi(4) if(o[i]->defer) goto c; } // if any of the constituents is not perfect, then this one isn't either
66 if(SOLID(r))
67 {
68 loopi(3)
69 {
70 if(o[i]->wtex != o[3]->wtex) goto c; // on an all solid cube, only thing that needs to be equal for a perfect mip is the wall texture
71 }
72 }
73 else
74 {
75 loopi(3)
76 {

Callers 7

remipmoreFunction · 0.85
remipgenerousFunction · 0.85
mapmrproperFunction · 0.85
deletetextureslotFunction · 0.85
sorttextureslotsFunction · 0.85
postlightareaFunction · 0.85
replaceFunction · 0.85

Calls 2

iabsFunction · 0.85
loopiFunction · 0.70

Tested by

no test coverage detected