summaryrefslogtreecommitdiffstats
path: root/src/GameState.cpp
diff options
context:
space:
mode:
authorElisey Puzko <puzko.e02@gmail.com>2018-02-25 11:33:12 +0100
committerElisey Puzko <puzko.e02@gmail.com>2018-02-25 11:41:59 +0100
commitdf7024b9e1bac4b8b27b74b77a948d4f3d1d3253 (patch)
tree4b0a526de6c5b3a79533943e8fcecc373168d050 /src/GameState.cpp
parentI forgot about these functions (diff)
downloadAltCraft-df7024b9e1bac4b8b27b74b77a948d4f3d1d3253.tar
AltCraft-df7024b9e1bac4b8b27b74b77a948d4f3d1d3253.tar.gz
AltCraft-df7024b9e1bac4b8b27b74b77a948d4f3d1d3253.tar.bz2
AltCraft-df7024b9e1bac4b8b27b74b77a948d4f3d1d3253.tar.lz
AltCraft-df7024b9e1bac4b8b27b74b77a948d4f3d1d3253.tar.xz
AltCraft-df7024b9e1bac4b8b27b74b77a948d4f3d1d3253.tar.zst
AltCraft-df7024b9e1bac4b8b27b74b77a948d4f3d1d3253.zip
Diffstat (limited to '')
-rw-r--r--src/GameState.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp
index 9478085..192a0c5 100644
--- a/src/GameState.cpp
+++ b/src/GameState.cpp
@@ -594,33 +594,37 @@ BlockFacing detectHitFace(VectorF raycastHit, Vector selectedBlock) {
static const auto vecRight = VectorF(1, 0, 0);
static const auto vecForward = VectorF(0, 0, -1);
- auto up = vec.cosBetween(vecUp);
- auto down = -up;
- auto right = vec.cosBetween(vecRight);
- auto left = -right;
- auto forward = vec.cosBetween(vecForward);
- auto backward = -forward;
+ double up = vec.cosBetween(vecUp);
+ double down = -up;
+ double right = vec.cosBetween(vecRight);
+ double left = -right;
+ double forward = vec.cosBetween(vecForward);
+ double backward = -forward;
// TODO: create a min/max function for the variable number of arguments
- auto min = std::min(
- std::min(
- std::min(
- std::min(
- std::min(up, down),
+ // NOTE: function names are surrounded by parentheses to avoid conflict of
+ // `std::min` and a `min` macro from `windows.h`. If there will be more uses
+ // of `std::min`, a macro `NOMINMAX` should be defined because these hacks can
+ // have the real impact on the performance.
+ double min_cos = (std::min)(
+ (std::min)(
+ (std::min)(
+ (std::min)(
+ (std::min)(up, down),
right),
left),
forward),
backward);
- if (min == down)
+ if (min_cos == down)
return BlockFacing::Bottom;
- else if (min == up)
+ else if (min_cos == up)
return BlockFacing::Top;
- else if (min == forward)
+ else if (min_cos == forward)
return BlockFacing::North;
- else if (min == backward)
+ else if (min_cos == backward)
return BlockFacing::South;
- else if (min == left)
+ else if (min_cos == left)
return BlockFacing::West;
else return BlockFacing::East;
}