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

Function intersectclosest

source/src/weapon.cpp:345–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345playerent *intersectclosest(const vec &from, const vec &to, const playerent *at, float &bestdistsquared, int &hitzone, bool aiming = true)
346{
347 playerent *best = NULL;
348 bestdistsquared = 1e16f;
349 int zone;
350 if(at!=player1 && player1->state==CS_ALIVE && (zone = intersect(player1, from, to)))
351 {
352 best = player1;
353 bestdistsquared = at->o.squareddist(player1->o);
354 hitzone = zone;
355 }
356 loopv(players)
357 {
358 playerent *o = players[i];
359 if(!o || o==at || (o->state!=CS_ALIVE && (aiming || (o->state!=CS_EDITING && o->state!=CS_LAGGED)))) continue;
360 float distsquared = at->o.squareddist(o->o);
361 if(distsquared < bestdistsquared && (zone = intersect(o, from, to)))
362 {
363 best = o;
364 bestdistsquared = distsquared;
365 hitzone = zone;
366 }
367 }
368 return best;
369}
370
371playerent *playerincrosshair()
372{

Callers 3

playerincrosshairFunction · 0.85
loopiFunction · 0.85
raydamageFunction · 0.85

Calls 2

intersectFunction · 0.85
squareddistMethod · 0.80

Tested by

no test coverage detected