From 82c845425f0a5e2805ed7e9f6cb74920fa96229f Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Sat, 17 Aug 2013 04:37:25 +0000 Subject: BGE: Adding partial support for LibLoaded lights with GLSL materials. Any GLSL materials loaded after lights are LibLoaded will now use the lights in heir shaders. This includes materials loaded from the same scene as the LibLoaded lights. We could later add a new flag to LibLoad to recompile all existing shaders, but this commit should offer a lot more flexibility as is. --- source/gameengine/Ketsji/KX_Light.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/gameengine/Ketsji/KX_Light.cpp') diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index a8f309cc592..0e4db0d351e 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -48,6 +48,9 @@ #include "DNA_scene_types.h" #include "DNA_lamp_types.h" #include "GPU_material.h" + +#include "BKE_scene.h" +#include "MEM_guardedalloc.h" KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, class RAS_IRenderTools* rendertools, @@ -62,6 +65,7 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks, m_rendertools->AddLight(&m_lightobj); m_glsl = glsl; m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene(); + m_base = NULL; }; @@ -78,6 +82,11 @@ KX_LightObject::~KX_LightObject() } m_rendertools->RemoveLight(&m_lightobj); + + if (m_base) { + BKE_scene_base_unlink(m_blenderscene, m_base); + MEM_freeN(m_base); + } } @@ -216,6 +225,13 @@ void KX_LightObject::Update() } } +void KX_LightObject::UpdateScene(KX_Scene *kxscene) +{ + m_lightobj.m_scene = (void*)kxscene; + m_blenderscene = kxscene->GetBlenderScene(); + m_base = BKE_scene_base_add(m_blenderscene, GetBlenderObject()); +} + bool KX_LightObject::HasShadowBuffer() { GPULamp *lamp; -- cgit v1.2.3