Box.h 854 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef CORE_BOX_H
  2. #define CORE_BOX_H
  3. #include "math/Vector.h"
  4. #include "utils/ArrayString.h"
  5. namespace Core {
  6. class Box final {
  7. Vector3 min;
  8. Vector3 max;
  9. Box(const Vector3& min, const Vector3& max);
  10. public:
  11. Box(const Vector3& size);
  12. Box offset(const Vector3& offset) const;
  13. bool collidesWith(const Box& other) const;
  14. Box expand(const Vector3& offset) const;
  15. Box grow(const Vector3& growth) const;
  16. const Vector3& getMin() const;
  17. const Vector3& getMax() const;
  18. // returns true on error and calls the error callback
  19. template<int L>
  20. check_return bool toString(ArrayString<L>& s) const {
  21. return s.append("Box(") || s.append(min) || s.append(", ") ||
  22. s.append(max) || s.append(")");
  23. }
  24. };
  25. }
  26. #endif