diff options
author | Auke Kok <sofar@foo-projects.org> | 2016-01-18 20:44:46 -0800 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2016-01-20 00:36:48 +0000 |
commit | 882a89d65aa78b89cfaf2af054d15cc4c94ad022 (patch) | |
tree | 3cdb76c54ef6b9964bc35b7f1490bf333ca42126 /src/script/common | |
parent | 9f988e3b962389e10a7cf010fd4bf0f81d70e31a (diff) | |
download | minetest-882a89d65aa78b89cfaf2af054d15cc4c94ad022.tar.gz minetest-882a89d65aa78b89cfaf2af054d15cc4c94ad022.tar.bz2 minetest-882a89d65aa78b89cfaf2af054d15cc4c94ad022.zip |
Allow per-tiles culling.
Backface culling is enabled by default for all tiles, as this
is how the lua parser initializes each tiledef. We revert to
always using the value from the tiledef since it is always
read and serialized.
Mods that wish to enable culling for e.g. mesh nodes, now can
specify the following to enable backface culling:
tiles = {{ name = "tex.png", backface_culling = true }},
Note the double '{' and use of 'name' key here! In the same
fashion, backface_culling can be disabled for any node now.
I've tested this against the new door models and this properly
allows me to disable culling per node. I've also tested this
against my crops mod which uses mesh nodes where culling needs
to be disabled, and tested also with plantlike drawtype nodes
where we want this to continue to be disabled.
No default setting has changed. The defaults are just migrated
from nodedef.cpp to c_content.cpp.
Diffstat (limited to 'src/script/common')
-rw-r--r-- | src/script/common/c_content.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 275b22bb8..96fb78d99 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -294,14 +294,31 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype) index = lua_gettop(L) + 1 + index; TileDef tiledef; - bool default_tiling = (drawtype == NDT_PLANTLIKE || drawtype == NDT_FIRELIKE) - ? false : true; + + bool default_tiling = true; + bool default_culling = true; + switch (drawtype) { + case NDT_PLANTLIKE: + case NDT_FIRELIKE: + default_tiling = false; + // "break" is omitted here intentionaly, as PLANTLIKE + // FIRELIKE drawtype both should default to having + // backface_culling to false. + case NDT_MESH: + case NDT_LIQUID: + default_culling = false; + break; + default: + break; + } + // key at index -2 and value at index if(lua_isstring(L, index)){ // "default_lava.png" tiledef.name = lua_tostring(L, index); tiledef.tileable_vertical = default_tiling; tiledef.tileable_horizontal = default_tiling; + tiledef.backface_culling = default_culling; } else if(lua_istable(L, index)) { @@ -310,7 +327,7 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype) getstringfield(L, index, "name", tiledef.name); getstringfield(L, index, "image", tiledef.name); // MaterialSpec compat. tiledef.backface_culling = getboolfield_default( - L, index, "backface_culling", true); + L, index, "backface_culling", default_culling); tiledef.tileable_horizontal = getboolfield_default( L, index, "tileable_horizontal", default_tiling); tiledef.tileable_vertical = getboolfield_default( |