Fix player sprite visibility in first person

closes #10525
This commit is contained in:
sfan5 2020-11-10 21:36:58 +01:00
parent c441baa91b
commit b504a1aa4b

@ -1919,13 +1919,23 @@ void GenericCAO::updateMeshCulling()
if (!m_is_local_player) if (!m_is_local_player)
return; return;
// Grab the active player scene node so we know there's const bool hidden = m_client->getCamera()->getCameraMode() == CAMERA_MODE_FIRST;
// at least a mesh to occlude from the camera.
if (m_meshnode && m_prop.visual == "upright_sprite") {
u32 buffers = m_meshnode->getMesh()->getMeshBufferCount();
for (u32 i = 0; i < buffers; i++) {
video::SMaterial &mat = m_meshnode->getMesh()->getMeshBuffer(i)->getMaterial();
// upright sprite has no backface culling
mat.setFlag(video::EMF_FRONT_FACE_CULLING, hidden);
}
return;
}
irr::scene::ISceneNode *node = getSceneNode(); irr::scene::ISceneNode *node = getSceneNode();
if (!node) if (!node)
return; return;
if (m_client->getCamera()->getCameraMode() == CAMERA_MODE_FIRST) { if (hidden) {
// Hide the mesh by culling both front and // Hide the mesh by culling both front and
// back faces. Serious hackyness but it works for our // back faces. Serious hackyness but it works for our
// purposes. This also preserves the skeletal armature. // purposes. This also preserves the skeletal armature.