Skip to content

Commit

Permalink
Fix two bugs in content_cao
Browse files Browse the repository at this point in the history
fixes #9889 (backface_culling with visual = "cube")
fixes #9916 (crash with visual = "upright_sprite")
  • Loading branch information
sfan5 committed May 24, 2020
1 parent 5430770 commit f51cf7c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/client/content_cao.cpp
Expand Up @@ -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") {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f51cf7c

Please sign in to comment.