aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2020-05-24 11:48:51 +0200
committerGitHub <noreply@github.com>2020-05-24 11:48:51 +0200
commitf51cf7c68af16d0068b91d00ab2cc9abdf2b31d0 (patch)
tree356e84eea5c16320e7fedc1a475ac94be2fc6b5c
parent5430770b6851a18417f6b2629c9167a5aa38baa5 (diff)
downloadminetest-f51cf7c68af16d0068b91d00ab2cc9abdf2b31d0.tar.gz
minetest-f51cf7c68af16d0068b91d00ab2cc9abdf2b31d0.tar.bz2
minetest-f51cf7c68af16d0068b91d00ab2cc9abdf2b31d0.zip
Fix two bugs in content_cao
fixes #9889 (backface_culling with visual = "cube") fixes #9916 (crash with visual = "upright_sprite")
-rw-r--r--src/client/content_cao.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp
index 867bbf2c8..cdc12f041 100644
--- a/src/client/content_cao.cpp
+++ b/src/client/content_cao.cpp
@@ -713,6 +713,8 @@ void GenericCAO::addToScene(ITextureSource *tsrc)
mesh->drop();
m_meshnode->setScale(m_prop.visual_size);
+ m_meshnode->setMaterialFlag(video::EMF_BACK_FACE_CULLING,
+ m_prop.backface_culling);
setSceneNodeMaterial(m_meshnode);
} else if (m_prop.visual == "mesh") {
@@ -832,19 +834,20 @@ void GenericCAO::setNodeLight(u8 light)
}
if (m_enable_shaders) {
- scene::ISceneNode *node = getSceneNode();
-
- if (node == nullptr)
- return;
-
if (m_prop.visual == "upright_sprite") {
+ if (!m_meshnode)
+ return;
+
scene::IMesh *mesh = m_meshnode->getMesh();
for (u32 i = 0; i < mesh->getMeshBufferCount(); ++i) {
scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
- video::SMaterial &material = buf->getMaterial();
- material.EmissiveColor = color;
+ buf->getMaterial().EmissiveColor = color;
}
} else {
+ scene::ISceneNode *node = getSceneNode();
+ if (!node)
+ return;
+
for (u32 i = 0; i < node->getMaterialCount(); ++i) {
video::SMaterial &material = node->getMaterial(i);
material.EmissiveColor = color;