From 69896fdc6aefb62be5e1d5e37e4f8ee313ea91e3 Mon Sep 17 00:00:00 2001 From: vlj Date: Sun, 28 Sep 2014 02:51:13 +0200 Subject: [PATCH] Fix material detection --- src/graphics/material.cpp | 2 -- src/graphics/stkanimatedmesh.cpp | 2 +- src/graphics/stkmesh.cpp | 25 ++++++++----------------- src/graphics/stkmesh.hpp | 1 + src/graphics/stkmeshscenenode.cpp | 2 +- 5 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index 878cb1d75..d633a8a3c 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -784,7 +784,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m // Material and shaders m->MaterialType = irr_driver->getShader(ES_NORMAL_MAP); m->setTexture(1, glossytex); - m_shader_type = SHADERTYPE_NORMAL_MAP; return; } @@ -796,7 +795,6 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m m->setTexture(2, m->getTexture(1)); if (!m->getTexture(2)) m->setTexture(2, getUnicolorTexture(SColor(255, 255, 255, 255))); - m_shader_type = SHADERTYPE_DETAIL_MAP; } m->setTexture(1, glossytex); } diff --git a/src/graphics/stkanimatedmesh.cpp b/src/graphics/stkanimatedmesh.cpp index 5b52251ef..02f251cd1 100644 --- a/src/graphics/stkanimatedmesh.cpp +++ b/src/graphics/stkanimatedmesh.cpp @@ -142,7 +142,7 @@ void STKAnimatedMesh::updateGL() if (!rnd->isTransparent()) { Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); - Material::ShaderType MatType = material->getShaderType();// MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); InitTextures(mesh, MatType); } diff --git a/src/graphics/stkmesh.cpp b/src/graphics/stkmesh.cpp index 46ba030c1..f54695326 100644 --- a/src/graphics/stkmesh.cpp +++ b/src/graphics/stkmesh.cpp @@ -10,30 +10,21 @@ #include "graphics/camera.hpp" #include "modes/world.hpp" -/* -MeshMaterial MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, Material* material) + +Material::ShaderType MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, Material* material) { switch (material->getShaderType()) { - case Material::SHADERTYPE_SPHERE_MAP: - return MAT_SPHEREMAP; - case Material::SHADERTYPE_ALPHA_TEST: - return MAT_ALPHA_REF; - case Material::SHADERTYPE_VEGETATION: - return MAT_GRASS; - case Material::SHADERTYPE_SPLATTING: - return MAT_SPLATTING; - case Material::SHADERTYPE_SOLID_UNLIT: - return MAT_UNLIT; default: + return material->getShaderType(); + case Material::SHADERTYPE_SOLID: if (MaterialType == irr_driver->getShader(ES_NORMAL_MAP)) - return MAT_NORMAL_MAP; + return Material::SHADERTYPE_NORMAL_MAP; else if (tp == video::EVT_2TCOORDS) - return MAT_DETAIL; - return MAT_DEFAULT; + return Material::SHADERTYPE_DETAIL_MAP; + return Material::SHADERTYPE_SOLID; } } -*/ TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE type, f32 MaterialTypeParam, Material* material) { @@ -287,7 +278,7 @@ SetTexture(GLMesh &mesh, unsigned i, bool isSrgb) { if (!mesh.textures[i]) { - Log::warn("STKMesh", "Missing texture"); + Log::fatal("STKMesh", "Missing texture"); return; } compressTexture(mesh.textures[i], isSrgb); diff --git a/src/graphics/stkmesh.hpp b/src/graphics/stkmesh.hpp index 346ffe9fb..574036b88 100644 --- a/src/graphics/stkmesh.hpp +++ b/src/graphics/stkmesh.hpp @@ -174,6 +174,7 @@ class ListDisplacement : public MiscList, public std::vector {}; +Material::ShaderType MaterialTypeToMeshMaterial(video::E_MATERIAL_TYPE MaterialType, video::E_VERTEX_TYPE tp, Material* material); TransparentMaterial MaterialTypeToTransparentMaterial(video::E_MATERIAL_TYPE, f32 MaterialTypeParam, Material* material); void InitTextures(GLMesh &mesh, Material::ShaderType); diff --git a/src/graphics/stkmeshscenenode.cpp b/src/graphics/stkmeshscenenode.cpp index 1e7d5da19..0786bbc13 100644 --- a/src/graphics/stkmeshscenenode.cpp +++ b/src/graphics/stkmeshscenenode.cpp @@ -143,7 +143,7 @@ void STKMeshSceneNode::updateNoGL() else { assert(!isDisplacement); - Material::ShaderType MatType = material->getShaderType();// MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); + Material::ShaderType MatType = MaterialTypeToMeshMaterial(type, mb->getVertexType(), material); if (!immediate_draw) MeshSolidMaterial[MatType].push_back(&mesh); }