Renamed [Box|Rect]::GetSize() to GetLengths()

Former-commit-id: 3c122057634a6472034b284bfe7091acbb41d004
This commit is contained in:
Lynix 2013-06-09 15:34:36 +02:00
parent 7080719287
commit c940abdb75
5 changed files with 19 additions and 19 deletions

View File

@ -40,11 +40,11 @@ class NzBox
NzSphere<T> GetBoundingSphere() const;
NzVector3<T> GetCorner(nzCorner corner) const;
NzVector3<T> GetCenter() const;
NzVector3<T> GetLengths() const;
NzVector3<T> GetNegativeVertex(const NzVector3<T>& normal) const;
NzVector3<T> GetPosition() const;
NzVector3<T> GetPositiveVertex(const NzVector3<T>& normal) const;
T GetRadius() const;
NzVector3<T> GetSize() const;
T GetSquaredRadius() const;
bool Intersect(const NzBox& box, NzBox* intersection = nullptr) const;

View File

@ -159,7 +159,13 @@ NzSphere<T> NzBox<T>::GetBoundingSphere() const
template<typename T>
NzVector3<T> NzBox<T>::GetCenter() const
{
return GetPosition() + F(0.5)*GetSize();
return GetPosition() + F(0.5)*GetLengths();
}
template<typename T>
NzVector3<T> NzBox<T>::GetLengths() const
{
return NzVector3<T>(width, height, depth);
}
template<typename T>
@ -208,16 +214,10 @@ T NzBox<T>::GetRadius() const
return std::sqrt(GetSquaredRadius());
}
template<typename T>
NzVector3<T> NzBox<T>::GetSize() const
{
return NzVector3<T>(width, height, depth);
}
template<typename T>
T NzBox<T>::GetSquaredRadius() const
{
NzVector3<T> size(GetSize());
NzVector3<T> size(GetLengths());
size *= F(0.5); // La taille étant relative à la position (minimum) de la boite et non pas à son centre
return size.GetSquaredLength();
@ -375,7 +375,7 @@ template<typename T>
NzBox<T>& NzBox<T>::Transform(const NzMatrix4<T>& matrix, bool applyTranslation)
{
NzVector3<T> center = matrix.Transform(GetCenter(), (applyTranslation) ? F(1.0) : F(0.0)); // Valeur multipliant la translation
NzVector3<T> halfSize = GetSize() * F(0.5);
NzVector3<T> halfSize = GetLengths() * F(0.5);
halfSize.Set(std::fabs(matrix(0,0))*halfSize.x + std::fabs(matrix(1,0))*halfSize.y + std::fabs(matrix(2,0))*halfSize.z,
std::fabs(matrix(0,1))*halfSize.x + std::fabs(matrix(1,1))*halfSize.y + std::fabs(matrix(2,1))*halfSize.z,

View File

@ -33,10 +33,10 @@ class NzRect
NzRect& ExtendTo(const NzRect& rect);
NzVector2<T> GetCenter() const;
NzVector2<T> GetLengths() const;
NzVector2<T> GetNegativeVertex(const NzVector2<T>& normal) const;
NzVector2<T> GetPosition() const;
NzVector2<T> GetPositiveVertex(const NzVector2<T>& normal) const;
NzVector2<T> GetSize() const;
bool Intersect(const NzRect& rect, NzRect* intersection = nullptr) const;

View File

@ -106,7 +106,13 @@ NzRect<T>& NzRect<T>::ExtendTo(const NzRect& rect)
template<typename T>
NzVector2<T> NzRect<T>::GetCenter() const
{
return NzVector2<T>(x + width/F(2.0), y + height/F(2.0));
return GetPosition() + F(0.5)*GetLengths();
}
template<typename T>
NzVector2<T> NzRect<T>::GetLengths() const
{
return NzVector2<T>(width, height);
}
template<typename T>
@ -143,12 +149,6 @@ NzVector2<T> NzRect<T>::GetPositiveVertex(const NzVector2<T>& normal) const
return pos;
}
template<typename T>
NzVector2<T> NzRect<T>::GetSize() const
{
return NzVector2<T>(width, height);
}
template<typename T>
bool NzRect<T>::Intersect(const NzRect& rect, NzRect* intersection) const
{

View File

@ -63,7 +63,7 @@ void NzDebugDrawer::Draw(const NzBoxf& box)
NzVertexStruct_XYZ* vertex = reinterpret_cast<NzVertexStruct_XYZ*>(mapper.GetPointer());
NzVector3f max, min;
max = box.GetPosition() + box.GetSize();
max = box.GetPosition() + box.GetLengths();
min = box.GetPosition();
vertex->position.Set(min.x, min.y, min.z);