summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAuke Kok <sofar+github@foo-projects.org>2017-04-28 11:11:43 -0700
committerSmallJoker <SmallJoker@users.noreply.github.com>2017-04-28 20:11:43 +0200
commite21a1ab3bd31f9b854ef77c33698624755fc915c (patch)
tree3795e0ecbfac9d1615f7de04d29151b4d17e0ae3
parentc761717f11837828bfb57998273695419a28e6eb (diff)
downloadminetest-e21a1ab3bd31f9b854ef77c33698624755fc915c.tar.gz
minetest-e21a1ab3bd31f9b854ef77c33698624755fc915c.tar.bz2
minetest-e21a1ab3bd31f9b854ef77c33698624755fc915c.zip
Allow mesh and nodeboxes to wave like plants or leaves. (#3497)
We introduce a new value for "waving" - 2: 0 - waving disabled 1 - wave like a plant 2 - wave like a leave Plantlike nodes will only allow waving = 1, but for leaves we will permit both 1 and 2 since current minetest_game sets it to 1 for all leaves. This makes it somewhat backwards compatible. For mesh and nodebox, values 1 and 2 are both valid, and the node can wave in both fashions as desired. I've tested this with the crops:corn plants, which are mesh nodes, and the results are really good. The code change is trivial as well, so I've opted to document the waving parameter in lua_api.txt because it was missing from there. Nodeboxes likely will not wave properly unless waving = 2. However it's possible that waving=1 may be desired by some mod developers for geometries I have not tried, so the code will not prohibit either value for mesh and nodebox drawtypes. Add lua_api.txt documentation for this feature and document both the existing functionality and the expansion to mesh and nodebox drawtypes.
-rw-r--r--doc/lua_api.txt6
-rw-r--r--src/nodedef.cpp10
2 files changed, 13 insertions, 3 deletions
diff --git a/doc/lua_api.txt b/doc/lua_api.txt
index b47046cb1..603619ab0 100644
--- a/doc/lua_api.txt
+++ b/doc/lua_api.txt
@@ -3973,6 +3973,12 @@ Definition tables
^ If drawtype "nodebox" is used and selection_box is nil, then node_box is used. ]]
legacy_facedir_simple = false, -- Support maps made in and before January 2012
legacy_wallmounted = false, -- Support maps made in and before January 2012
+ waving = 0, --[[ valid for mesh, nodebox, plantlike, allfaces_optional nodes
+ ^ 1 - wave node like plants (top of node moves, bottom is fixed)
+ ^ 2 - wave node like leaves (whole node moves side-to-side synchronously)
+ ^ caveats: not all models will properly wave
+ ^ plantlike drawtype nodes can only wave like plants
+ ^ allfaces_optional drawtype nodes can only wave like leaves --]]
sounds = {
footstep = <SimpleSoundSpec>,
dig = <SimpleSoundSpec>, -- "__group" = group-based sound (default)
diff --git a/src/nodedef.cpp b/src/nodedef.cpp
index ce2834c91..1bc483077 100644
--- a/src/nodedef.cpp
+++ b/src/nodedef.cpp
@@ -733,25 +733,29 @@ void ContentFeatures::updateTextures(ITextureSource *tsrc, IShaderSource *shdsrc
for (u32 i = 0; i < 6; i++)
tdef[i].name += std::string("^[noalpha");
}
- if (waving == 1)
+ if (waving >= 1)
material_type = TILE_MATERIAL_WAVING_LEAVES;
break;
case NDT_PLANTLIKE:
solidness = 0;
- if (waving == 1)
+ if (waving >= 1)
material_type = TILE_MATERIAL_WAVING_PLANTS;
break;
case NDT_FIRELIKE:
solidness = 0;
break;
case NDT_MESH:
+ case NDT_NODEBOX:
solidness = 0;
+ if (waving == 1)
+ material_type = TILE_MATERIAL_WAVING_PLANTS;
+ else if (waving == 2)
+ material_type = TILE_MATERIAL_WAVING_LEAVES;
break;
case NDT_TORCHLIKE:
case NDT_SIGNLIKE:
case NDT_FENCELIKE:
case NDT_RAILLIKE:
- case NDT_NODEBOX:
solidness = 0;
break;
}