aboutsummaryrefslogtreecommitdiff
path: root/src/mapnode.cpp
diff options
context:
space:
mode:
authorVitaliy <numzer0@yandex.ru>2021-03-30 01:25:11 +0300
committerGitHub <noreply@github.com>2021-03-30 00:25:11 +0200
commit3b78a223717c69918a5af422e21561f47ec74ce1 (patch)
treeaafa2961a6faafc58a2712dfcc277e662d149382 /src/mapnode.cpp
parentfde2785fe363c55e8acfd17af71375a231df41c1 (diff)
downloadminetest-3b78a223717c69918a5af422e21561f47ec74ce1.tar.xz
Degrotate support for mesh nodes (#7840)
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r--src/mapnode.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp
index 0551f3b6f..20980b238 100644
--- a/src/mapnode.cpp
+++ b/src/mapnode.cpp
@@ -177,6 +177,16 @@ v3s16 MapNode::getWallMountedDir(const NodeDefManager *nodemgr) const
}
}
+u8 MapNode::getDegRotate(const NodeDefManager *nodemgr) const
+{
+ const ContentFeatures &f = nodemgr->get(*this);
+ if (f.param_type_2 == CPT2_DEGROTATE)
+ return getParam2() % 240;
+ if (f.param_type_2 == CPT2_COLORED_DEGROTATE)
+ return 10 * ((getParam2() & 0x1F) % 24);
+ return 0;
+}
+
void MapNode::rotateAlongYAxis(const NodeDefManager *nodemgr, Rotation rot)
{
ContentParamType2 cpt2 = nodemgr->get(*this).param_type_2;
@@ -230,6 +240,17 @@ void MapNode::rotateAlongYAxis(const NodeDefManager *nodemgr, Rotation rot)
Rotation oldrot = wallmounted_to_rot[wmountface - 2];
param2 &= ~7;
param2 |= rot_to_wallmounted[(oldrot - rot) & 3];
+ } else if (cpt2 == CPT2_DEGROTATE) {
+ int angle = param2; // in 1.5°
+ angle += 60 * rot; // don’t do that on u8
+ angle %= 240;
+ param2 = angle;
+ } else if (cpt2 == CPT2_COLORED_DEGROTATE) {
+ int angle = param2 & 0x1F; // in 15°
+ int color = param2 & 0xE0;
+ angle += 6 * rot;
+ angle %= 24;
+ param2 = color | angle;
}
}