Box.hpp 944 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef CORE_BOX_HPP
  2. #define CORE_BOX_HPP
  3. #include "math/Vector.hpp"
  4. #include "utils/ArrayString.hpp"
  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. template<typename String>
  19. check_return Error toString(String& s) const {
  20. CORE_RETURN_ERROR(s.append("Box("));
  21. CORE_RETURN_ERROR(s.append(min));
  22. CORE_RETURN_ERROR(s.append(", "));
  23. CORE_RETURN_ERROR(s.append(max));
  24. CORE_RETURN_ERROR(s.append(")"));
  25. return Error::NONE;
  26. }
  27. };
  28. }
  29. #endif