| 74 | physent *hitplayer = NULL; |
| 75 | |
| 76 | bool 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 | |
| 94 | int cornertest(int x, int y, int &bx, int &by, int &bs, sqr *&s, sqr *&h) // iteratively collide with a mipmapped corner cube |
| 95 | { |