summaryrefslogtreecommitdiff
path: root/src/mapnode.cpp
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2013-07-08 15:19:22 -0400
committerkwolekr <kwolekr@minetest.net>2013-07-08 15:19:48 -0400
commitce955f37ba9f431122ca3c46e5a7dac63ffd65ea (patch)
tree59785622b4848501fd26d42ebb554ccec20d9a42 /src/mapnode.cpp
parentc813a3cc53f0ab4a39f07d0a017db7b7e3ef6fbc (diff)
downloadminetest-ce955f37ba9f431122ca3c46e5a7dac63ffd65ea.tar.gz
minetest-ce955f37ba9f431122ca3c46e5a7dac63ffd65ea.tar.bz2
minetest-ce955f37ba9f431122ca3c46e5a7dac63ffd65ea.zip
Decoration: Handle facedir and wallmounted param2types with schematic rotation
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r--src/mapnode.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp
index bba845fcc..388818c42 100644
--- a/src/mapnode.cpp
+++ b/src/mapnode.cpp
@@ -28,6 +28,14 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string>
#include <sstream>
+static const Rotation wallmounted_to_rot[] = {
+ ROTATE_0, ROTATE_180, ROTATE_90, ROTATE_270
+};
+static const u8 rot_to_wallmounted[] = {
+ 2, 4, 3, 5
+};
+
+
/*
MapNode
*/
@@ -132,6 +140,24 @@ v3s16 MapNode::getWallMountedDir(INodeDefManager *nodemgr) const
}
}
+void MapNode::rotateAlongYAxis(INodeDefManager *nodemgr, Rotation rot) {
+ ContentParamType2 cpt2 = nodemgr->get(*this).param_type_2;
+
+ if (cpt2 == CPT2_FACEDIR) {
+ u8 newrot = param2 & 3;
+ param2 &= ~3;
+ param2 |= (newrot + rot) & 3;
+ } else if (cpt2 == CPT2_WALLMOUNTED) {
+ u8 wmountface = (param2 & 7);
+ if (wmountface <= 1)
+ return;
+
+ Rotation oldrot = wallmounted_to_rot[wmountface - 2];
+ param2 &= ~7;
+ param2 |= rot_to_wallmounted[(oldrot + rot) & 3];
+ }
+}
+
static std::vector<aabb3f> transformNodeBox(const MapNode &n,
const NodeBox &nodebox, INodeDefManager *nodemgr)
{