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

Function cornertest

source/src/physics.cpp:94–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94int cornertest(int x, int y, int &bx, int &by, int &bs, sqr *&s, sqr *&h) // iteratively collide with a mipmapped corner cube
95{
96 int mip = 1, res = -1;
97 while(SWS(wmip[mip], x>>mip, y>>mip, sfactor-mip)->type==CORNER) mip++;
98 mip--;
99 x >>= mip;
100 y >>= mip;
101 int mfactor = sfactor - mip;
102 bx = x<<mip; // bx, by and bs are the real-world coordinates and size of the corner mip
103 by = y<<mip; // s is the corner mip and h is the companion mip of a corner between non-solids (to get floor and ceil from)
104 bs = 1<<mip;
105 sqr *z = SWS(wmip[mip],x - 1, y,mfactor);
106 sqr *t = SWS(z,2,0,mfactor); // w
107 sqr *w = SWS(z,1,-1,mfactor); // zst
108 sqr *v = SWS(z,1,1,mfactor); // v
109 s = SWS(z,1,0,mfactor);
110
111 // now, this is _exactly_ how the renderer interprets map geometry...
112 if(SOLID(z))
113 {
114 if(SOLID(w)) res = 2; // corners between solids are solid behind the wall or SPACE in front of it
115 else if(SOLID(v)) res = 3;
116 }
117 else if(SOLID(t))
118 {
119 if(SOLID(w)) res = 1;
120 else if(SOLID(v)) res = 0;
121 }
122 else
123 { // not a corner between solids
124 bool wv = w->ceil-w->floor < v->ceil-v->floor;
125 h = wv ? v : w; // in front of the corner, use floor and ceil from h
126 if(z->ceil-z->floor < t->ceil-t->floor) res = wv ? 2 : 3;
127 else res = wv ? 1 : 0;
128 } // 03
129 return res; // 12
130}
131
132static int cornersurface = 0;
133

Callers 2

collideFunction · 0.85
intersectgeometryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected