mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add paramtype2s for 4 horizontal rotations and 64 colors (#11431)
4dir is like facedir, but only for 4 horizontal directions: NESW. It is identical in behavior to facedir otherwise. The reason why game makers would want to use this over facedir is 1) simplicity and 2) you get 6 free bits. It can be used for things like chests and furnaces and you don't need or want them to "flip them on the side" (like you could with facedir). color4dir is like colorfacedir, but you get 64 colors instead of only 8.
This commit is contained in:
parent
b5e7280708
commit
1d04903c19
15 changed files with 299 additions and 28 deletions
|
@ -149,6 +149,9 @@ u8 MapNode::getFaceDir(const NodeDefManager *nodemgr,
|
|||
if (f.param_type_2 == CPT2_FACEDIR ||
|
||||
f.param_type_2 == CPT2_COLORED_FACEDIR)
|
||||
return (getParam2() & 0x1F) % 24;
|
||||
if (f.param_type_2 == CPT2_4DIR ||
|
||||
f.param_type_2 == CPT2_COLORED_4DIR)
|
||||
return getParam2() & 0x03;
|
||||
if (allow_wallmounted && (f.param_type_2 == CPT2_WALLMOUNTED ||
|
||||
f.param_type_2 == CPT2_COLORED_WALLMOUNTED))
|
||||
return wallmounted_to_facedir[getParam2() & 0x07];
|
||||
|
@ -196,7 +199,8 @@ void MapNode::rotateAlongYAxis(const NodeDefManager *nodemgr, Rotation rot)
|
|||
{
|
||||
ContentParamType2 cpt2 = nodemgr->get(*this).param_type_2;
|
||||
|
||||
if (cpt2 == CPT2_FACEDIR || cpt2 == CPT2_COLORED_FACEDIR) {
|
||||
if (cpt2 == CPT2_FACEDIR || cpt2 == CPT2_COLORED_FACEDIR ||
|
||||
cpt2 == CPT2_4DIR || cpt2 == CPT2_COLORED_4DIR) {
|
||||
static const u8 rotate_facedir[24 * 4] = {
|
||||
// Table value = rotated facedir
|
||||
// Columns: 0, 90, 180, 270 degrees rotation around vertical axis
|
||||
|
@ -232,10 +236,17 @@ void MapNode::rotateAlongYAxis(const NodeDefManager *nodemgr, Rotation rot)
|
|||
22, 21, 20, 23,
|
||||
23, 22, 21, 20
|
||||
};
|
||||
u8 facedir = (param2 & 31) % 24;
|
||||
u8 index = facedir * 4 + rot;
|
||||
param2 &= ~31;
|
||||
param2 |= rotate_facedir[index];
|
||||
if (cpt2 == CPT2_FACEDIR || cpt2 == CPT2_COLORED_FACEDIR) {
|
||||
u8 facedir = (param2 & 31) % 24;
|
||||
u8 index = facedir * 4 + rot;
|
||||
param2 &= ~31;
|
||||
param2 |= rotate_facedir[index];
|
||||
} else if (cpt2 == CPT2_4DIR || cpt2 == CPT2_COLORED_4DIR) {
|
||||
u8 fourdir = param2 & 3;
|
||||
u8 index = fourdir + rot;
|
||||
param2 &= ~3;
|
||||
param2 |= rotate_facedir[index];
|
||||
}
|
||||
} else if (cpt2 == CPT2_WALLMOUNTED ||
|
||||
cpt2 == CPT2_COLORED_WALLMOUNTED) {
|
||||
u8 wmountface = (param2 & 7);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue