[Bf-blender-cvs] [931c3e6] master: BGE: Code clean up for world (mist, background, ambient)
Thomas Szepe
noreply at git.blender.org
Mon Mar 23 22:49:52 CET 2015
Commit: 931c3e654404bbff05f1bcce9487fc6e91392300
Author: Thomas Szepe
Date: Mon Mar 23 22:49:38 2015 +0100
Branches: master
https://developer.blender.org/rB931c3e654404bbff05f1bcce9487fc6e91392300
BGE: Code clean up for world (mist, background, ambient)
Code clean up for BGE world mist, background and global ambient color.
Move mist render update to BlenderWolrdInfo
Reviewers: moguri, brecht
Reviewed By: moguri, brecht
Differential Revision: https://developer.blender.org/D152
===================================================================
M source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
M source/gameengine/Converter/BlenderWorldInfo.cpp
M source/gameengine/Converter/BlenderWorldInfo.h
M source/gameengine/Ketsji/KX_KetsjiEngine.cpp
M source/gameengine/Ketsji/KX_KetsjiEngine.h
M source/gameengine/Ketsji/KX_WorldInfo.h
M source/gameengine/Rasterizer/RAS_IRasterizer.h
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
M source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
M source/gameengine/VideoTexture/ImageRender.cpp
===================================================================
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 511b615..1a19892 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -446,7 +446,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c
rasterizer->SetEyeSeparation(scene->gm.eyeseparation);
}
- rasterizer->SetBackColor(scene->gm.framing.col[0], scene->gm.framing.col[1], scene->gm.framing.col[2], 0.0f);
+ rasterizer->SetBackColor(scene->gm.framing.col);
}
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp
index 5f47694..40293d7 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.cpp
+++ b/source/gameengine/Converter/BlenderWorldInfo.cpp
@@ -33,6 +33,8 @@
#include <stdio.h> // printf()
#include "BlenderWorldInfo.h"
+#include "KX_PythonInit.h"
+#include "GPU_material.h"
/* This little block needed for linking to Blender... */
#ifdef WIN32
@@ -40,23 +42,7 @@
#endif
/* This list includes only data type definitions */
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_group_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_property_types.h"
-#include "DNA_text_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_view3d_types.h"
#include "DNA_world_types.h"
-#include "DNA_screen_types.h"
#include "BLI_math.h"
@@ -65,7 +51,7 @@
/* end of blender include block */
-BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World *blenderworld)
+BlenderWorldInfo::BlenderWorldInfo(Scene *blenderscene, World *blenderworld)
{
if (blenderworld) {
m_hasworld = true;
@@ -212,3 +198,38 @@ void BlenderWorldInfo::setAmbientColor(float r, float g, float b)
m_ambientcolor[1] = g;
m_ambientcolor[2] = b;
}
+
+void BlenderWorldInfo::UpdateBackGround()
+{
+ if (m_hasworld) {
+ RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer();
+
+ if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) {
+ m_rasterizer->SetBackColor(m_backgroundcolor);
+ GPU_horizon_update_color(m_backgroundcolor);
+ }
+ }
+}
+
+void BlenderWorldInfo::UpdateWorldSettings()
+{
+ if (m_hasworld) {
+ RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer();
+
+ if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) {
+ m_rasterizer->SetAmbientColor(m_ambientcolor);
+ GPU_ambient_update_color(m_ambientcolor);
+
+ if (m_hasmist) {
+ m_rasterizer->SetFog(m_misttype, m_miststart, m_mistdistance, m_mistintensity, m_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);
+ }
+ }
+ }
+}
diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h
index 4184d42..395e8f7 100644
--- a/source/gameengine/Converter/BlenderWorldInfo.h
+++ b/source/gameengine/Converter/BlenderWorldInfo.h
@@ -31,37 +31,33 @@
#ifndef __BLENDERWORLDINFO_H__
#define __BLENDERWORLDINFO_H__
-#include "MT_CmMatrix4x4.h"
#include "KX_WorldInfo.h"
+#include "KX_KetsjiEngine.h"
+#include "RAS_IRasterizer.h"
+
+struct Scene;
+struct World;
+const class KX_KetsjiEngine;
+const class RAS_IRasterizer;
class BlenderWorldInfo : public KX_WorldInfo
{
bool m_hasworld;
- float m_backgroundcolor[3];
-
bool m_hasmist;
short m_misttype;
float m_miststart;
float m_mistdistance;
float m_mistintensity;
float m_mistcolor[3];
-
+ float m_backgroundcolor[3];
float m_ambientcolor[3];
public:
- BlenderWorldInfo(struct Scene *blenderscene, struct World *blenderworld);
+ BlenderWorldInfo(Scene *blenderscene, World *blenderworld);
~BlenderWorldInfo();
bool hasWorld();
bool hasMist();
- float getBackColorRed();
- float getBackColorGreen();
- float getBackColorBlue();
-
- float getAmbientColorRed();
- float getAmbientColorGreen();
- float getAmbientColorBlue();
-
short getMistType();
float getMistStart();
float getMistDistance();
@@ -69,7 +65,12 @@ public:
float getMistColorRed();
float getMistColorGreen();
float getMistColorBlue();
-
+ float getBackColorRed();
+ float getBackColorGreen();
+ float getBackColorBlue();
+ float getAmbientColorRed();
+ float getAmbientColorGreen();
+ float getAmbientColorBlue();
void setBackColor(float r, float g, float b);
void setUseMist(bool enable);
void setMistType(short type);
@@ -78,7 +79,8 @@ public:
void setMistIntensity(float intensity);
void setMistColor(float r, float g, float b);
void setAmbientColor(float r, float g, float b);
-
+ void UpdateBackGround();
+ void UpdateWorldSettings();
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("GE:BlenderWorldInfo")
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 2907371..6c2e34d 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -80,8 +80,6 @@
#include "KX_NavMeshObject.h"
-#include "GPU_material.h"
-
#define DEFAULT_LOGIC_TIC_RATE 60.0
//#define DEFAULT_PHYSICS_TIC_RATE 60.0
@@ -317,7 +315,7 @@ void KX_KetsjiEngine::RenderDome()
KX_Camera* cam = scene->GetActiveCamera();
// pass the scene's worldsettings to the rasterizer
- SetWorldSettings(scene->GetWorldInfo());
+ scene->GetWorldInfo()->UpdateWorldSettings();
// shadow buffers
if (i == 0) {
@@ -477,7 +475,7 @@ void KX_KetsjiEngine::ClearFrame()
if (doclear) {
KX_Scene* firstscene = *m_scenes.begin();
- SetBackGround(firstscene->GetWorldInfo());
+ firstscene->GetWorldInfo()->UpdateBackGround();
m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(),
clearvp.GetRight(), clearvp.GetTop());
@@ -827,7 +825,7 @@ void KX_KetsjiEngine::Render()
KX_Scene* scene = *sceneit;
KX_Camera* cam = scene->GetActiveCamera();
// pass the scene's worldsettings to the rasterizer
- SetWorldSettings(scene->GetWorldInfo());
+ scene->GetWorldInfo()->UpdateWorldSettings();
// this is now done incrementatlly in KX_Scene::CalculateVisibleMeshes
//scene->UpdateMeshTransformations();
@@ -884,7 +882,7 @@ void KX_KetsjiEngine::Render()
KX_Camera* cam = scene->GetActiveCamera();
// pass the scene's worldsettings to the rasterizer
- SetWorldSettings(scene->GetWorldInfo());
+ scene->GetWorldInfo()->UpdateWorldSettings();
if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer();
@@ -964,77 +962,6 @@ const STR_String& KX_KetsjiEngine::GetExitString()
return m_exitstring;
}
-
-void KX_KetsjiEngine::SetBackGround(KX_WorldInfo* wi)
-{
- if (wi->hasWorld())
- {
- if (m_rasterizer->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
- {
- m_rasterizer->SetBackColor(
- wi->getBackColorRed(),
- wi->getBackColorGreen(),
- wi->getBackColorBlue(),
- 0.0
- );
-
- float horicolor[] = {wi->getBackColorRed(), wi->getBackColorGreen(), wi->getBackColorBlue()};
- GPU_horizon_update_color(horicolor);
- }
- }
-}
-
-
-
-void KX_KetsjiEngine::SetWorldSettings(KX_WorldInfo* wi)
-{
- if (wi->hasWorld())
- {
- if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
- {
- m_rasterizer->SetAmbientColor(
- wi->getAmbientColorRed(),
- wi->getAmbientColorGreen(),
- wi->getAmbientColorBlue()
- );
-
- float ambcolor[] = {wi->getAmbientColorRed(), wi->getAmbientColorGreen(), wi->getAmbientColorBlue()};
- GPU_ambient_update_color(ambcolor);
-
- if (wi->hasMist())
- {
- m_rasterizer->SetFog(
- wi->getMistType(),
- wi->getMistStart(),
- wi->getMistDistance(),
- wi->getMistIntensity(),
- wi->getMistColorRed(),
- wi->getMistColorGreen(),
- wi->getMistColorBlue()
- );
-
- float mistcolor[] = {wi->getMistColorRed(), wi->getMistColorGreen(), wi->getMistColorBlue()};
- GPU_mist_update_values(
- wi->getMistType(),
- wi->getMistStart(),
- wi->getMistDistance(),
- wi->getMistIntensity(),
- mistcolor
- );
-
- m_rasterizer->EnableFog(true);
- GPU_mist_update_enable(true);
- }
- else {
- m_rasterizer->EnableFog(false);
- GPU_mist_update_enable(false);
- }
- }
- }
-}
-
-
-
void KX_KetsjiEngine::EnableCameraOverride(const STR_String& forscene)
{
m_overrideCam = true;
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
index e18b203..4392769 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h
@@ -205,14 +205,12 @@ private:
void PostRenderScene(KX_Scene* scene);
void RenderDebugProperties();
void RenderShadowBuffers(KX_Scene *scene);
- void SetBackGround(KX_WorldInfo* worldinfo);
public:
KX_KetsjiEngine(class KX_ISystem* system);
virtual ~KX_KetsjiEngine();
// set the devices and stuff. the client must take care of creating these
- void SetWorldSettings(KX_WorldInfo* worldinfo);
void SetKeyboardDevice(SCA_IInputDevice* keyboarddevice);
void SetMouseDevice(SCA_IInputDevice* mousedevice);
void SetNetworkDevice(NG_NetworkDeviceInterface* networkdevice);
diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h
index f90a4ff..a6f93dd 100644
--- a/source/gameengine/Ketsji/KX_WorldInfo.h
+++ b/source/gameengine/Ketsji/KX_WorldInfo.h
@@ -57,9 +57,6 @@ public:
virtual bool hasWorld() = 0;
virtual bool hasMist() = 0;
- virtual float getBackColorRed() = 0;
- virtual float getBackColorGreen() = 0;
- virtual float getBackColorBlue() = 0;
virtual short getMistType() = 0;
virtual float getMistStart() = 0;
virtual float getMistDistance() = 0;
@@ -67,11 +64,12 @@ public:
virtual float
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list