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

Function plcollide

source/src/physics.cpp:76–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74physent *hitplayer = NULL;
75
76bool plcollide(physent *d, physent *o, float &headspace, float &hi, float &lo) // collide with physent
77{
78 if(o->state!=CS_ALIVE || !o->cancollide) return false;
79 const float r = o->radius+d->radius;
80 const vec dr = vec(o->o.x-d->o.x,o->o.y-d->o.y,0);
81 const float deyeheight = d->eyeheight, oeyeheight = o->eyeheight;
82 if((d->type==ENT_PLAYER && o->type==ENT_PLAYER ? dr.sqrxy() < r*r : fabs(dr.x)<r && fabs(dr.y)<r) && dr.dotxy(d->vel) >= 0.0f)
83 {
84 if(d->o.z-deyeheight<o->o.z-oeyeheight) { if(o->o.z-oeyeheight<hi) hi = o->o.z-oeyeheight-1; }
85 else if(o->o.z+o->aboveeye>lo) lo = o->o.z+o->aboveeye;
86
87 if(fabs(o->o.z-d->o.z)<o->aboveeye+deyeheight) { hitplayer = o; return true; }
88 headspace = d->o.z-o->o.z-o->aboveeye-deyeheight;
89 if(headspace<0) headspace = 10;
90 }
91 return false;
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{

Callers 2

loopvFunction · 0.85
collideFunction · 0.85

Calls 3

vecClass · 0.85
sqrxyMethod · 0.80
dotxyMethod · 0.80

Tested by

no test coverage detected