Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Szepe <HG1_public@gmx.net>2015-03-24 00:49:38 +0300
committerThomas Szepe <HG1_public@gmx.net>2015-03-24 00:49:38 +0300
commit931c3e654404bbff05f1bcce9487fc6e91392300 (patch)
tree6b71c869a8827c2231f47db7a8d22a67cbc60380 /source/gameengine/Converter
parentc73693d4a5c9b286333a90dd0fc6fd8a7e6ea753 (diff)
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
Diffstat (limited to 'source/gameengine/Converter')
-rw-r--r--source/gameengine/Converter/BlenderWorldInfo.cpp55
-rw-r--r--source/gameengine/Converter/BlenderWorldInfo.h32
2 files changed, 55 insertions, 32 deletions
diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp
index 5f476949616..40293d7479b 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 4184d428808..395e8f723aa 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")