BGE: When dynamically loading scenes (bge.logic.LibLoad()) in GLSL mode, the lights...
authorMitchell Stokes <mogurijin@gmail.com>
Wed, 16 Jun 2010 19:07:20 +0000 (19:07 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Wed, 16 Jun 2010 19:07:20 +0000 (19:07 +0000)
source/gameengine/Ketsji/BL_BlenderShader.h
source/gameengine/Ketsji/KX_BlenderMaterial.h
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Rasterizer/RAS_BucketManager.cpp
source/gameengine/Rasterizer/RAS_BucketManager.h

index 400c355bd0af299eac95835be1845dc9e10ffe5b..c2d4245b77f9a0640e4db2e09ad9c9eb4e15bae4 100644 (file)
@@ -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);
        
        
index c5f5e23c6e7f57bc4070f83496f04d04f29d27e4..e28c43d1a23a30822e6aa7a603a1a1f418f4b695 100644 (file)
@@ -89,6 +89,7 @@ public:
        virtual void Replace_IScene(SCA_IScene *val)
        {
                mScene= static_cast<KX_Scene *>(val);
+               mBlenderShader->SetScene(mScene);
        };
 
 #ifndef DISABLE_PYTHON
index d72fef166e643eb1214e37fafb9737f897cdd0b3..99bec8159b42738be71bdf507f1d8459d705dbd1 100644 (file)
@@ -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);
index 4c22f4dcfc7b5f3dfffa8754d87fa2faf196c058..32fb1e31780437358ffc2964a962a638169c4e7b 100644 (file)
@@ -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());
index 9edac8dcdc8f17daa1981ca3cea496fea4a0c56c..487df50802c1cf87669a97ddd06e5dbb60dca95b 100644 (file)
@@ -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;};