2013-02-22 09:07:31 +04:00
|
|
|
/*
|
2015-01-02 02:04:46 +03:00
|
|
|
* Copyright 2011-2015 Branimir Karadzic. All rights reserved.
|
2013-02-22 09:07:31 +04:00
|
|
|
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2013-11-15 07:10:10 +04:00
|
|
|
#ifndef BOUNDS_H_HEADER_GUARD
|
|
|
|
#define BOUNDS_H_HEADER_GUARD
|
2013-02-22 09:07:31 +04:00
|
|
|
|
|
|
|
struct Aabb
|
|
|
|
{
|
|
|
|
float m_min[3];
|
|
|
|
float m_max[3];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Obb
|
|
|
|
{
|
|
|
|
float m_mtx[16];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Sphere
|
|
|
|
{
|
|
|
|
float m_center[3];
|
|
|
|
float m_radius;
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Convert axis aligned bounding box to oriented bounding box.
|
|
|
|
void aabbToObb(Obb& _obb, const Aabb& _aabb);
|
|
|
|
|
2014-05-20 09:08:35 +04:00
|
|
|
/// Convert sphere to axis aligned bounding box.
|
|
|
|
void sphereToAabb(Aabb& _aabb, const Sphere& _sphere);
|
|
|
|
|
2013-02-22 09:07:31 +04:00
|
|
|
/// Calculate surface area of axis aligned bounding box.
|
|
|
|
float calcAabbArea(Aabb& _aabb);
|
|
|
|
|
|
|
|
/// Calculate axis aligned bounding box.
|
|
|
|
void calcAabb(Aabb& _aabb, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
|
|
|
|
|
|
|
|
/// Transform vertices and calculate axis aligned bounding box.
|
|
|
|
void calcAabb(Aabb& _aabb, const float* _mtx, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
|
|
|
|
|
2014-05-27 03:55:46 +04:00
|
|
|
/// Expand AABB.
|
|
|
|
void aabbExpand(Aabb& _aabb, float _factor);
|
|
|
|
|
|
|
|
/// Returns 0 is two AABB don't overlap, otherwise returns flags of overlap
|
|
|
|
/// test.
|
|
|
|
uint32_t aabbOverlapTest(Aabb& _aabb0, Aabb& _aabb1);
|
|
|
|
|
2013-02-22 09:07:31 +04:00
|
|
|
/// Calculate oriented bounding box.
|
|
|
|
void calcObb(Obb& _obb, const void* _vertices, uint32_t _numVertices, uint32_t _stride, uint32_t _steps = 17);
|
|
|
|
|
|
|
|
/// Calculate maximum bounding sphere.
|
|
|
|
void calcMaxBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _numVertices, uint32_t _stride);
|
|
|
|
|
|
|
|
/// Calculate minimum bounding sphere.
|
|
|
|
void calcMinBoundingSphere(Sphere& _sphere, const void* _vertices, uint32_t _numVertices, uint32_t _stride, float _step = 0.01f);
|
|
|
|
|
2013-11-15 07:10:10 +04:00
|
|
|
#endif // BOUNDS_H_HEADER_GUARD
|