summaryrefslogtreecommitdiffstats
path: root/src/Defines.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Defines.h')
-rw-r--r--src/Defines.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/Defines.h b/src/Defines.h
index 6ab2274a4..3b7654265 100644
--- a/src/Defines.h
+++ b/src/Defines.h
@@ -2,6 +2,7 @@
#pragma once
#include "ChatColor.h"
+#include <limits>
@@ -276,6 +277,26 @@ inline eBlockFace RotateBlockFaceCW(eBlockFace a_BlockFace)
+/** Returns the textual representation of the BlockFace constant. */
+inline AString BlockFaceToString(eBlockFace a_BlockFace)
+{
+ switch (a_BlockFace)
+ {
+ case BLOCK_FACE_XM: return "BLOCK_FACE_XM";
+ case BLOCK_FACE_XP: return "BLOCK_FACE_XP";
+ case BLOCK_FACE_YM: return "BLOCK_FACE_YM";
+ case BLOCK_FACE_YP: return "BLOCK_FACE_YP";
+ case BLOCK_FACE_ZM: return "BLOCK_FACE_ZM";
+ case BLOCK_FACE_ZP: return "BLOCK_FACE_ZP";
+ case BLOCK_FACE_NONE: return "BLOCK_FACE_NONE";
+ }
+ return Printf("Unknown BLOCK_FACE: %d", a_BlockFace);
+}
+
+
+
+
+
inline bool IsValidBlock(int a_BlockType)
{
if (
@@ -469,7 +490,7 @@ inline void EulerToVector(double a_Pan, double a_Pitch, double & a_X, double & a
inline void VectorToEuler(double a_X, double a_Y, double a_Z, double & a_Pan, double & a_Pitch)
{
- if (a_X != 0)
+ if (fabs(a_X) < std::numeric_limits<double>::epsilon())
{
a_Pan = atan2(a_Z, a_X) * 180 / PI - 90;
}