From e346b44ba1c3d4d5eb301faa8ca5bbe7048da91e Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 30 Jan 2012 00:54:13 +0000 Subject: [PATCH] Silence many of the annoying warnings that are printed when loading the overworld git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10757 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/irr_driver.cpp | 8 ++++---- src/graphics/irr_driver.hpp | 3 ++- src/graphics/material.cpp | 14 +++++++++----- src/graphics/material.hpp | 5 +++-- src/graphics/material_manager.cpp | 5 +++-- src/graphics/material_manager.hpp | 6 ++++-- src/tracks/track.cpp | 7 ++++++- 7 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index db53ddf77..cf3dd9568 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -860,7 +860,8 @@ void IrrDriver::removeCameraSceneNode(scene::ICameraSceneNode *camera) */ video::ITexture *IrrDriver::getTexture(const std::string &filename, bool is_premul, - bool is_prediv) + bool is_prediv, + bool complain_if_not_found) { video::ITexture* out; if(!is_premul && !is_prediv) @@ -923,13 +924,12 @@ video::ITexture *IrrDriver::getTexture(const std::string &filename, out = m_video_driver->addTexture(filename.c_str(), img, NULL); } // if is_premul or is_prediv -#ifndef NDEBUG - if (out == NULL) + + if (complain_if_not_found && out == NULL) { printf("[IrrDriver] Texture '%s' not found; Put a breakpoint at line %s:%i to debug!\n", filename.c_str(), __FILE__, __LINE__); } -#endif return out; } // getTexture diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 81b7e8f44..5297f1de4 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -144,7 +144,8 @@ public: void setAmbientLight(const video::SColor &light); video::ITexture *getTexture(const std::string &filename, bool is_premul=false, - bool is_prediv=false); + bool is_prediv=false, + bool complain_if_not_found=true); void grabAllTextures(const scene::IMesh *mesh); void dropAllTextures(const scene::IMesh *mesh); scene::IMesh *createQuadMesh(const video::SMaterial *material=NULL, diff --git a/src/graphics/material.cpp b/src/graphics/material.cpp index fd975a4cb..904601734 100644 --- a/src/graphics/material.cpp +++ b/src/graphics/material.cpp @@ -471,11 +471,12 @@ Material::Material(const XMLNode *node, int index) * \param index Unique index in material_manager. * \param is_full_path If the fname contains the full path. */ -Material::Material(const std::string& fname, int index, bool is_full_path) +Material::Material(const std::string& fname, int index, bool is_full_path, + bool complain_if_not_found) { m_texname = fname; init(index); - install(is_full_path); + install(is_full_path, complain_if_not_found); } // Material //----------------------------------------------------------------------------- @@ -537,19 +538,22 @@ void Material::init(unsigned int index) } // init //----------------------------------------------------------------------------- -void Material::install(bool is_full_path) +void Material::install(bool is_full_path, bool complain_if_not_found) { const std::string &full_path = is_full_path ? m_texname : file_manager->getTextureFile(m_texname); - if (full_path.size() == 0) + if (complain_if_not_found && full_path.size() == 0) { fprintf(stderr, "[Material] WARNING, cannot find texture '%s'\n", m_texname.c_str()); } + m_texture = irr_driver->getTexture(full_path, - isPreMul(), isPreDiv()); + isPreMul(), + isPreDiv(), + complain_if_not_found); if (m_texture == NULL) return; diff --git a/src/graphics/material.hpp b/src/graphics/material.hpp index e8900df4a..12d20f0d2 100644 --- a/src/graphics/material.hpp +++ b/src/graphics/material.hpp @@ -210,14 +210,15 @@ private: std::map m_bubble_provider; void init (unsigned int index); - void install (bool is_full_path=false); + void install (bool is_full_path=false, bool complain_if_not_found=true); void initCustomSFX(const XMLNode *sfx); void initParticlesEffect(const XMLNode *node); public: Material(const XMLNode *node, int index); Material(const std::string& fname, int index, - bool is_full_path=false); + bool is_full_path=false, + bool complain_if_not_found=true); ~Material (); void setSFXSpeed(SFXBase *sfx, float speed) const; diff --git a/src/graphics/material_manager.cpp b/src/graphics/material_manager.cpp index a7e99faac..34c9c52e9 100644 --- a/src/graphics/material_manager.cpp +++ b/src/graphics/material_manager.cpp @@ -265,7 +265,8 @@ void MaterialManager::popTempMaterial() */ Material *MaterialManager::getMaterial(const std::string& fname, bool is_full_path, - bool make_permanent) + bool make_permanent, + bool complain_if_not_found) { if(fname=="") { @@ -287,7 +288,7 @@ Material *MaterialManager::getMaterial(const std::string& fname, } // Add the new material - Material* m=new Material(fname, m_materials.size(), is_full_path); + Material* m=new Material(fname, m_materials.size(), is_full_path, complain_if_not_found); m_materials.push_back(m); if(make_permanent) { diff --git a/src/graphics/material_manager.hpp b/src/graphics/material_manager.hpp index 805f40237..75ca9ed5f 100644 --- a/src/graphics/material_manager.hpp +++ b/src/graphics/material_manager.hpp @@ -62,8 +62,10 @@ public: void setAllUntexturedMaterialFlags(scene::IMeshBuffer *mb) const; int addEntity (Material *m); - Material *getMaterial (const std::string& t, bool is_full_path=false, - bool make_permanent=false); + Material *getMaterial (const std::string& t, + bool is_full_path=false, + bool make_permanent=false, + bool complain_if_not_found=true); void addSharedMaterial(const std::string& filename); bool pushTempMaterial (const std::string& filename); bool pushTempMaterial (const XMLNode *root, const std::string& filename); diff --git a/src/tracks/track.cpp b/src/tracks/track.cpp index eb5e7645d..bc54e8452 100644 --- a/src/tracks/track.cpp +++ b/src/tracks/track.cpp @@ -539,7 +539,12 @@ void Track::convertTrackToBullet(scene::ISceneNode *node) if(t) { std::string image = std::string(core::stringc(t->getName()).c_str()); - material=material_manager->getMaterial(StringUtils::getBasename(image)); + + // the third boolean argument is false because at this point we're + // dealing physics, so it's useless to warn about missing textures, + // we'd just get duplicate/useless warnings + material=material_manager->getMaterial(StringUtils::getBasename(image), + false, false, false); // Special gfx meshes will not be stored as a normal physics body, // but converted to a collision body only, so that ray tests // against them can be done.