Box.h 652 B

123456789101112131415161718192021222324252627282930
  1. #ifndef COLLISION_BOX_H
  2. #define COLLISION_BOX_H
  3. #include "math/Vector.h"
  4. #include "utils/StringBuffer.h"
  5. class Box {
  6. Vector3 min;
  7. Vector3 max;
  8. Box(const Vector3& min, const Vector3& max);
  9. public:
  10. Box(const Vector3& size);
  11. Box offset(const Vector3& offset) const;
  12. bool collidesWith(const Box& other) const;
  13. Box expand(const Vector3& offset) const;
  14. Box grow(const Vector3& growth) const;
  15. const Vector3& getMin() const;
  16. const Vector3& getMax() const;
  17. template<int L>
  18. void toString(StringBuffer<L>& s) const {
  19. s.append("Box(").append(min).append(", ").append(max).append(")");
  20. }
  21. };
  22. #endif