From: BlockMen Date: Mon, 28 Sep 2015 18:49:38 +0000 (+0200) Subject: Add option to disable backface culling for models X-Git-Tag: 0.4.14~571 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=50ba7e114d0937061f988c9452904dd2456399b5;p=oweals%2Fminetest.git Add option to disable backface culling for models - Disabled by default (except players) - Fixes #2984 --- diff --git a/doc/lua_api.txt b/doc/lua_api.txt index e9d19ad27..5ad88b121 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -3045,6 +3045,7 @@ Definition tables stepheight = 0, automatic_face_movement_dir = 0.0, -- ^ automatically set yaw to movement direction; offset in degrees; false to disable + backface_culling = true, -- false to disable backface_culling for model } ### Entity definition (`register_entity`) diff --git a/src/content_cao.cpp b/src/content_cao.cpp index e864063a4..72f6145b0 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -934,10 +934,15 @@ void GenericCAO::addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc, u8 li = m_last_light; setMeshColor(m_animated_meshnode->getMesh(), video::SColor(255,li,li,li)); + bool backface_culling = m_prop.backface_culling; + if (m_is_player) + backface_culling = false; + m_animated_meshnode->setMaterialFlag(video::EMF_LIGHTING, false); m_animated_meshnode->setMaterialFlag(video::EMF_BILINEAR_FILTER, false); m_animated_meshnode->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF); m_animated_meshnode->setMaterialFlag(video::EMF_FOG_ENABLE, true); + m_animated_meshnode->setMaterialFlag(video::EMF_BACK_FACE_CULLING, backface_culling); } else errorstream<<"GenericCAO::addToScene(): Could not load mesh "<automatic_face_movement_dir_offset = 0.0; } lua_pop(L, 1); + getboolfield(L, -1, "backface_culling", prop->backface_culling); } /******************************************************************************/ @@ -255,6 +256,8 @@ void push_object_properties(lua_State *L, ObjectProperties *prop) else lua_pushboolean(L, false); lua_setfield(L, -2, "automatic_face_movement_dir"); + lua_pushboolean(L, prop->backface_culling); + lua_setfield(L, -2, "backface_culling"); } /******************************************************************************/ @@ -1231,4 +1234,3 @@ void read_json_value(lua_State *L, Json::Value &root, int index, u8 recursion) } lua_pop(L, 1); // Pop value } -