Added caching of textures for overworld.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@11813 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d9fd492d50
commit
9b74d0cdd0
@ -299,6 +299,15 @@ Material *MaterialManager::getMaterial(const std::string& fname,
|
||||
} // getMaterial
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Makes all materials permanent. Used for overworld.
|
||||
*/
|
||||
void MaterialManager::makeMaterialsPermanent()
|
||||
{
|
||||
m_shared_material_index = m_materials.size();
|
||||
} // makeMaterialsPermanent
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
bool MaterialManager::hasMaterial(const std::string& fname)
|
||||
{
|
||||
std::string basename=StringUtils::getBasename(fname);
|
||||
|
@ -70,11 +70,11 @@ public:
|
||||
bool pushTempMaterial (const std::string& filename);
|
||||
bool pushTempMaterial (const XMLNode *root, const std::string& filename);
|
||||
void popTempMaterial ();
|
||||
|
||||
void makeMaterialsPermanent();
|
||||
bool hasMaterial(const std::string& fname);
|
||||
|
||||
Material* getLatestMaterial() { return m_materials[m_materials.size()-1]; }
|
||||
};
|
||||
}; // MaterialManager
|
||||
|
||||
extern MaterialManager *material_manager;
|
||||
|
||||
|
@ -78,6 +78,7 @@ Track::Track(const std::string &filename)
|
||||
m_magic_number = 0x17AC3802;
|
||||
#endif
|
||||
|
||||
m_materials_loaded = false;
|
||||
m_filename = filename;
|
||||
m_root = StringUtils::getPath(StringUtils::removeExtension(m_filename));
|
||||
m_ident = StringUtils::getBasename(m_root);
|
||||
@ -215,8 +216,13 @@ void Track::cleanup()
|
||||
}
|
||||
m_sky_textures.clear();
|
||||
|
||||
// remove temporary materials loaded by the material manager
|
||||
material_manager->popTempMaterial();
|
||||
if(m_ident!="overworld")
|
||||
{
|
||||
// remove temporary materials loaded by the material manager
|
||||
material_manager->popTempMaterial();
|
||||
}
|
||||
else
|
||||
material_manager->makeMaterialsPermanent();
|
||||
|
||||
if(UserConfigParams::logMemory())
|
||||
{
|
||||
@ -661,7 +667,6 @@ void Track::convertTrackToBullet(scene::ISceneNode *node)
|
||||
} // convertTrackToBullet
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/** Loads the main track model (i.e. all other objects contained in the
|
||||
* scene might use raycast on this track model to determine the actual
|
||||
* height of the terrain.
|
||||
@ -1221,7 +1226,14 @@ void Track::loadTrackModel(World* parent, bool reverse_track,
|
||||
try
|
||||
{
|
||||
std::string materials_file = m_root+"/materials.xml";
|
||||
material_manager->pushTempMaterial(materials_file);
|
||||
if(m_ident=="overworld")
|
||||
{
|
||||
if(!m_materials_loaded)
|
||||
material_manager->addSharedMaterial(materials_file);
|
||||
m_materials_loaded = true;
|
||||
}
|
||||
else
|
||||
material_manager->pushTempMaterial(materials_file);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ private:
|
||||
std::string m_screenshot;
|
||||
std::vector<MusicInformation*> m_music;
|
||||
|
||||
/** Will only be sued on overworld */
|
||||
/** Will only be used on overworld */
|
||||
std::vector<OverworldChallenge> m_challenges;
|
||||
|
||||
std::vector<OverworldForceField> m_force_fields;
|
||||
@ -189,6 +189,10 @@ private:
|
||||
* be removed from the cache at cleanup time. */
|
||||
std::vector<video::ITexture*> m_all_cached_textures;
|
||||
|
||||
/** True if the materials.xml file is already loaded. This is used
|
||||
* for the overworld to keep its textures loaded. */
|
||||
bool m_materials_loaded;
|
||||
|
||||
#ifdef DEBUG
|
||||
/** A list of textures that were cached before the track is loaded.
|
||||
* After cleanup of ta track it can be tested which new textures
|
||||
|
Loading…
Reference in New Issue
Block a user