[colobot] 233/390: Better fix for #94
Didier Raboud
odyx at moszumanska.debian.org
Fri Jun 12 14:21:49 UTC 2015
This is an automated email from the git hooks/post-receive script.
odyx pushed a commit to branch upstream/latest
in repository colobot.
commit f30592bf56143677d0302c06a0a6bc21dc2e179c
Author: Piotr Dziwinski <piotrdz at gmail.com>
Date: Sat Nov 22 13:30:05 2014 +0100
Better fix for #94
---
src/graphics/engine/engine.cpp | 117 ++++++++++++++++++++++-------------------
src/object/robotmain.cpp | 6 +--
2 files changed, 64 insertions(+), 59 deletions(-)
diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp
index cd975ab..ae7733b 100644
--- a/src/graphics/engine/engine.cpp
+++ b/src/graphics/engine/engine.cpp
@@ -2439,14 +2439,18 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
m_texBlacklist.insert(texName);
return false;
}
-
+
+ bool changeColorsNeeded = true;
+
if (colorRef1.r == colorNew1.r &&
colorRef1.g == colorNew1.g &&
colorRef1.b == colorNew1.b &&
colorRef2.r == colorNew2.r &&
colorRef2.g == colorNew2.g &&
colorRef2.b == colorNew2.b)
- return true;
+ {
+ changeColorsNeeded = false;
+ }
int dx = img.GetSize().x;
@@ -2464,66 +2468,69 @@ bool CEngine::ChangeTextureColor(const std::string& texName,
ColorHSV cr2 = RGB2HSV(colorRef2);
ColorHSV cn2 = RGB2HSV(colorNew2);
- for (int y = sy; y < ey; y++)
+ if (changeColorsNeeded)
{
- for (int x = sx; x < ex; x++)
+ for (int y = sy; y < ey; y++)
{
- if (exclude != nullptr && IsExcludeColor(exclude, x,y) )
- continue;
+ for (int x = sx; x < ex; x++)
+ {
+ if (exclude != nullptr && IsExcludeColor(exclude, x,y) )
+ continue;
- Color color = img.GetPixel(Math::IntPoint(x, y));
+ Color color = img.GetPixel(Math::IntPoint(x, y));
- if (hsv)
- {
- ColorHSV c = RGB2HSV(color);
- if (c.s > 0.01f && fabs(c.h - cr1.h) < tolerance1)
- {
- c.h += cn1.h - cr1.h;
- c.s += cn1.s - cr1.s;
- c.v += cn1.v - cr1.v;
- if (c.h < 0.0f) c.h -= 1.0f;
- if (c.h > 1.0f) c.h += 1.0f;
- color = HSV2RGB(c);
- color.r = Math::Norm(color.r + shift);
- color.g = Math::Norm(color.g + shift);
- color.b = Math::Norm(color.b + shift);
- img.SetPixel(Math::IntPoint(x, y), color);
- }
- else if (tolerance2 != -1.0f &&
- c.s > 0.01f && fabs(c.h - cr2.h) < tolerance2)
- {
- c.h += cn2.h - cr2.h;
- c.s += cn2.s - cr2.s;
- c.v += cn2.v - cr2.v;
- if (c.h < 0.0f) c.h -= 1.0f;
- if (c.h > 1.0f) c.h += 1.0f;
- color = HSV2RGB(c);
- color.r = Math::Norm(color.r + shift);
- color.g = Math::Norm(color.g + shift);
- color.b = Math::Norm(color.b + shift);
- img.SetPixel(Math::IntPoint(x, y), color);
- }
- }
- else
- {
- if ( fabs(color.r - colorRef1.r) +
- fabs(color.g - colorRef1.g) +
- fabs(color.b - colorRef1.b) < tolerance1 * 3.0f)
+ if (hsv)
{
- color.r = Math::Norm(colorNew1.r + color.r - colorRef1.r + shift);
- color.g = Math::Norm(colorNew1.g + color.g - colorRef1.g + shift);
- color.b = Math::Norm(colorNew1.b + color.b - colorRef1.b + shift);
- img.SetPixel(Math::IntPoint(x, y), color);
+ ColorHSV c = RGB2HSV(color);
+ if (c.s > 0.01f && fabs(c.h - cr1.h) < tolerance1)
+ {
+ c.h += cn1.h - cr1.h;
+ c.s += cn1.s - cr1.s;
+ c.v += cn1.v - cr1.v;
+ if (c.h < 0.0f) c.h -= 1.0f;
+ if (c.h > 1.0f) c.h += 1.0f;
+ color = HSV2RGB(c);
+ color.r = Math::Norm(color.r + shift);
+ color.g = Math::Norm(color.g + shift);
+ color.b = Math::Norm(color.b + shift);
+ img.SetPixel(Math::IntPoint(x, y), color);
+ }
+ else if (tolerance2 != -1.0f &&
+ c.s > 0.01f && fabs(c.h - cr2.h) < tolerance2)
+ {
+ c.h += cn2.h - cr2.h;
+ c.s += cn2.s - cr2.s;
+ c.v += cn2.v - cr2.v;
+ if (c.h < 0.0f) c.h -= 1.0f;
+ if (c.h > 1.0f) c.h += 1.0f;
+ color = HSV2RGB(c);
+ color.r = Math::Norm(color.r + shift);
+ color.g = Math::Norm(color.g + shift);
+ color.b = Math::Norm(color.b + shift);
+ img.SetPixel(Math::IntPoint(x, y), color);
+ }
}
- else if (tolerance2 != -1 &&
- fabs(color.r - colorRef2.r) +
- fabs(color.g - colorRef2.g) +
- fabs(color.b - colorRef2.b) < tolerance2 * 3.0f)
+ else
{
- color.r = Math::Norm(colorNew2.r + color.r - colorRef2.r + shift);
- color.g = Math::Norm(colorNew2.g + color.g - colorRef2.g + shift);
- color.b = Math::Norm(colorNew2.b + color.b - colorRef2.b + shift);
- img.SetPixel(Math::IntPoint(x, y), color);
+ if ( fabs(color.r - colorRef1.r) +
+ fabs(color.g - colorRef1.g) +
+ fabs(color.b - colorRef1.b) < tolerance1 * 3.0f)
+ {
+ color.r = Math::Norm(colorNew1.r + color.r - colorRef1.r + shift);
+ color.g = Math::Norm(colorNew1.g + color.g - colorRef1.g + shift);
+ color.b = Math::Norm(colorNew1.b + color.b - colorRef1.b + shift);
+ img.SetPixel(Math::IntPoint(x, y), color);
+ }
+ else if (tolerance2 != -1 &&
+ fabs(color.r - colorRef2.r) +
+ fabs(color.g - colorRef2.g) +
+ fabs(color.b - colorRef2.b) < tolerance2 * 3.0f)
+ {
+ color.r = Math::Norm(colorNew2.r + color.r - colorRef2.r + shift);
+ color.g = Math::Norm(colorNew2.g + color.g - colorRef2.g + shift);
+ color.b = Math::Norm(colorNew2.b + color.b - colorRef2.b + shift);
+ img.SetPixel(Math::IntPoint(x, y), color);
+ }
}
}
}
diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp
index b134085..f2f6b23 100644
--- a/src/object/robotmain.cpp
+++ b/src/object/robotmain.cpp
@@ -3660,9 +3660,7 @@ void CRobotMain::ScenePerso()
iMan->Flush(CLASS_PYRO);
CObjectManager::GetInstancePointer()->Flush();
-
- ChangeColor();
-
+
m_dialog->SetSceneName("perso");
m_dialog->SetSceneRank(0);
try {
@@ -4743,7 +4741,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
g_build |= BUILD_FLAG;
}
- if (!resetObject && !fixScene)
+ if (!resetObject)
{
ChangeColor(); // changes the colors of texture
m_short->SetMode(false); // vehicles?
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git
More information about the Pkg-games-commits
mailing list