Advertisement
Guest User

k

a guest
Jun 29th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. inline bool WorldToPoint(float fCircleGay, const CVector2D& vec2WindowPosition, const CVector2D& vec2WindowSize, const CVector3D& vec3Origin, const CVector3D& vec3LocalOrigin, const CVector3D& vec3LocalAngles, CVector2D& vec2Point, const float& fRadarRange)
  2. {
  3. float fdx = vec3Origin.GetX() - vec3LocalOrigin.GetX();
  4. float fdy = vec3Origin.GetY() - vec3LocalOrigin.GetY();
  5.  
  6. float fya = NMath::Deg2Rad(vec3LocalAngles.GetY());
  7.  
  8. float fzx = fdy * (-cos(fya)) + fdx * sin(fya);
  9. float fzy = fdx * (-cos(fya)) - fdy * sin(fya);
  10.  
  11. if (fRadarRange > 0)
  12. {
  13. fzx /= fRadarRange;
  14. fzy /= fRadarRange;
  15. }
  16.  
  17. if (r_radar_sqr.GetBool())
  18. {
  19. if (abs(fzx) > fCircleGay || abs(fzy) > fCircleGay)
  20. {
  21. //Implant: r_radar_clamppoint for r_radar_sqr
  22. if (!r_radar_clamppoint.GetBool())
  23. return false;
  24.  
  25. float angle = atan2(fzy, fzx);
  26.  
  27. float radius = cos(M_PI / 4.f) / cos(fmodf(angle + M_PI * 0.25f, M_PI * 0.5f) - M_PI_ON_4);
  28.  
  29. float meme = fCircleGay / (radius + M_FLT_EPSILON);
  30.  
  31. fzx *= meme;
  32. fzy *= meme;
  33. }
  34. }
  35. else
  36. {
  37. if ((fzx * fzx + fzy * fzy) > fCircleGay)
  38. {
  39. if (!r_radar_clamppoint.GetBool())
  40. return false;
  41.  
  42. float ok = CVector2D(fzx, fzy).Length();
  43.  
  44. fzx /= ok;
  45. fzy /= ok;
  46.  
  47. fCircleGay = sqrt(fCircleGay);
  48.  
  49. fzx *= fCircleGay;
  50. fzy *= fCircleGay;
  51. }
  52. }
  53.  
  54. vec2Point = CVector2D((float(vec2WindowPosition.GetX()) + fzx) + float(vec2WindowSize.GetX() / 2), (float(vec2WindowPosition.GetY()) + fzy) + float(vec2WindowSize.GetY() / 2));
  55.  
  56. return true;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement