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
This commit is contained in:
Thomas Szepe 2015-03-24 00:19:15 +01:00
parent ce40fb9ab2
commit 6c9502a6c1
7 changed files with 262 additions and 378 deletions

@ -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);

@ -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 <stdio.h> // 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);
}
}
}
}

@ -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__ */

@ -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

@ -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

@ -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);
}
}
}
}

@ -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")