From be7d3655f5eccf1e7bb76b66e1339dda85300ba7 Mon Sep 17 00:00:00 2001 From: Porteries Tristan Date: Wed, 17 Feb 2016 22:43:16 +0100 Subject: [PATCH] UPBGE: Pass the rasterizer as function arguments in KX_WorldInfo. --- source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 8 ++-- source/gameengine/Ketsji/KX_WorldInfo.cpp | 45 ++++++++----------- source/gameengine/Ketsji/KX_WorldInfo.h | 4 +- .../gameengine/VideoTexture/ImageRender.cpp | 2 +- 4 files changed, 25 insertions(+), 34 deletions(-) diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 6ba3970d3365..604d2c418543 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -288,7 +288,7 @@ void KX_KetsjiEngine::RenderDome() KX_Camera *cam = scene->GetActiveCamera(); // pass the scene's worldsettings to the rasterizer - scene->GetWorldInfo()->UpdateWorldSettings(); + scene->GetWorldInfo()->UpdateWorldSettings(m_rasterizer); // shadow buffers if (i == 0) { @@ -437,7 +437,7 @@ void KX_KetsjiEngine::ClearFrame() if (doclear) { KX_Scene *firstscene = (KX_Scene *)m_scenes->GetFront(); - firstscene->GetWorldInfo()->UpdateBackGround(); + firstscene->GetWorldInfo()->UpdateBackGround(m_rasterizer); m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(), clearvp.GetRight(), clearvp.GetTop()); m_rasterizer->ClearColorBuffer(); @@ -760,7 +760,7 @@ void KX_KetsjiEngine::Render() KX_Scene *scene = (KX_Scene *)*sceit; KX_Camera *cam = scene->GetActiveCamera(); // pass the scene's worldsettings to the rasterizer - scene->GetWorldInfo()->UpdateWorldSettings(); + scene->GetWorldInfo()->UpdateWorldSettings(m_rasterizer); // shadow buffers RenderShadowBuffers(scene); @@ -809,7 +809,7 @@ void KX_KetsjiEngine::Render() KX_Camera *cam = scene->GetActiveCamera(); // pass the scene's worldsettings to the rasterizer - scene->GetWorldInfo()->UpdateWorldSettings(); + scene->GetWorldInfo()->UpdateWorldSettings(m_rasterizer); if (scene->IsClearingZBuffer()) m_rasterizer->ClearDepthBuffer(); diff --git a/source/gameengine/Ketsji/KX_WorldInfo.cpp b/source/gameengine/Ketsji/KX_WorldInfo.cpp index abb4d48fceb4..118c753171ab 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.cpp +++ b/source/gameengine/Ketsji/KX_WorldInfo.cpp @@ -31,7 +31,6 @@ #include "KX_WorldInfo.h" -#include "KX_PythonInit.h" #include "KX_PyMath.h" #include "RAS_IRasterizer.h" #include "GPU_material.h" @@ -158,37 +157,29 @@ void KX_WorldInfo::setAmbientColor(float r, float g, float b) } } -void KX_WorldInfo::UpdateBackGround() +void KX_WorldInfo::UpdateBackGround(RAS_IRasterizer *rasty) { - if (m_hasworld) { - RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer(); - - if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::RAS_SOLID) { - m_rasterizer->SetBackColor(m_con_backgroundcolor); - GPU_horizon_update_color(m_backgroundcolor); - } + if (m_hasworld && rasty->GetDrawingMode() >= RAS_IRasterizer::RAS_SOLID) { + rasty->SetBackColor(m_con_backgroundcolor); + GPU_horizon_update_color(m_backgroundcolor); } } -void KX_WorldInfo::UpdateWorldSettings() +void KX_WorldInfo::UpdateWorldSettings(RAS_IRasterizer *rasty) { - if (m_hasworld) { - RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer(); - - if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::RAS_SOLID) { - m_rasterizer->SetAmbientColor(m_con_ambientcolor); - GPU_ambient_update_color(m_ambientcolor); - - if (m_hasmist) { - m_rasterizer->SetFog(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_con_mistcolor); - GPU_mist_update_values(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_mistcolor); - m_rasterizer->EnableFog(true); - GPU_mist_update_enable(true); - } - else { - m_rasterizer->EnableFog(false); - GPU_mist_update_enable(false); - } + if (m_hasworld && rasty->GetDrawingMode() >= RAS_IRasterizer::RAS_SOLID) { + rasty->SetAmbientColor(m_con_ambientcolor); + GPU_ambient_update_color(m_ambientcolor); + + if (m_hasmist) { + rasty->SetFog(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_con_mistcolor); + GPU_mist_update_values(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_mistcolor); + rasty->EnableFog(true); + GPU_mist_update_enable(true); + } + else { + rasty->EnableFog(false); + GPU_mist_update_enable(false); } } } diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index 6c7a3bbfbae4..ff951d57cf50 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -87,8 +87,8 @@ class KX_WorldInfo : public PyObjectPlus void setBackColor(float r, float g, float b); const float *getBackColorConverted() const; void setAmbientColor(float r, float g, float b); - void UpdateBackGround(); - void UpdateWorldSettings(); + void UpdateBackGround(RAS_IRasterizer *rasty); + void UpdateWorldSettings(RAS_IRasterizer *rasty); void RenderBackground(RAS_IRasterizer *rasty); #ifdef WITH_PYTHON diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index d4afdb42bbb1..f96f0e860334 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -219,7 +219,7 @@ void ImageRender::Render() m_canvas->ClearColor(m_background[0], m_background[1], m_background[2], m_background[3]); m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER); m_rasterizer->BeginFrame(m_engine->GetClockTime()); - m_scene->GetWorldInfo()->UpdateWorldSettings(); + m_scene->GetWorldInfo()->UpdateWorldSettings(m_rasterizer); m_rasterizer->SetAuxilaryClientInfo(m_scene); m_rasterizer->DisplayFog(); // matrix calculation, don't apply any of the stereo mode