In view cone snippet

From Valve Developer Community
Revision as of 13:56, 15 June 2008 by John6000 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

bool CMyEnt::InViewCone( const Vector &vecSpot, float tolerance ) {

   Vector los = ( vecSpot - GetAbsOrigin() );
   los.z = 0;
   VectorNormalize( los );
   Vector facingDir;
   AngleVectors( GetAbsAngles(), &facingDir );
   float flDot = DotProduct( los, facingDir );
   if ( flDot > tolerance )

return true;

   return false;

}