Materials optimisation : minor tweaks and cleanup

This commit is contained in:
auria.mg 2016-12-28 20:13:55 -05:00
parent 1597c2ad48
commit 33802d9f81
2 changed files with 12 additions and 21 deletions

View File

@ -75,7 +75,6 @@ Material::Material(const XMLNode *node, bool deprecated)
m_full_path = file_manager->getFileSystem()->getAbsolutePath(relativePath.c_str()).c_str(); m_full_path = file_manager->getFileSystem()->getAbsolutePath(relativePath.c_str()).c_str();
init(); init();
node->get("dont-load", &m_dont_load_texture);
bool b = false; bool b = false;
node->get("clampu", &b); if (b) m_clamp_tex |= UCLAMP; //blender 2.4 style node->get("clampu", &b); if (b) m_clamp_tex |= UCLAMP; //blender 2.4 style
@ -403,13 +402,9 @@ Material::Material(const XMLNode *node, bool deprecated)
video::ITexture* Material::getTexture() video::ITexture* Material::getTexture()
{ {
// Note that dont load means that the textures are not loaded
// via the material. So getTexture should only get called for
// automatically loaded textures (used atm for font textures).
assert(!m_dont_load_texture);
if (!m_installed) if (!m_installed)
{ {
install(/*is_full_path*/true, true); install(/*is_full_path*/true);
} }
return m_texture; return m_texture;
} // getTexture } // getTexture
@ -429,8 +424,10 @@ Material::Material(const std::string& fname, bool is_full_path,
m_full_path = file_manager->getFileSystem()->getAbsolutePath( m_full_path = file_manager->getFileSystem()->getAbsolutePath(
file_manager->searchTexture(m_texname).c_str()).c_str(); file_manager->searchTexture(m_texname).c_str()).c_str();
m_complain_if_not_found = complain_if_not_found;
if (load_texture) if (load_texture)
install(is_full_path, complain_if_not_found); install(is_full_path);
} // Material } // Material
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -438,7 +435,6 @@ Material::Material(const std::string& fname, bool is_full_path,
*/ */
void Material::init() void Material::init()
{ {
m_dont_load_texture = false;
m_texture = NULL; m_texture = NULL;
m_clamp_tex = 0; m_clamp_tex = 0;
m_shader_type = SHADERTYPE_SOLID; m_shader_type = SHADERTYPE_SOLID;
@ -476,7 +472,7 @@ void Material::init()
m_water_splash = false; m_water_splash = false;
m_is_jump_texture = false; m_is_jump_texture = false;
m_has_gravity = false; m_has_gravity = false;
m_complain_if_not_found = true;
for (int n=0; n<EMIT_KINDS_COUNT; n++) for (int n=0; n<EMIT_KINDS_COUNT; n++)
{ {
m_particles_effects[n] = NULL; m_particles_effects[n] = NULL;
@ -484,10 +480,9 @@ void Material::init()
} // init } // init
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void Material::install(bool is_full_path, bool complain_if_not_found) void Material::install(bool is_full_path)
{ {
// Don't load a texture that are not supposed to be loaded automatically // Don't load a texture that are not supposed to be loaded automatically
if (m_dont_load_texture) return;
if (m_installed) return; if (m_installed) return;
m_installed = true; m_installed = true;
@ -496,7 +491,7 @@ void Material::install(bool is_full_path, bool complain_if_not_found)
? m_texname ? m_texname
: file_manager->searchTexture(m_texname); : file_manager->searchTexture(m_texname);
if (complain_if_not_found && full_path.size() == 0) if (m_complain_if_not_found && full_path.size() == 0)
{ {
Log::error("material", "Cannot find texture '%s'.", m_texname.c_str()); Log::error("material", "Cannot find texture '%s'.", m_texname.c_str());
m_texture = NULL; m_texture = NULL;
@ -507,7 +502,7 @@ void Material::install(bool is_full_path, bool complain_if_not_found)
m_texture = irr_driver->getTexture(full_path, m_texture = irr_driver->getTexture(full_path,
false, //isPreMul(), false, //isPreMul(),
false, //isPreDiv(), false, //isPreDiv(),
complain_if_not_found); m_complain_if_not_found);
} }
if (m_texture == NULL) return; if (m_texture == NULL) return;
@ -727,7 +722,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
{ {
if (!m_installed) if (!m_installed)
{ {
install(/*is_full_path*/true, true); install(/*is_full_path*/true);
} }
if (m_deprecated || if (m_deprecated ||

View File

@ -92,12 +92,6 @@ private:
std::string m_full_path; std::string m_full_path;
/** If true, the texture will not automatically be loaded and bound
* at load time, it must be loaded elsewhere. This is used to store
* material settings for font textures, without loading fonts for
* languages that might not be needed at all. */
bool m_dont_load_texture;
/** Name of a special sfx to play when a kart is on this terrain, or /** Name of a special sfx to play when a kart is on this terrain, or
* "" if no special sfx exists. */ * "" if no special sfx exists. */
std::string m_sfx_name; std::string m_sfx_name;
@ -266,12 +260,14 @@ private:
std::string m_gloss_map; std::string m_gloss_map;
bool m_complain_if_not_found;
bool m_deprecated; bool m_deprecated;
bool m_installed; bool m_installed;
void init (); void init ();
void install (bool is_full_path=false, bool complain_if_not_found=true); void install (bool is_full_path=false);
void initCustomSFX(const XMLNode *sfx); void initCustomSFX(const XMLNode *sfx);
void initParticlesEffect(const XMLNode *node); void initParticlesEffect(const XMLNode *node);