Float/Ciel: If it's going to use C++11, it might as well take advantage of it
This commit is contained in:
parent
f8d1e96ae7
commit
76b37acb42
@ -27,9 +27,9 @@
|
|||||||
return super::GetClass(); \
|
return super::GetClass(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define POSX_TOINT FloorD(GetPosX())
|
#define POSX_TOINT FloorC(GetPosX())
|
||||||
#define POSY_TOINT FloorD(GetPosY())
|
#define POSY_TOINT FloorC(GetPosY())
|
||||||
#define POSZ_TOINT FloorD(GetPosZ())
|
#define POSZ_TOINT FloorC(GetPosZ())
|
||||||
#define POS_TOINT Vector3i(POSXTOINT, POSYTOINT, POSZTOINT)
|
#define POS_TOINT Vector3i(POSXTOINT, POSYTOINT, POSZTOINT)
|
||||||
|
|
||||||
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == NULL) || !ChunkVarName->IsValid()) { return; }
|
#define GET_AND_VERIFY_CURRENT_CHUNK(ChunkVarName, X, Z) cChunk * ChunkVarName = a_Chunk.GetNeighborChunk(X, Z); if ((ChunkVarName == NULL) || !ChunkVarName->IsValid()) { return; }
|
||||||
|
@ -400,34 +400,20 @@ T Clamp(T a_Value, T a_Min, T a_Max)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Floors a_Value, then casts it to C (an int by default) */
|
/** Floors a value, then casts it to C (an int by default) */
|
||||||
template <typename C = int>
|
template <typename C = int, typename T>
|
||||||
C FloorD(double a_Value)
|
typename std::enable_if<std::is_arithmetic<T>::value, C>::type FloorC(T a_Value)
|
||||||
{
|
{
|
||||||
return static_cast<C>(std::floor(a_Value));
|
return static_cast<C>(std::floor(a_Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Floors a_Value, then casts it to C (an int by default) */
|
/** Ceils a value, then casts it to C (an int by default) */
|
||||||
template <typename C = int>
|
template <typename C = int, typename T>
|
||||||
C FloorF(double a_Value)
|
typename std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC(T a_Value)
|
||||||
{
|
|
||||||
return static_cast<C>(std::floorf(a_Value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Ciels a_Value, then casts it to C (an int by default) */
|
|
||||||
template <typename C = int>
|
|
||||||
C CeilD(double a_Value)
|
|
||||||
{
|
{
|
||||||
return static_cast<C>(std::ceil(a_Value));
|
return static_cast<C>(std::ceil(a_Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ciels a_Value, then casts it to C (an int by default) */
|
|
||||||
template <typename C = int>
|
|
||||||
C CeilF(double a_Value)
|
|
||||||
{
|
|
||||||
return static_cast<C>(std::ceilf(a_Value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,9 +137,9 @@ public:
|
|||||||
inline Vector3<int> Floor(void) const
|
inline Vector3<int> Floor(void) const
|
||||||
{
|
{
|
||||||
return Vector3<int>(
|
return Vector3<int>(
|
||||||
static_cast<int>(floor(x)),
|
FloorC(x),
|
||||||
static_cast<int>(floor(y)),
|
FloorC(y),
|
||||||
static_cast<int>(floor(z))
|
FloorC(z)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user