MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / find_nearest_hook

Function find_nearest_hook

src/SB/Game/zEntPlayerBungeeState.cpp:711–728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

709 return 0;
710 }
711 static S32 find_nearest_hook(const xVec3& loc)
712 {
713 S32 found = -1;
714 F32 closest = 10000000000.0f;
715 for (S32 i = 0; i < shared.hook_cache_size; ++i)
716 {
717 F32 attach_dist = shared.hook_cache[i]->asset->attach.dist;
718 xVec3* p = xEntGetPos(shared.hook_cache[i]->ent);
719 xVec3 dloc = *p + shared.hook_cache[i]->asset->center - loc;
720 F32 len2 = dloc.length2();
721 if (len2 <= SQR(attach_dist) && len2 < closest)
722 {
723 found = i;
724 closest = len2;
725 }
726 }
727 return found;
728 }
729 static void init_sounds()
730 {
731 }

Callers 1

startFunction · 0.70

Calls 2

xEntGetPosFunction · 0.85
length2Method · 0.45

Tested by

no test coverage detected