| 309 | |
| 310 | |
| 311 | int intersect(playerent *d, const vec &from, const vec &to, vec *end) |
| 312 | { |
| 313 | float dist; |
| 314 | if(d->head.x >= 0) |
| 315 | { |
| 316 | if(intersectsphere(from, to, d->head, HEADSIZE, dist)) |
| 317 | { |
| 318 | if(end) (*end = to).sub(from).mul(dist).add(from); |
| 319 | return 2; |
| 320 | } |
| 321 | } |
| 322 | float y = d->yaw*RAD, p = (d->pitch/4+90)*RAD, c = cosf(p); |
| 323 | vec bottom(d->o), top(sinf(y)*c, -cosf(y)*c, sinf(p))/*, mid(top)*/; |
| 324 | bottom.z -= d->eyeheight; |
| 325 | float h = d->eyeheight /*+ d->aboveeye*/; // this mod makes the shots pass over the shoulders |
| 326 | // mid.mul(h*0.5).add(bottom); // this mod divides the hitbox in 2 |
| 327 | top.mul(h).add(bottom); |
| 328 | if( intersectcylinder(from, to, bottom, top, d->radius, dist) ) // FIXME if using 2 hitboxes |
| 329 | { |
| 330 | if(end) (*end = to).sub(from).mul(dist).add(from); |
| 331 | return 1; |
| 332 | } |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | bool intersect(entity *e, const vec &from, const vec &to, vec *end) |
| 337 | { |
no test coverage detected