mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Decoration: Handle facedir and wallmounted param2types with schematic rotation
This commit is contained in:
parent
c813a3cc53
commit
ce955f37ba
4 changed files with 50 additions and 12 deletions
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue