mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02: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:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user