Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Converter/BlenderWorldInfo.cpp
| Show All 27 Lines | |||||
| /** \file gameengine/Converter/BlenderWorldInfo.cpp | /** \file gameengine/Converter/BlenderWorldInfo.cpp | ||||
| * \ingroup bgeconv | * \ingroup bgeconv | ||||
| */ | */ | ||||
| #include <stdio.h> // printf() | #include <stdio.h> // printf() | ||||
| #include "BlenderWorldInfo.h" | #include "BlenderWorldInfo.h" | ||||
| #include "KX_PythonInit.h" | |||||
| #include "GPU_material.h" | |||||
| /* This little block needed for linking to Blender... */ | /* This little block needed for linking to Blender... */ | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| #include "BLI_winstuff.h" | #include "BLI_winstuff.h" | ||||
| #endif | #endif | ||||
| /* This list includes only data type definitions */ | /* 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_world_types.h" | ||||
| #include "DNA_screen_types.h" | |||||
| #include "BLI_math.h" | #include "BLI_math.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_scene.h" | #include "BKE_scene.h" | ||||
| /* end of blender include block */ | /* end of blender include block */ | ||||
| BlenderWorldInfo::BlenderWorldInfo(struct Scene *blenderscene, struct World *blenderworld) | BlenderWorldInfo::BlenderWorldInfo(Scene *blenderscene, World *blenderworld) | ||||
| { | { | ||||
| if (blenderworld) { | if (blenderworld) { | ||||
| m_hasworld = true; | m_hasworld = true; | ||||
| m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false); | m_hasmist = ((blenderworld->mode) & WO_MIST ? true : false); | ||||
| m_misttype = blenderworld->mistype; | m_misttype = blenderworld->mistype; | ||||
| m_miststart = blenderworld->miststa; | m_miststart = blenderworld->miststa; | ||||
brecht: I personally wouldn't put these in member variables, you never know when some code is added… | |||||
Not Done Inline ActionsUpdateBackGround() and UpdateWorldSettings() is called every frame (necessary if we have multiple scenes running). hg1: UpdateBackGround() and UpdateWorldSettings() is called every frame (necessary if we have… | |||||
Not Done Inline ActionsIt actually wont be that slow to do the calls. Modern processors and compilers handle functions calls pretty well these days. Having the drawtype fixed at construction is particularly problematic, as this does change during execution for shadows. moguri: It actually wont be that slow to do the calls. Modern processors and compilers handle functions… | |||||
Not Done Inline ActionsOK. I will change that. hg1: OK. I will change that. | |||||
| m_mistdistance = blenderworld->mistdist; | m_mistdistance = blenderworld->mistdist; | ||||
| m_mistintensity = blenderworld->misi; | m_mistintensity = blenderworld->misi; | ||||
| copy_v3_v3(m_mistcolor, &blenderworld->horr); | copy_v3_v3(m_mistcolor, &blenderworld->horr); | ||||
| copy_v3_v3(m_backgroundcolor, &blenderworld->horr); | copy_v3_v3(m_backgroundcolor, &blenderworld->horr); | ||||
| copy_v3_v3(m_ambientcolor, &blenderworld->ambr); | copy_v3_v3(m_ambientcolor, &blenderworld->ambr); | ||||
| if (BKE_scene_check_color_management_enabled(blenderscene)) { | if (BKE_scene_check_color_management_enabled(blenderscene)) { | ||||
| linearrgb_to_srgb_v3_v3(m_mistcolor, m_mistcolor); | linearrgb_to_srgb_v3_v3(m_mistcolor, m_mistcolor); | ||||
| ▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| void BlenderWorldInfo::setAmbientColor(float r, float g, float b) | void BlenderWorldInfo::setAmbientColor(float r, float g, float b) | ||||
| { | { | ||||
| m_ambientcolor[0] = r; | m_ambientcolor[0] = r; | ||||
| m_ambientcolor[1] = g; | m_ambientcolor[1] = g; | ||||
| m_ambientcolor[2] = b; | 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); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
I personally wouldn't put these in member variables, you never know when some code is added that might make these change dynamically, generally I wouldn't copy that kind of state around when I can avoid it.