mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
47 lines
1.3 KiB
C
47 lines
1.3 KiB
C
/*
|
|
* Copyright 2011-2013 Branimir Karadzic. All rights reserved.
|
|
* License: http://www.opensource.org/licenses/BSD-2-Clause
|
|
*/
|
|
|
|
#ifndef __BOUNDS_H__
|
|
#define __BOUNDS_H__
|
|
|
|
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);
|
|
|
|
/// 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);
|
|
|
|
/// 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);
|
|
|
|
#endif // __BOUNDS_H__
|