Proper fix to #94 (finally!!!!)

It was so simple, wasn't it?
Additionaly:
* fixed texture recoloring after changing texture settings while simulation is running
* fixed annoying "could not open textures/shadow*.png" messages
* don't ChangeColor() if not in simulation to reduce lag in settings
master
krzys-h 2015-07-20 19:35:20 +02:00
parent 7b3ae32626
commit 5593f427f6
2 changed files with 28 additions and 23 deletions

View File

@ -2246,6 +2246,9 @@ bool CEngine::LoadAllTextures()
m_planet->LoadTexture();
m_firstGroundSpot = true;
UpdateGroundSpotTextures();
bool ok = true;
for (int objRank = 0; objRank < static_cast<int>( m_objects.size() ); objRank++)
@ -2444,6 +2447,9 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
m_texNameMap[texName] = tex;
m_revTexNameMap[tex] = texName;
// This updates the texture to updated Texture struct on the objects
LoadAllTextures();
return true;
}
@ -2824,14 +2830,12 @@ float CEngine::GetGadgetQuantity()
void CEngine::SetTextureFilterMode(TexFilter value)
{
bool changed = m_defaultTexParams.filter != value || m_terrainTexParams.filter != value;
if(m_defaultTexParams.filter == value && m_terrainTexParams.filter == value) return;
m_defaultTexParams.filter = m_terrainTexParams.filter = value;
m_defaultTexParams.mipmap = m_terrainTexParams.mipmap = (value == TEX_FILTER_TRILINEAR);
if(changed)
{
FlushTextureCache();
LoadAllTextures();
}
ResetAfterDeviceChanged();
CRobotMain::GetInstancePointer()->ChangeColor();
}
TexFilter CEngine::GetTextureFilterMode()
@ -2843,14 +2847,11 @@ void CEngine::SetTextureMipmapLevel(int value)
{
if (value < 1) value = 1;
if (value > 16) value = 16;
if(m_textureMipmapLevel == value) return;
bool changed = m_textureMipmapLevel != value;
m_textureMipmapLevel = value;
if(changed)
{
FlushTextureCache();
LoadAllTextures();
}
ResetAfterDeviceChanged();
CRobotMain::GetInstancePointer()->ChangeColor();
}
int CEngine::GetTextureMipmapLevel()
@ -2863,13 +2864,11 @@ void CEngine::SetTextureAnisotropyLevel(int value)
if (value < 1) value = 1;
if (value > 16) value = 16;
bool changed = m_textureAnisotropy != value;
if(m_textureAnisotropy == value) return;
m_textureAnisotropy = value;
if(changed)
{
FlushTextureCache();
LoadAllTextures();
}
ResetAfterDeviceChanged();
CRobotMain::GetInstancePointer()->ChangeColor();
}
int CEngine::GetTextureAnisotropyLevel()

View File

@ -2822,10 +2822,6 @@ void CRobotMain::ScenePerso()
m_lightMan->FlushLights();
m_particle->FlushParticle();
ChangeColor();
m_dialog->SetLevel(LevelCategory::Perso, 0, 0);
try
{
@ -3910,7 +3906,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_build |= BUILD_FLAG;
}
if (!resetObject && !fixScene)
if (!resetObject)
{
ChangeColor(); // changes the colors of texture
m_short->SetMode(false); // vehicles?
@ -4022,6 +4018,16 @@ int CRobotMain::CreateSpot(Math::Vector pos, Gfx::Color color)
//! Change the colors and textures
void CRobotMain::ChangeColor()
{
if (m_phase != PHASE_SIMUL &&
m_phase != PHASE_SETUPds &&
m_phase != PHASE_SETUPgs &&
m_phase != PHASE_SETUPps &&
m_phase != PHASE_SETUPcs &&
m_phase != PHASE_SETUPss &&
m_phase != PHASE_WIN &&
m_phase != PHASE_LOST &&
m_phase != PHASE_APPERANCE ) return;
Math::Point ts = Math::Point(0.0f, 0.0f);
Math::Point ti = Math::Point(1.0f, 1.0f); // the entire image