MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / findCoverCallback

Function findCoverCallback

Engine/source/T3D/aiPlayer.cpp:972–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

970};
971
972static void findCoverCallback(SceneObject *obj, void *key)
973{
974 CoverPoint *p = dynamic_cast<CoverPoint*>(obj);
975 if(!p || p->isOccupied())
976 return;
977 CoverSearch *s = static_cast<CoverSearch*>(key);
978 Point3F dir = s->from - p->getPosition();
979 dir.normalizeSafe();
980 // Score first based on angle of cover point to enemy.
981 F32 score = mDot(p->getNormal(), dir);
982 // Score also based on distance from seeker.
983 score -= (p->getPosition() - s->loc).len() / s->dist;
984 // Finally, consider cover size.
985 score += (p->getSize() + 1) / CoverPoint::NumSizes;
986 score *= p->getQuality();
987 if(score > s->best)
988 {
989 s->best = score;
990 s->point = p;
991 }
992}
993
994bool AIPlayer::findCover(const Point3F &from, F32 radius)
995{

Callers

nothing calls this directly

Calls 8

isOccupiedMethod · 0.80
getQualityMethod · 0.80
mDotFunction · 0.50
getPositionMethod · 0.45
normalizeSafeMethod · 0.45
getNormalMethod · 0.45
lenMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected