summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBlockMen <nmuelll@web.de>2015-09-28 20:49:38 +0200
committerBlockMen <nmuelll@web.de>2015-10-25 12:06:08 +0100
commit50ba7e114d0937061f988c9452904dd2456399b5 (patch)
treedab9054e22208e42841c29d3b38f3e1fe8134cda /src
parent6907c3e40a16d491fd0f7b224ba30a58e0777a24 (diff)
downloadminetest-50ba7e114d0937061f988c9452904dd2456399b5.tar.gz
minetest-50ba7e114d0937061f988c9452904dd2456399b5.tar.bz2
minetest-50ba7e114d0937061f988c9452904dd2456399b5.zip
Add option to disable backface culling for models
- Disabled by default (except players) - Fixes #2984
Diffstat (limited to 'src')
-rw-r--r--src/content_cao.cpp5
-rw-r--r--src/object_properties.cpp7
-rw-r--r--src/object_properties.h2
-rw-r--r--src/script/common/c_content.cpp4
4 files changed, 14 insertions, 4 deletions
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 "<<m_prop.mesh<<std::endl;
diff --git a/src/object_properties.cpp b/src/object_properties.cpp
index f560f5934..dc1eddf4e 100644
--- a/src/object_properties.cpp
+++ b/src/object_properties.cpp
@@ -42,7 +42,8 @@ ObjectProperties::ObjectProperties():
automatic_rotate(0),
stepheight(0),
automatic_face_movement_dir(false),
- automatic_face_movement_dir_offset(0.0)
+ automatic_face_movement_dir_offset(0.0),
+ backface_culling(true)
{
textures.push_back("unknown_object.png");
colors.push_back(video::SColor(255,255,255,255));
@@ -74,6 +75,7 @@ std::string ObjectProperties::dump()
os<<", is_visible="<<is_visible;
os<<", makes_footstep_sound="<<makes_footstep_sound;
os<<", automatic_rotate="<<automatic_rotate;
+ os<<", backface_culling="<<backface_culling;
return os.str();
}
@@ -106,6 +108,7 @@ void ObjectProperties::serialize(std::ostream &os) const
writeF1000(os,stepheight);
writeU8(os, automatic_face_movement_dir);
writeF1000(os, automatic_face_movement_dir_offset);
+ writeU8(os, backface_culling);
// Add stuff only at the bottom.
// Never remove anything, because we don't want new versions of this
}
@@ -142,6 +145,7 @@ void ObjectProperties::deSerialize(std::istream &is)
stepheight = readF1000(is);
automatic_face_movement_dir = readU8(is);
automatic_face_movement_dir_offset = readF1000(is);
+ backface_culling = readU8(is);
}catch(SerializationError &e){}
}
else
@@ -149,4 +153,3 @@ void ObjectProperties::deSerialize(std::istream &is)
throw SerializationError("unsupported ObjectProperties version");
}
}
-
diff --git a/src/object_properties.h b/src/object_properties.h
index 4b7f9a5eb..eee3be228 100644
--- a/src/object_properties.h
+++ b/src/object_properties.h
@@ -47,6 +47,7 @@ struct ObjectProperties
f32 stepheight;
bool automatic_face_movement_dir;
f32 automatic_face_movement_dir_offset;
+ bool backface_culling;
ObjectProperties();
@@ -56,4 +57,3 @@ struct ObjectProperties
};
#endif
-
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 00ec85b2f..787541ad0 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -197,6 +197,7 @@ void read_object_properties(lua_State *L, int index,
prop->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
}
-