SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. inline void UTIL_ClipRayToEntity(Vector end, Vector start, trace_t* oldtrace, CBaseEntity* ent)
  2. {
  3.     auto mins = ent->GetMins(), maxs = ent->GetMaxs();
  4.  
  5.     auto dir(end - start);
  6.  
  7.     dir.NormalizeInPlace();
  8.  
  9.     auto center = (maxs + mins) / 2;
  10.  
  11.     auto pos(center + ent->GetNetworkOrigin());
  12.  
  13.     auto to = (pos - start);
  14.  
  15.     auto range_along = dir.Dot(to);
  16.  
  17.     float range;
  18.  
  19.     if (range_along < 0.f)
  20.         range = -to.Length();
  21.     else if (range_along > dir.Length())
  22.         range = -(pos - end).Length();
  23.     else
  24.     {
  25.         auto ray(pos - ((dir * range_along) + start));
  26.  
  27.         range = ray.Length();
  28.     }
  29.  
  30.     if (range <= 60.f)
  31.     {
  32.         trace_t tr;
  33.         Ray_t ray;
  34.         ray.Init(start, end);
  35.  
  36.         Interfaces::EngineTrace->ClipRayToEntity(ray, 0x4600400B, (IHandleEntity*)ent, &tr);
  37.  
  38.         if (oldtrace->fraction > tr.fraction)
  39.             *oldtrace = tr;
  40.     }
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top