From 5593f427f6f36b6c1b61329aeabead714cc2e778 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 20 Jul 2015 19:35:20 +0200 Subject: [PATCH] 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 --- src/graphics/engine/engine.cpp | 35 +++++++++++++++++----------------- src/object/robotmain.cpp | 16 +++++++++++----- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index 8a6aba2d..9f640073 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -2246,6 +2246,9 @@ bool CEngine::LoadAllTextures() m_planet->LoadTexture(); + m_firstGroundSpot = true; + UpdateGroundSpotTextures(); + bool ok = true; for (int objRank = 0; objRank < static_cast( 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() diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index c67ce9af..2c726a28 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -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