Added limited lazy-load flag to avoid loading of all font textures
(most of which might not be needed). Fixes #1592.
This commit is contained in:
parent
f63e7d93b8
commit
df62c8921e
@ -1,22 +1,22 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<materials>
|
<materials>
|
||||||
<!-- Fonts -->
|
<!-- Fonts -->
|
||||||
<material name="title_font.png" shader="unlit"/>
|
<material name="title_font.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="title_font_2.png" shader="unlit"/>
|
<material name="title_font_2.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="sigmar0.png" shader="unlit"/>
|
<material name="sigmar0.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="AR_PL_SungtiL_GB0.png" shader="unlit"/>
|
<material name="comix.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="comix.png" shader="unlit"/>
|
<material name="LayneHansom0.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="LayneHansom0.png" shader="unlit"/>
|
<material name="Mplus2p_JP0.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="LayneHansomBigDigits.png" shader="unlit"/>
|
<material name="rasheeq0.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="Mplus2p_JP0.png" shader="unlit"/>
|
<material name="rasheeq3.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="rasheeq0.png" shader="unlit"/>
|
<material name="rasheeq4.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="rasheeq3.png" shader="unlit"/>
|
<material name="wqyMicroHei0.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="rasheeq4.png" shader="unlit"/>
|
<material name="wqyMicroHei1.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="wqyMicroHei0.png" shader="unlit"/>
|
<material name="wqyMicroHei2.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="wqyMicroHei1.png" shader="unlit"/>
|
<material name="wqyMicroHei3.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="wqyMicroHei2.png" shader="unlit"/>
|
<material name="wqyMicroHei4.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="wqyMicroHei3.png" shader="unlit"/>
|
<material name="wqyMicroHei5.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="wqyMicroHei4.png" shader="unlit"/>
|
<material name="AR_PL_SungtiL_GB0.png" shader="unlit" lazy-load="Y"/>
|
||||||
<material name="wqyMicroHei5.png" shader="unlit"/>
|
<material name="LayneHansomBigDigits.png" shader="unlit" lazy-load="Y"/>
|
||||||
|
|
||||||
</materials>
|
</materials>
|
||||||
|
@ -58,7 +58,6 @@ Material::Material(const XMLNode *node, bool deprecated)
|
|||||||
m_deprecated = deprecated;
|
m_deprecated = deprecated;
|
||||||
|
|
||||||
node->get("name", &m_texname);
|
node->get("name", &m_texname);
|
||||||
|
|
||||||
if (m_texname=="")
|
if (m_texname=="")
|
||||||
{
|
{
|
||||||
throw std::runtime_error("[Material] No texture name specified "
|
throw std::runtime_error("[Material] No texture name specified "
|
||||||
@ -66,6 +65,7 @@ Material::Material(const XMLNode *node, bool deprecated)
|
|||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
|
|
||||||
|
node->get("lazy-load", &m_lazy_load);
|
||||||
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
|
||||||
@ -412,10 +412,10 @@ Material::Material(const std::string& fname, bool is_full_path,
|
|||||||
*/
|
*/
|
||||||
void Material::init()
|
void Material::init()
|
||||||
{
|
{
|
||||||
|
m_lazy_load = false;
|
||||||
|
m_texture = NULL;
|
||||||
m_clamp_tex = 0;
|
m_clamp_tex = 0;
|
||||||
m_shader_type = SHADERTYPE_SOLID;
|
m_shader_type = SHADERTYPE_SOLID;
|
||||||
//m_lightmap = false;
|
|
||||||
//m_adjust_image = ADJ_NONE;
|
|
||||||
m_backface_culling = true;
|
m_backface_culling = true;
|
||||||
m_high_tire_adhesion = false;
|
m_high_tire_adhesion = false;
|
||||||
m_below_surface = false;
|
m_below_surface = false;
|
||||||
@ -455,6 +455,9 @@ void Material::init()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Material::install(bool is_full_path, bool complain_if_not_found)
|
void Material::install(bool is_full_path, bool complain_if_not_found)
|
||||||
{
|
{
|
||||||
|
// Don't load a texture that is lazily loaded.
|
||||||
|
if(m_lazy_load) return;
|
||||||
|
|
||||||
const std::string &full_path = is_full_path
|
const std::string &full_path = is_full_path
|
||||||
? m_texname
|
? m_texname
|
||||||
: file_manager->searchTexture(m_texname);
|
: file_manager->searchTexture(m_texname);
|
||||||
|
@ -22,13 +22,11 @@
|
|||||||
|
|
||||||
#include "utils/no_copy.hpp"
|
#include "utils/no_copy.hpp"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <IShaderConstantSetCallBack.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace video { class ITexture; class SMaterial; }
|
namespace video { class ITexture; class SMaterial; }
|
||||||
@ -81,9 +79,18 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/** Pointer to the texture. */
|
||||||
video::ITexture *m_texture;
|
video::ITexture *m_texture;
|
||||||
//unsigned int m_index;
|
|
||||||
|
/** Name of the texture. */
|
||||||
std::string m_texname;
|
std::string m_texname;
|
||||||
|
|
||||||
|
/** 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_lazy_load;
|
||||||
|
|
||||||
/** 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;
|
||||||
@ -114,7 +121,7 @@ private:
|
|||||||
/** If a kart is rescued when driving on this surface. */
|
/** If a kart is rescued when driving on this surface. */
|
||||||
bool m_drive_reset;
|
bool m_drive_reset;
|
||||||
|
|
||||||
/** True if this is a texture that will start the jump animatoin when
|
/** True if this is a texture that will start the jump animation when
|
||||||
* leaving it and being in the air. */
|
* leaving it and being in the air. */
|
||||||
bool m_is_jump_texture;
|
bool m_is_jump_texture;
|
||||||
|
|
||||||
@ -244,27 +251,45 @@ public:
|
|||||||
|
|
||||||
void setSFXSpeed(SFXBase *sfx, float speed, bool should_be_paused) const;
|
void setSFXSpeed(SFXBase *sfx, float speed, bool should_be_paused) const;
|
||||||
void setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* mb);
|
void setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* mb);
|
||||||
void adjustForFog(scene::ISceneNode* parent, video::SMaterial *m, bool use_fog) const;
|
void adjustForFog(scene::ISceneNode* parent, video::SMaterial *m,
|
||||||
|
bool use_fog) const;
|
||||||
|
void onMadeVisible(scene::IMeshBuffer* who);
|
||||||
|
void onHidden(scene::IMeshBuffer* who);
|
||||||
|
void isInitiallyHidden(scene::IMeshBuffer* who);
|
||||||
|
|
||||||
/** Returns the ITexture associated with this material. */
|
/** Returns the ITexture associated with this material. */
|
||||||
video::ITexture *getTexture() const { return m_texture; }
|
video::ITexture *getTexture() const
|
||||||
|
{
|
||||||
|
// Note that atm lazy load means that the textures are not loaded
|
||||||
|
// via the material. So getTexture should only get called for non
|
||||||
|
// lazily loaded textures (used atm for font textures.
|
||||||
|
assert(!m_lazy_load);
|
||||||
|
return m_texture;
|
||||||
|
} // getTexture
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
bool isIgnore () const { return m_ignore; }
|
bool isIgnore () const { return m_ignore; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
/** Returns true if this material is a zipper. */
|
/** Returns true if this material is a zipper. */
|
||||||
bool isZipper () const { return m_zipper; }
|
bool isZipper () const { return m_zipper; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
/** Returns if this material should trigger a rescue if a kart
|
/** Returns if this material should trigger a rescue if a kart
|
||||||
* is driving on it. */
|
* is driving on it. */
|
||||||
bool isDriveReset () const { return m_drive_reset; }
|
bool isDriveReset () const { return m_drive_reset; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
/** Returns if this material should trigger a rescue if a kart
|
/** Returns if this material should trigger a rescue if a kart
|
||||||
* crashes against it. */
|
* crashes against it. */
|
||||||
CollisionReaction getCollisionReaction() const { return m_collision_reaction; }
|
CollisionReaction getCollisionReaction() const { return m_collision_reaction; }
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
std::string getCrashResetParticles() const { return m_collision_particles; }
|
std::string getCrashResetParticles() const { return m_collision_particles; }
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
bool highTireAdhesion () const { return m_high_tire_adhesion; }
|
bool highTireAdhesion () const { return m_high_tire_adhesion; }
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
const std::string&
|
const std::string&
|
||||||
getTexFname () const { return m_texname; }
|
getTexFname () const { return m_texname; }
|
||||||
//int getIndex () const { return m_index; }
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
bool isTransparent () const
|
bool isTransparent () const
|
||||||
{
|
{
|
||||||
return m_shader_type == SHADERTYPE_ADDITIVE ||
|
return m_shader_type == SHADERTYPE_ADDITIVE ||
|
||||||
@ -272,12 +297,6 @@ public:
|
|||||||
m_shader_type == SHADERTYPE_ALPHA_TEST;
|
m_shader_type == SHADERTYPE_ALPHA_TEST;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
/** Returns true if this materials need pre-multiply of alpha. */
|
|
||||||
//bool isPreMul() const {return m_adjust_image==ADJ_PREMUL; }
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
/** Returns true if this materials need pre-division of alpha. */
|
|
||||||
//bool isPreDiv() const {return m_adjust_image==ADJ_DIV; }
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the fraction of maximum speed on this material. */
|
/** Returns the fraction of maximum speed on this material. */
|
||||||
float getMaxSpeedFraction() const { return m_max_speed_fraction; }
|
float getMaxSpeedFraction() const { return m_max_speed_fraction; }
|
||||||
@ -300,17 +319,20 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the name of a special sfx to play while a kart is on this
|
/** Returns the name of a special sfx to play while a kart is on this
|
||||||
* terrain. The string will be "" if no special sfx exists. */
|
* terrain. The string will be "" if no special sfx exists. */
|
||||||
const std::string &
|
const std::string &getSFXName() const { return m_sfx_name; }
|
||||||
getSFXName () const { return m_sfx_name; }
|
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Returns if fog is enabled. */
|
||||||
bool isFogEnabled() const { return m_fog; }
|
bool isFogEnabled() const { return m_fog; }
|
||||||
|
|
||||||
/**
|
// ------------------------------------------------------------------------
|
||||||
* \brief Get the kind of particles that are to be used on this material, in the given conditions
|
/** \brief Get the kind of particles that are to be used on this material,
|
||||||
* \return The particles to use, or NULL if none
|
* in the given conditions.
|
||||||
*/
|
* \return The particles to use, or NULL if none. */
|
||||||
const ParticleKind* getParticlesWhen(ParticleConditions cond) const { return m_particles_effects[cond]; }
|
const ParticleKind* getParticlesWhen(ParticleConditions cond) const
|
||||||
|
{
|
||||||
|
return m_particles_effects[cond];
|
||||||
|
} // getParticlesWhen
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns true if a kart falling over this kind of material triggers
|
/** Returns true if a kart falling over this kind of material triggers
|
||||||
* the special falling camera. */
|
* the special falling camera. */
|
||||||
@ -346,9 +368,6 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
ShaderType getShaderType() const { return m_shader_type; }
|
ShaderType getShaderType() const { return m_shader_type; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void onMadeVisible(scene::IMeshBuffer* who);
|
|
||||||
void onHidden(scene::IMeshBuffer* who);
|
|
||||||
void isInitiallyHidden(scene::IMeshBuffer* who);
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1208,12 +1208,11 @@ int main(int argc, char *argv[] )
|
|||||||
main_loop = new MainLoop();
|
main_loop = new MainLoop();
|
||||||
material_manager->loadMaterial();
|
material_manager->loadMaterial();
|
||||||
|
|
||||||
// Load the font textures
|
// Load the font textures - they are all lazily loaded
|
||||||
file_manager->pushTextureSearchPath(
|
// so no need to push a texture search path. They will actually
|
||||||
file_manager->getAsset(FileManager::FONT,""));
|
// be loaded from ScalableFont.
|
||||||
material_manager->addSharedMaterial(
|
material_manager->addSharedMaterial(
|
||||||
file_manager->getAsset(FileManager::FONT,"materials.xml"));
|
file_manager->getAsset(FileManager::FONT,"materials.xml"));
|
||||||
file_manager->popTextureSearchPath();
|
|
||||||
|
|
||||||
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
|
GUIEngine::addLoadingIcon( irr_driver->getTexture(FileManager::GUI,
|
||||||
"options_video.png"));
|
"options_video.png"));
|
||||||
|
Loading…
Reference in New Issue
Block a user