Moved AxisAlignedBox::GetCorner to Cube
Former-commit-id: 59509594e6cda19089b93efd8dc77ab7bd20250c
This commit is contained in:
parent
f14a68fc04
commit
60d41f3c4b
|
|
@ -8,6 +8,7 @@
|
|||
#define NAZARA_CUBE_HPP
|
||||
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Math/Enums.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Math/Vector3.hpp>
|
||||
|
||||
|
|
@ -31,6 +32,7 @@ class NzCube
|
|||
NzCube& ExtendTo(const NzVector3<T>& point);
|
||||
NzCube& ExtendTo(const NzCube& cube);
|
||||
|
||||
NzVector3<T> GetCorner(nzCorner corner) const;
|
||||
NzVector3<T> GetCenter() const;
|
||||
NzVector3<T> GetPosition() const;
|
||||
NzVector3<T> GetSize() const;
|
||||
|
|
|
|||
|
|
@ -96,6 +96,40 @@ NzCube<T>& NzCube<T>::ExtendTo(const NzCube& cube)
|
|||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetCorner(nzCorner corner) const
|
||||
{
|
||||
switch (corner)
|
||||
{
|
||||
case nzCorner_FarLeftBottom:
|
||||
return NzVector3f(x, y, z);
|
||||
|
||||
case nzCorner_FarLeftTop:
|
||||
return NzVector3f(x, y + height, z);
|
||||
|
||||
case nzCorner_FarRightBottom:
|
||||
return NzVector3f(x + width, y, z);
|
||||
|
||||
case nzCorner_FarRightTop:
|
||||
return NzVector3f(x + width, y + height, z);
|
||||
|
||||
case nzCorner_NearLeftBottom:
|
||||
return NzVector3f(x, y, z + depth);
|
||||
|
||||
case nzCorner_NearLeftTop:
|
||||
return NzVector3f(x, y + height, z + depth);
|
||||
|
||||
case nzCorner_NearRightBottom:
|
||||
return NzVector3f(x + width, y, z + depth);
|
||||
|
||||
case nzCorner_NearRightTop:
|
||||
return NzVector3f(x + width, y + height, z + depth);
|
||||
}
|
||||
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
return NzVector3f();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T> NzCube<T>::GetCenter() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Mathematics module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_ENUMS_MATH_HPP
|
||||
#define NAZARA_ENUMS_MATH_HPP
|
||||
|
||||
enum nzCorner
|
||||
{
|
||||
nzCorner_FarLeftBottom,
|
||||
nzCorner_FarLeftTop,
|
||||
nzCorner_FarRightBottom,
|
||||
nzCorner_FarRightTop,
|
||||
nzCorner_NearLeftBottom,
|
||||
nzCorner_NearLeftTop,
|
||||
nzCorner_NearRightBottom,
|
||||
nzCorner_NearRightTop,
|
||||
|
||||
nzCorner_Max = nzCorner_FarRightTop
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_MATH_HPP
|
||||
|
|
@ -59,20 +59,6 @@ enum nzCoordSys
|
|||
nzCoordSys_Max = nzCoordSys_Local
|
||||
};
|
||||
|
||||
enum nzCorner
|
||||
{
|
||||
nzCorner_FarLeftBottom,
|
||||
nzCorner_FarLeftTop,
|
||||
nzCorner_FarRightBottom,
|
||||
nzCorner_FarRightTop,
|
||||
nzCorner_NearLeftBottom,
|
||||
nzCorner_NearLeftTop,
|
||||
nzCorner_NearRightBottom,
|
||||
nzCorner_NearRightTop,
|
||||
|
||||
nzCorner_Max = nzCorner_FarRightTop
|
||||
};
|
||||
|
||||
enum nzCubemapFace
|
||||
{
|
||||
// Cette énumération est prévue pour remplacer l'argument "z" des méthodes de NzImage contenant un cubemap
|
||||
|
|
|
|||
|
|
@ -84,6 +84,8 @@ void NzAxisAlignedBox::ExtendTo(const NzAxisAlignedBox& box)
|
|||
operator=(box);
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Extend type not handled (0x" + NzString::Number(m_extend, 16) + ')');
|
||||
}
|
||||
|
||||
void NzAxisAlignedBox::ExtendTo(const NzVector3f& vector)
|
||||
|
|
@ -103,38 +105,28 @@ void NzAxisAlignedBox::ExtendTo(const NzVector3f& vector)
|
|||
m_cube.Set(vector, vector);
|
||||
break;
|
||||
}
|
||||
|
||||
NazaraError("Extend type not handled (0x" + NzString::Number(m_extend, 16) + ')');
|
||||
}
|
||||
|
||||
NzVector3f NzAxisAlignedBox::GetCorner(nzCorner corner) const
|
||||
{
|
||||
switch (corner)
|
||||
switch (m_extend)
|
||||
{
|
||||
case nzCorner_FarLeftBottom:
|
||||
return NzVector3f(m_cube.x, m_cube.y, m_cube.z);
|
||||
case nzExtend_Finite:
|
||||
return m_cube.GetCorner(corner);
|
||||
|
||||
case nzCorner_FarLeftTop:
|
||||
return NzVector3f(m_cube.x, m_cube.y+m_cube.height, m_cube.z);
|
||||
case nzExtend_Infinite:
|
||||
// Il est possible de renvoyer un vecteur avec des flottants infinis dont le signe dépend du coin
|
||||
// Bien que ça soit plus juste mathématiquement, je ne vois pas l'intérêt...
|
||||
NazaraError("Infinite AABB has no corner");
|
||||
return NzVector3f();
|
||||
|
||||
case nzCorner_FarRightBottom:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y, m_cube.z);
|
||||
|
||||
case nzCorner_FarRightTop:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y+m_cube.height, m_cube.z);
|
||||
|
||||
case nzCorner_NearLeftBottom:
|
||||
return NzVector3f(m_cube.x, m_cube.y, m_cube.z+m_cube.depth);
|
||||
|
||||
case nzCorner_NearLeftTop:
|
||||
return NzVector3f(m_cube.x, m_cube.y+m_cube.height, m_cube.z+m_cube.depth);
|
||||
|
||||
case nzCorner_NearRightBottom:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y, m_cube.z+m_cube.depth);
|
||||
|
||||
case nzCorner_NearRightTop:
|
||||
return NzVector3f(m_cube.x+m_cube.width, m_cube.y+m_cube.height, m_cube.z+m_cube.depth);
|
||||
case nzExtend_Null:
|
||||
return NzVector3f::Zero();
|
||||
}
|
||||
|
||||
NazaraError("Corner not handled (0x" + NzString::Number(corner, 16) + ')');
|
||||
NazaraError("Extend type not handled (0x" + NzString::Number(m_extend, 16) + ')');
|
||||
return NzVector3f();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue