diff options
| author | Wuzzy <Wuzzy@disroot.org> | 2022-09-16 13:18:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-16 13:18:55 +0200 |
| commit | 1d04903c1973591e795d3275b900d76d7cb7877a (patch) | |
| tree | 06891c6fe3075c1868832bc0007308e525cef70f /src/nodedef.cpp | |
| parent | b5e7280708221cdcca89df7d16f2aea19e4b3c4c (diff) | |
| download | minetest-1d04903c1973591e795d3275b900d76d7cb7877a.tar.xz | |
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.
Diffstat (limited to 'src/nodedef.cpp')
| -rw-r--r-- | src/nodedef.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/nodedef.cpp b/src/nodedef.cpp index e2a222ed3..f42231736 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -992,6 +992,7 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc if (param_type_2 == CPT2_COLOR || param_type_2 == CPT2_COLORED_FACEDIR || + param_type_2 == CPT2_COLORED_4DIR || param_type_2 == CPT2_COLORED_WALLMOUNTED || param_type_2 == CPT2_COLORED_DEGROTATE) palette = tsrc->getPalette(palette_name); @@ -1018,6 +1019,15 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc recalculateBoundingBox(mesh_ptr[j]); meshmanip->recalculateNormals(mesh_ptr[j], true, false); } + } else if (tsettings.enable_mesh_cache && mesh_ptr[0] && + (param_type_2 == CPT2_4DIR + || param_type_2 == CPT2_COLORED_4DIR)) { + for (u16 j = 1; j < 4; j++) { + mesh_ptr[j] = cloneMesh(mesh_ptr[0]); + rotateMeshBy6dFacedir(mesh_ptr[j], j); + recalculateBoundingBox(mesh_ptr[j]); + meshmanip->recalculateNormals(mesh_ptr[j], true, false); + } } else if (tsettings.enable_mesh_cache && mesh_ptr[0] && (param_type_2 == CPT2_WALLMOUNTED || param_type_2 == CPT2_COLORED_WALLMOUNTED)) { @@ -1241,7 +1251,9 @@ void getNodeBoxUnion(const NodeBox &nodebox, const ContentFeatures &features, half_processed.MaxEdge.Y = +BS / 2; } if (features.param_type_2 == CPT2_FACEDIR || - features.param_type_2 == CPT2_COLORED_FACEDIR) { + features.param_type_2 == CPT2_COLORED_FACEDIR || + features.param_type_2 == CPT2_4DIR || + features.param_type_2 == CPT2_COLORED_4DIR) { // Get maximal coordinate f32 coords[] = { fabsf(half_processed.MinEdge.X), @@ -1705,7 +1717,9 @@ bool NodeDefManager::nodeboxConnects(MapNode from, MapNode to, // does to node declare usable faces? if (f2.connect_sides > 0) { if ((f2.param_type_2 == CPT2_FACEDIR || - f2.param_type_2 == CPT2_COLORED_FACEDIR) + f2.param_type_2 == CPT2_COLORED_FACEDIR || + f2.param_type_2 == CPT2_4DIR || + f2.param_type_2 == CPT2_COLORED_4DIR) && (connect_face >= 4)) { static const u8 rot[33 * 4] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 16, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1719,8 +1733,15 @@ bool NodeDefManager::nodeboxConnects(MapNode from, MapNode to, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 16, 8, 4 // 32 - left }; - return (f2.connect_sides - & rot[(connect_face * 4) + (to.param2 & 0x1F)]); + if (f2.param_type_2 == CPT2_FACEDIR || + f2.param_type_2 == CPT2_COLORED_FACEDIR) { + return (f2.connect_sides + & rot[(connect_face * 4) + (to.param2 & 0x1F)]); + } else if (f2.param_type_2 == CPT2_4DIR || + f2.param_type_2 == CPT2_COLORED_4DIR) { + return (f2.connect_sides + & rot[(connect_face * 4) + (to.param2 & 0x03)]); + } } return (f2.connect_sides & connect_face); } |
