- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
template<typename T> struct OBB
{
vector3<T> position;
matrix3<T> transform;
vector3<T> GetPoint(bool positiveX, bool positiveY, bool positiveZ) const
{
const vector3<T> localUnitPoint = {T(positiveX)-T(0.5), T(positiveY)-T(0.5), T(positiveZ)-T(0.5)};
return vector3<T>(GetFullTransform()*vector4<T>(localUnitPoint, 1));
}
AABB<T> BoundingAABB() const
{
AABB<T> result;
result.max = result.min = position;
for(bool b1: {false, true})
for(bool b2: {false, true})
for(bool b3: {false, true}) //Перебираем все точки параллелепипеда
result.AddPoint(GetPoint(b1, b2, b3));
return result;
}
};
Что-то даже не могу вспомнить, когда я такое написал. Случайно наткнулся и решил, что это должно быть здесь.