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

Function objcollide

source/src/physics.cpp:196–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194}
195
196bool objcollide(physent *d, const vec &objpos, float objrad, float objheight) // collide with custom/typeless objects
197{
198 const float r = d->radius+objrad;
199 if(fabs(objpos.x-d->o.x)<r && fabs(objpos.y-d->o.y)<r)
200 {
201 const float maxdist = (d->eyeheight+d->aboveeye+objheight)/2.0f;
202 const float dz = d->o.z+(-d->eyeheight+d->aboveeye)/2.0f;
203 const float objz = objpos.z+objheight/2.0f;
204 return dz-objz <= maxdist && dz-objz >= -maxdist;
205 }
206 return false;
207}
208
209// all collision happens here
210// spawn is a dirty side effect used in spawning

Callers 1

checkitemsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected