From eff0e29cbae095baae26fc650baed36ff0573f50 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Tue, 18 Jan 2011 22:27:18 +0000 Subject: [PATCH] BGE BugFix [#25711]render.setBackgroundColor() does not work: Since rev.2 (hans ftw) we have a strange situation where horizon color was being used at Convert time for the WorldInfo background color (and for the fog). However through the Python API only the Rasterizer background color was being updated. On top of that the KX_KetsjiEngine.cpp::SetBackGround was using the WorldInfo bgcolor when render mode was the potato one (TEXTURED). Bottomline, when in potato mode the glClearColor used was the original one in worldinfo, not the API updated one in Rasterized. --- source/gameengine/Converter/BlenderWorldInfo.cpp | 6 ++++++ source/gameengine/Converter/BlenderWorldInfo.h | 6 ++++++ source/gameengine/Ketsji/KX_PythonInit.cpp | 5 +++++ source/gameengine/Ketsji/KX_WorldInfo.h | 1 + 4 files changed, 18 insertions(+) diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp index f0d6083a8fa..60cb4a751bb 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ b/source/gameengine/Converter/BlenderWorldInfo.cpp @@ -188,6 +188,12 @@ float BlenderWorldInfo::getMistColorBlue() return m_mistcolor[2]; } +void BlenderWorldInfo::setBackColor(float r, float g, float b) +{ + m_backgroundcolor[0] = r; + m_backgroundcolor[1] = g; + m_backgroundcolor[2] = b; +} void BlenderWorldInfo::setMistStart( diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h index a430e18223e..29145344d18 100644 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ b/source/gameengine/Converter/BlenderWorldInfo.h @@ -64,6 +64,12 @@ public: float getMistColorGreen(); float getMistColorBlue(); + void + setBackColor( + float r, + float g, + float b + ); void setMistStart( float d diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index f5a9e438e1a..8cc62e2c2fb 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -923,6 +923,11 @@ static PyObject* gPySetBackgroundColor(PyObject*, PyObject* value) { gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]); } + + KX_WorldInfo *wi = gp_KetsjiScene->GetWorldInfo(); + if (wi->hasWorld()) + wi->setBackColor(vec[0], vec[1], vec[2]); + Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index 3b3d52f91f7..fb730c5502f 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -58,6 +58,7 @@ public: virtual float getAmbientColorGreen()=0; virtual float getAmbientColorBlue()=0; + virtual void setBackColor(float,float,float)=0; virtual void setMistStart(float)=0; virtual void setMistDistance(float)=0; virtual void setMistColorRed(float)=0;