diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2010-06-16 23:07:20 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2010-06-16 23:07:20 +0400 |
commit | 08a94f9bbdf74a2d87da5908d919d018445ca222 (patch) | |
tree | ec1e5dfe666f373a4582084bafc4e9923d42ba95 | |
parent | dd3513e3622ab09db5b619a061db43f6b5447380 (diff) |
BGE: When dynamically loading scenes (bge.logic.LibLoad()) in GLSL mode, the lights in the loaded scene would not affect the current scene and vice versa. To fix this, I've updated to merge code to update the scenes that the shaders are using to the scene being merged into.
-rw-r--r-- | source/gameengine/Ketsji/BL_BlenderShader.h | 7 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_BlenderMaterial.h | 1 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_BucketManager.cpp | 10 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_BucketManager.h | 2 |
5 files changed, 19 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h index 400c355bd0a..c2d4245b77f 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.h +++ b/source/gameengine/Ketsji/BL_BlenderShader.h @@ -56,6 +56,13 @@ public: void ReloadMaterial(); int GetBlendMode(); + void SetScene(KX_Scene *scene) + { + mScene = scene; + mBlenderScene = scene->GetBlenderScene(); + ReloadMaterial(); + } + bool Equals(BL_BlenderShader *blshader); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h index c5f5e23c6e7..e28c43d1a23 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.h +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h @@ -89,6 +89,7 @@ public: virtual void Replace_IScene(SCA_IScene *val) { mScene= static_cast<KX_Scene *>(val); + mBlenderShader->SetScene(mScene); }; #ifndef DISABLE_PYTHON diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index d72fef166e6..99bec8159b4 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1754,7 +1754,7 @@ bool KX_Scene::MergeScene(KX_Scene *other) } - GetBucketManager()->MergeBucketManager(other->GetBucketManager()); + GetBucketManager()->MergeBucketManager(other->GetBucketManager(), this); /* move materials across, assume they both use the same scene-converters */ GetSceneConverter()->MergeScene(this, other); diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 4c22f4dcfc7..32fb1e31780 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -346,13 +346,21 @@ void RAS_BucketManager::RemoveMaterial(RAS_IPolyMaterial * mat) //#include <stdio.h> -void RAS_BucketManager::MergeBucketManager(RAS_BucketManager *other) +void RAS_BucketManager::MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene) { /* concatinate lists */ // printf("BEFORE %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size()); + BucketList::iterator it; + + for (it = other->GetSolidBuckets().begin(); it != other->GetSolidBuckets().end(); ++it) + (*it)->GetPolyMaterial()->Replace_IScene(scene); + GetSolidBuckets().insert( GetSolidBuckets().end(), other->GetSolidBuckets().begin(), other->GetSolidBuckets().end() ); other->GetSolidBuckets().clear(); + for (it = other->GetAlphaBuckets().begin(); it != other->GetAlphaBuckets().end(); ++it) + (*it)->GetPolyMaterial()->Replace_IScene(scene); + GetAlphaBuckets().insert( GetAlphaBuckets().end(), other->GetAlphaBuckets().begin(), other->GetAlphaBuckets().end() ); other->GetAlphaBuckets().clear(); //printf("AFTER %d %d\n", GetSolidBuckets().size(), GetAlphaBuckets().size()); diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index 9edac8dcdc8..487df50802c 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -63,7 +63,7 @@ public: void RemoveMaterial(RAS_IPolyMaterial * mat); // freeing scenes only /* for merging */ - void MergeBucketManager(RAS_BucketManager *other); + void MergeBucketManager(RAS_BucketManager *other, SCA_IScene *scene); BucketList & GetSolidBuckets() {return m_SolidBuckets;}; BucketList & GetAlphaBuckets() {return m_AlphaBuckets;}; |