Only set material flag on rendered meshes (#5023)

master
lhofhansl 2017-01-14 13:30:14 -08:00 committed by Loïc Blot
parent f0c6feca97
commit c41352a1c7
1 changed files with 9 additions and 8 deletions

View File

@ -371,10 +371,10 @@ struct MeshBufListList
void add(scene::IMeshBuffer *buf) void add(scene::IMeshBuffer *buf)
{ {
const video::SMaterial &m = buf->getMaterial();
for(std::vector<MeshBufList>::iterator i = lists.begin(); for(std::vector<MeshBufList>::iterator i = lists.begin();
i != lists.end(); ++i){ i != lists.end(); ++i){
MeshBufList &l = *i; MeshBufList &l = *i;
video::SMaterial &m = buf->getMaterial();
// comparing a full material is quite expensive so we don't do it if // comparing a full material is quite expensive so we don't do it if
// not even first texture is equal // not even first texture is equal
@ -387,7 +387,7 @@ struct MeshBufListList
} }
} }
MeshBufList l; MeshBufList l;
l.m = buf->getMaterial(); l.m = m;
l.bufs.push_back(buf); l.bufs.push_back(buf);
lists.push_back(l); lists.push_back(l);
} }
@ -508,12 +508,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
{ {
scene::IMeshBuffer *buf = mesh->getMeshBuffer(i); scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter); video::SMaterial& material = buf->getMaterial();
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
buf->getMaterial().setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
const video::SMaterial& material = buf->getMaterial();
video::IMaterialRenderer* rnd = video::IMaterialRenderer* rnd =
driver->getMaterialRenderer(material.MaterialType); driver->getMaterialRenderer(material.MaterialType);
bool transparent = (rnd && rnd->isTransparent()); bool transparent = (rnd && rnd->isTransparent());
@ -521,6 +516,12 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
if (buf->getVertexCount() == 0) if (buf->getVertexCount() == 0)
errorstream << "Block [" << analyze_block(block) errorstream << "Block [" << analyze_block(block)
<< "] contains an empty meshbuf" << std::endl; << "] contains an empty meshbuf" << std::endl;
material.setFlag(video::EMF_TRILINEAR_FILTER, m_cache_trilinear_filter);
material.setFlag(video::EMF_BILINEAR_FILTER, m_cache_bilinear_filter);
material.setFlag(video::EMF_ANISOTROPIC_FILTER, m_cache_anistropic_filter);
material.setFlag(video::EMF_WIREFRAME, m_control.show_wireframe);
drawbufs.add(buf); drawbufs.add(buf);
} }
} }