Frustum.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef CORE_FRUSTUM_H
  2. #define CORE_FRUSTUM_H
  3. #include "data/Array.h"
  4. #include "math/Matrix.h"
  5. #include "math/Plane.h"
  6. namespace Core {
  7. class Frustum final {
  8. Matrix projection;
  9. Array<Plane, 6> planes;
  10. public:
  11. float tan;
  12. float nearClip;
  13. float farClip;
  14. Frustum(float fieldOfView, float nearClip, float farClip);
  15. const Matrix& updateProjection(const IntVector2& size);
  16. void updatePlanes(const Vector3& pos, const Vector3& right,
  17. const Vector3& up, const Vector3& front,
  18. const IntVector2& size);
  19. bool isInside(const Vector3& pos) const;
  20. bool isInside(const Vector3& pos, float radius) const;
  21. // returns true on error and calls the error callback
  22. template<int L>
  23. check_return bool toString(ArrayString<L>& s) const {
  24. return s.append("(tan = ") || s.append(tan) ||
  25. s.append(", nearClip = ") || s.append(nearClip) ||
  26. s.append(", farClip = ") || s.append(farClip) ||
  27. s.append(')');
  28. }
  29. };
  30. }
  31. #endif