Skip to content

Commit

Permalink
UPBGE: Pass the rasterizer as function arguments in KX_WorldInfo.
Browse files Browse the repository at this point in the history
  • Loading branch information
panzergame committed Feb 17, 2016
1 parent da69af4 commit be7d365
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 34 deletions.
8 changes: 4 additions & 4 deletions source/gameengine/Ketsji/KX_KetsjiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
45 changes: 18 additions & 27 deletions source/gameengine/Ketsji/KX_WorldInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@


#include "KX_WorldInfo.h"
#include "KX_PythonInit.h"
#include "KX_PyMath.h"
#include "RAS_IRasterizer.h"
#include "GPU_material.h"
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/gameengine/Ketsji/KX_WorldInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/gameengine/VideoTexture/ImageRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit be7d365

Please sign in to comment.