MCPcopy Index your code
hub / github.com/assaultcube/AC / intersect

Function intersect

source/src/weapon.cpp:311–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

309
310
311int 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
336bool intersect(entity *e, const vec &from, const vec &to, vec *end)
337{

Callers 4

intersectclosestFunction · 0.85
loopvFunction · 0.85
loopvFunction · 0.85
TraceLineFunction · 0.85

Calls 7

intersectsphereFunction · 0.85
intersectcylinderFunction · 0.85
getmminfoFunction · 0.85
intersectboxFunction · 0.85
vecClass · 0.85
mulMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected