Moved AxisAlignedBox::GetCorner to Cube
Former-commit-id: 59509594e6cda19089b93efd8dc77ab7bd20250c
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
24
include/Nazara/Math/Enums.hpp
Normal file
24
include/Nazara/Math/Enums.hpp
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user