bounds.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2011-2014 Branimir Karadzic. All rights reserved.
  3. * License: http://www.opensource.org/licenses/BSD-2-Clause
  4. */
  5. #ifndef BOUNDS_H_HEADER_GUARD
  6. #define BOUNDS_H_HEADER_GUARD
  7. struct Aabb
  8. {
  9. float m_min[3];
  10. float m_max[3];
  11. };
  12. struct Obb
  13. {
  14. float m_mtx[16];
  15. };
  16. struct Sphere
  17. {
  18. float m_center[3];
  19. float m_radius;
  20. };
  21. /// Convert axis aligned bounding box to oriented bounding box.
  22. void aabbToObb(Obb& _obb, const Aabb& _aabb);
  23. /// Calculate surface area of axis aligned bounding box.
  24. float calcAabbArea(Aabb& _aabb);
  25. /// Calculate axis aligned bounding box.
  26. void calcAabb(Aabb& _aabb, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
  27. /// Transform vertices and calculate axis aligned bounding box.
  28. void calcAabb(Aabb& _aabb, const float* _mtx, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
  29. /// Calculate oriented bounding box.
  30. void calcObb(Obb& _obb, const void* _vertices, uint32_t _numVertices, uint32_t _stride, uint32_t _steps = 17);
  31. /// Calculate maximum bounding sphere.
  32. void calcMaxBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
  33. /// Calculate minimum bounding sphere.
  34. void calcMinBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _numVertices, uint32_t _stride, float _step = 0.01f);
  35. #endif // BOUNDS_H_HEADER_GUARD