Frustum.hpp 1015 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef CORE_FRUSTUM_HPP
  2. #define CORE_FRUSTUM_HPP
  3. #include "core/data/Array.hpp"
  4. #include "core/math/Matrix.hpp"
  5. #include "core/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. void toString(BufferString& s) const {
  22. s.append("(tan = ").append(tan);
  23. s.append(", nearClip = ").append(nearClip);
  24. s.append(", farClip = ").append(farClip);
  25. s.append(')');
  26. }
  27. };
  28. }
  29. #endif