Frustum.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef CORE_FRUSTUM_HPP
  2. #define CORE_FRUSTUM_HPP
  3. #include "data/Array.hpp"
  4. #include "math/Matrix.hpp"
  5. #include "math/Plane.hpp"
  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. template<typename String>
  22. check_return Error toString(String& s) const {
  23. CORE_RETURN_ERROR(s.append("(tan = "));
  24. CORE_RETURN_ERROR(s.append(tan));
  25. CORE_RETURN_ERROR(s.append(", nearClip = "));
  26. CORE_RETURN_ERROR(s.append(nearClip));
  27. CORE_RETURN_ERROR(s.append(", farClip = "));
  28. CORE_RETURN_ERROR(s.append(farClip));
  29. CORE_RETURN_ERROR(s.append(')'));
  30. return Error::NONE;
  31. }
  32. };
  33. }
  34. #endif