From 6c9502a6c1e8637922991171680986f1c9a17f6e Mon Sep 17 00:00:00 2001 From: Thomas Szepe Date: Tue, 24 Mar 2015 00:19:15 +0100 Subject: BGE: Remove BlenderWorldInfo This patch will remove the BlenderWorldInfo and move the source into KX_WorldInfo. Reviewers: brecht, moguri Reviewed By: brecht, moguri Differential Revision: https://developer.blender.org/D156 --- .../Converter/BL_BlenderDataConversion.cpp | 4 +- source/gameengine/Converter/BlenderWorldInfo.cpp | 251 --------------------- source/gameengine/Converter/BlenderWorldInfo.h | 94 -------- source/gameengine/Converter/CMakeLists.txt | 2 - .../Converter/KX_BlenderSceneConverter.cpp | 2 +- source/gameengine/Ketsji/KX_WorldInfo.cpp | 212 +++++++++++++++++ source/gameengine/Ketsji/KX_WorldInfo.h | 75 +++--- 7 files changed, 262 insertions(+), 378 deletions(-) delete mode 100644 source/gameengine/Converter/BlenderWorldInfo.cpp delete mode 100644 source/gameengine/Converter/BlenderWorldInfo.h diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 3e7e104ed46..de5e27baf58 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -98,7 +98,7 @@ #include "BLI_utildefines.h" #include "BLI_listbase.h" -#include "BlenderWorldInfo.h" +#include "KX_WorldInfo.h" #include "KX_KetsjiEngine.h" #include "KX_BlenderSceneConverter.h" @@ -2342,7 +2342,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, sumolist->Release(); // convert world - KX_WorldInfo* worldinfo = new BlenderWorldInfo(blenderscene, blenderscene->world); + KX_WorldInfo* worldinfo = new KX_WorldInfo(blenderscene, blenderscene->world); converter->RegisterWorldInfo(worldinfo); kxscene->SetWorldInfo(worldinfo); diff --git a/source/gameengine/Converter/BlenderWorldInfo.cpp b/source/gameengine/Converter/BlenderWorldInfo.cpp deleted file mode 100644 index 6daecccf15c..00000000000 --- a/source/gameengine/Converter/BlenderWorldInfo.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can [0]istribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file gameengine/Converter/BlenderWorldInfo.cpp - * \ingroup bgeconv - */ - - -#include // printf() - -#include "BlenderWorldInfo.h" -#include "KX_PythonInit.h" -#include "GPU_material.h" - -/* This little block needed for linking to Blender... */ -#ifdef WIN32 -#include "BLI_winstuff.h" -#endif - -/* This list includes only data type definitions */ -#include "DNA_world_types.h" - -#include "BLI_math.h" - -#include "BKE_global.h" -#include "BKE_scene.h" -/* end of blender include block */ - - -BlenderWorldInfo::BlenderWorldInfo(Scene *blenderscene, World *blenderworld) -{ - if (blenderworld) { - m_do_color_management = BKE_scene_check_color_management_enabled(blenderscene); - m_hasworld = true; - m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false); - m_misttype = blenderworld->mistype; - m_miststart = blenderworld->miststa; - m_mistdistance = blenderworld->mistdist; - m_mistintensity = blenderworld->misi; - setMistColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); - setBackColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); - setAmbientColor(blenderworld->ambr, blenderworld->ambg, blenderworld->ambb); - } - else { - m_hasworld = false; - } -} - -BlenderWorldInfo::~BlenderWorldInfo() -{ -} - -bool BlenderWorldInfo::hasWorld() -{ - return m_hasworld; -} - -bool BlenderWorldInfo::hasMist() -{ - return m_hasmist; -} - -float BlenderWorldInfo::getBackColorRed() -{ - return m_backgroundcolor[0]; -} - -float BlenderWorldInfo::getBackColorGreen() -{ - return m_backgroundcolor[1]; -} - -float BlenderWorldInfo::getBackColorBlue() -{ - return m_backgroundcolor[2]; -} - -float BlenderWorldInfo::getAmbientColorRed() -{ - return m_ambientcolor[0]; -} - -float BlenderWorldInfo::getAmbientColorGreen() -{ - return m_ambientcolor[1]; -} - -float BlenderWorldInfo::getAmbientColorBlue() -{ - return m_ambientcolor[2]; -} - -short BlenderWorldInfo::getMistType() -{ - return m_misttype; -} - -float BlenderWorldInfo::getMistStart() -{ - return m_miststart; -} - -float BlenderWorldInfo::getMistDistance() -{ - return m_mistdistance; -} - -float BlenderWorldInfo::getMistIntensity() -{ - return m_mistintensity; -} - -float BlenderWorldInfo::getMistColorRed() -{ - return m_mistcolor[0]; -} - -float BlenderWorldInfo::getMistColorGreen() -{ - return m_mistcolor[1]; -} - -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; - - if (m_do_color_management) { - linearrgb_to_srgb_v3_v3(m_con_backgroundcolor, m_backgroundcolor); - } - else { - copy_v3_v3(m_con_backgroundcolor, m_backgroundcolor); - } -} - -void BlenderWorldInfo::setMistType(short type) -{ - m_misttype = type; -} - -void BlenderWorldInfo::setUseMist(bool enable) -{ - m_hasmist = enable; -} - -void BlenderWorldInfo::setMistStart(float d) -{ - m_miststart = d; -} - -void BlenderWorldInfo::setMistDistance(float d) -{ - m_mistdistance = d; -} - -void BlenderWorldInfo::setMistIntensity(float intensity) -{ - m_mistintensity = intensity; -} -void BlenderWorldInfo::setMistColor(float r, float g, float b) -{ - m_mistcolor[0] = r; - m_mistcolor[1] = g; - m_mistcolor[2] = b; - - if (m_do_color_management) { - linearrgb_to_srgb_v3_v3(m_con_mistcolor, m_mistcolor); - } - else { - copy_v3_v3(m_con_mistcolor, m_mistcolor); - } -} - -void BlenderWorldInfo::setAmbientColor(float r, float g, float b) -{ - m_ambientcolor[0] = r; - m_ambientcolor[1] = g; - m_ambientcolor[2] = b; - - if (m_do_color_management) { - linearrgb_to_srgb_v3_v3(m_con_ambientcolor, m_ambientcolor); - } - else { - copy_v3_v3(m_con_ambientcolor, m_ambientcolor); - } -} - -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_con_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_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); - } - } - } -} diff --git a/source/gameengine/Converter/BlenderWorldInfo.h b/source/gameengine/Converter/BlenderWorldInfo.h deleted file mode 100644 index 5c1cbd28104..00000000000 --- a/source/gameengine/Converter/BlenderWorldInfo.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file BlenderWorldInfo.h - * \ingroup bgeconv - */ - -#ifndef __BLENDERWORLDINFO_H__ -#define __BLENDERWORLDINFO_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; - 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]; - float m_con_mistcolor[3]; - float m_con_backgroundcolor[3]; - float m_con_ambientcolor[3]; - -public: - BlenderWorldInfo(Scene *blenderscene, World *blenderworld); - ~BlenderWorldInfo(); - - bool m_do_color_management; - bool hasWorld(); - bool hasMist(); - short getMistType(); - float getMistStart(); - float getMistDistance(); - float getMistIntensity(); - 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); - void setMistStart(float d); - void setMistDistance(float d); - 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") -#endif -}; - -#endif /* __BLENDERWORLDINFO_H__ */ diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt index 9721149314f..6d681dd166e 100644 --- a/source/gameengine/Converter/CMakeLists.txt +++ b/source/gameengine/Converter/CMakeLists.txt @@ -74,7 +74,6 @@ set(SRC BL_ShapeActionActuator.cpp BL_ShapeDeformer.cpp BL_SkinDeformer.cpp - BlenderWorldInfo.cpp KX_BlenderScalarInterpolator.cpp KX_BlenderSceneConverter.cpp KX_ConvertActuators.cpp @@ -96,7 +95,6 @@ set(SRC BL_ShapeActionActuator.h BL_ShapeDeformer.h BL_SkinDeformer.h - BlenderWorldInfo.h KX_BlenderScalarInterpolator.h KX_BlenderSceneConverter.h KX_ConvertActuators.h diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 09cc74d717f..21c8f39f782 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -58,7 +58,7 @@ #include "KX_LibLoadStatus.h" #include "KX_BlenderScalarInterpolator.h" #include "BL_BlenderDataConversion.h" -#include "BlenderWorldInfo.h" +#include "KX_WorldInfo.h" /* This little block needed for linking to Blender... */ #ifdef WIN32 diff --git a/source/gameengine/Ketsji/KX_WorldInfo.cpp b/source/gameengine/Ketsji/KX_WorldInfo.cpp index 444d6b0771b..a094bffd77a 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.cpp +++ b/source/gameengine/Ketsji/KX_WorldInfo.cpp @@ -31,8 +31,220 @@ #include "KX_WorldInfo.h" +#include "KX_PythonInit.h" +#include "GPU_material.h" + +/* This little block needed for linking to Blender... */ +#ifdef WIN32 +#include "BLI_winstuff.h" +#endif + +/* This list includes only data type definitions */ +#include "DNA_scene_types.h" +#include "DNA_world_types.h" + +#include "BLI_math.h" + +#include "BKE_global.h" +#include "BKE_scene.h" +/* end of blender include block */ + + +KX_WorldInfo::KX_WorldInfo(Scene *blenderscene, World *blenderworld) +{ + if (blenderworld) { + m_do_color_management = BKE_scene_check_color_management_enabled(blenderscene); + m_hasworld = true; + m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false); + m_misttype = blenderworld->mistype; + m_miststart = blenderworld->miststa; + m_mistdistance = blenderworld->mistdist; + m_mistintensity = blenderworld->misi; + setMistColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); + setBackColor(blenderworld->horr, blenderworld->horg, blenderworld->horb); + setAmbientColor(blenderworld->ambr, blenderworld->ambg, blenderworld->ambb); + } + else { + m_hasworld = false; + } +} KX_WorldInfo::~KX_WorldInfo() { } +bool KX_WorldInfo::hasWorld() +{ + return m_hasworld; +} + +bool KX_WorldInfo::hasMist() +{ + return m_hasmist; +} + +float KX_WorldInfo::getBackColorRed() +{ + return m_backgroundcolor[0]; +} + +float KX_WorldInfo::getBackColorGreen() +{ + return m_backgroundcolor[1]; +} + +float KX_WorldInfo::getBackColorBlue() +{ + return m_backgroundcolor[2]; +} + +float KX_WorldInfo::getAmbientColorRed() +{ + return m_ambientcolor[0]; +} + +float KX_WorldInfo::getAmbientColorGreen() +{ + return m_ambientcolor[1]; +} + +float KX_WorldInfo::getAmbientColorBlue() +{ + return m_ambientcolor[2]; +} + +short KX_WorldInfo::getMistType() +{ + return m_misttype; +} + +float KX_WorldInfo::getMistStart() +{ + return m_miststart; +} + +float KX_WorldInfo::getMistDistance() +{ + return m_mistdistance; +} + +float KX_WorldInfo::getMistIntensity() +{ + return m_mistintensity; +} + +float KX_WorldInfo::getMistColorRed() +{ + return m_mistcolor[0]; +} + +float KX_WorldInfo::getMistColorGreen() +{ + return m_mistcolor[1]; +} + +float KX_WorldInfo::getMistColorBlue() +{ + return m_mistcolor[2]; +} + +void KX_WorldInfo::setBackColor(float r, float g, float b) +{ + m_backgroundcolor[0] = r; + m_backgroundcolor[1] = g; + m_backgroundcolor[2] = b; + + if (m_do_color_management) { + linearrgb_to_srgb_v3_v3(m_con_backgroundcolor, m_backgroundcolor); + } + else { + copy_v3_v3(m_con_backgroundcolor, m_backgroundcolor); + } +} + +void KX_WorldInfo::setMistType(short type) +{ + m_misttype = type; +} + +void KX_WorldInfo::setUseMist(bool enable) +{ + m_hasmist = enable; +} + +void KX_WorldInfo::setMistStart(float d) +{ + m_miststart = d; +} + +void KX_WorldInfo::setMistDistance(float d) +{ + m_mistdistance = d; +} + +void KX_WorldInfo::setMistIntensity(float intensity) +{ + m_mistintensity = intensity; +} +void KX_WorldInfo::setMistColor(float r, float g, float b) +{ + m_mistcolor[0] = r; + m_mistcolor[1] = g; + m_mistcolor[2] = b; + + if (m_do_color_management) { + linearrgb_to_srgb_v3_v3(m_con_mistcolor, m_mistcolor); + } + else { + copy_v3_v3(m_con_mistcolor, m_mistcolor); + } +} + +void KX_WorldInfo::setAmbientColor(float r, float g, float b) +{ + m_ambientcolor[0] = r; + m_ambientcolor[1] = g; + m_ambientcolor[2] = b; + + if (m_do_color_management) { + linearrgb_to_srgb_v3_v3(m_con_ambientcolor, m_ambientcolor); + } + else { + copy_v3_v3(m_con_ambientcolor, m_ambientcolor); + } +} + +void KX_WorldInfo::UpdateBackGround() +{ + if (m_hasworld) { + RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer(); + + if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID) { + m_rasterizer->SetBackColor(m_con_backgroundcolor); + GPU_horizon_update_color(m_backgroundcolor); + } + } +} + +void KX_WorldInfo::UpdateWorldSettings() +{ + if (m_hasworld) { + RAS_IRasterizer *m_rasterizer = KX_GetActiveEngine()->GetRasterizer(); + + if (m_rasterizer->GetDrawingMode() >= RAS_IRasterizer::KX_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); + } + } + } +} diff --git a/source/gameengine/Ketsji/KX_WorldInfo.h b/source/gameengine/Ketsji/KX_WorldInfo.h index a6f93dd80ba..4abcfb98892 100644 --- a/source/gameengine/Ketsji/KX_WorldInfo.h +++ b/source/gameengine/Ketsji/KX_WorldInfo.h @@ -33,15 +33,34 @@ #define __KX_WORLDINFO_H__ #include "MT_Scalar.h" +#include "KX_KetsjiEngine.h" +#include "RAS_IRasterizer.h" #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" #endif -class MT_CmMatrix4x4; +struct Scene; +struct World; +const class KX_KetsjiEngine; +const class RAS_IRasterizer; class KX_WorldInfo { + bool m_do_color_management; + bool m_hasworld; + 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]; + float m_con_mistcolor[3]; + float m_con_backgroundcolor[3]; + float m_con_ambientcolor[3]; + public: /** * Mist options @@ -52,34 +71,34 @@ public: KX_MIST_INV_QUADRATIC, }; - KX_WorldInfo() {} - virtual ~KX_WorldInfo(); + KX_WorldInfo(Scene *blenderscene, World *blenderworld); + ~KX_WorldInfo(); - virtual bool hasWorld() = 0; - virtual bool hasMist() = 0; - virtual short getMistType() = 0; - virtual float getMistStart() = 0; - virtual float getMistDistance() = 0; - virtual float getMistIntensity() = 0; - virtual float getMistColorRed() = 0; - virtual float getMistColorGreen() = 0; - virtual float getMistColorBlue() = 0; - virtual float getBackColorRed() = 0; - virtual float getBackColorGreen() = 0; - virtual float getBackColorBlue() = 0; - virtual float getAmbientColorRed() = 0; - virtual float getAmbientColorGreen() = 0; - virtual float getAmbientColorBlue() = 0; - virtual void setUseMist(bool enable) = 0; - virtual void setMistType(short) = 0; - virtual void setMistStart(float) = 0; - virtual void setMistDistance(float) = 0; - virtual void setMistIntensity(float) = 0; - virtual void setMistColor(float, float, float) = 0; - virtual void setBackColor(float, float, float) = 0; - virtual void setAmbientColor(float,float,float) = 0; - virtual void UpdateBackGround() = 0; - virtual void UpdateWorldSettings() = 0; + bool hasWorld(); + bool hasMist(); + short getMistType(); + float getMistStart(); + float getMistDistance(); + float getMistIntensity(); + float getMistColorRed(); + float getMistColorGreen(); + float getMistColorBlue(); + float getBackColorRed(); + float getBackColorGreen(); + float getBackColorBlue(); + float getAmbientColorRed(); + float getAmbientColorGreen(); + float getAmbientColorBlue(); + void setUseMist(bool enable); + void setMistType(short type); + void setMistStart(float d); + void setMistDistance(float d); + void setMistIntensity(float intensity); + void setMistColor(float r, float g, float b); + void setBackColor(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:KX_WorldInfo") -- cgit v1.2.3