- rather then passing the python namespace dictionary to the controller function...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 29 Sep 2009 22:49:33 +0000 (22:49 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 29 Sep 2009 22:49:33 +0000 (22:49 +0000)
- renamed SetPythonDictionary() to SetPyNamespace()
- remove IsLight(), GetGameObjectType() existed before this but wasnt used for lights.

17 files changed:
source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Converter/BL_BlenderDataConversion.cpp
source/gameengine/Converter/BL_BlenderDataConversion.h
source/gameengine/Converter/KX_BlenderSceneConverter.cpp
source/gameengine/Converter/KX_BlenderSceneConverter.h
source/gameengine/Converter/KX_ConvertControllers.cpp
source/gameengine/Converter/KX_ConvertControllers.h
source/gameengine/GameLogic/SCA_IObject.h
source/gameengine/GameLogic/SCA_PythonController.cpp
source/gameengine/GameLogic/SCA_PythonController.h
source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/Ketsji/KX_GameObject.h
source/gameengine/Ketsji/KX_ISceneConverter.h
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
source/gameengine/Ketsji/KX_KetsjiEngine.h
source/gameengine/Ketsji/KX_Light.h
source/gameengine/Ketsji/KX_Scene.cpp

index 5b825899739ea3028e003ec4e6608338278e777f..df7f35d777317261cc9da66147c91da3ea669f7d 100644 (file)
@@ -375,7 +375,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw
 #ifndef DISABLE_PYTHON
                        // some python things
                        PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata);
-                       ketsjiengine->SetPythonDictionary(dictionaryobject);
+                       ketsjiengine->SetPyNamespace(dictionaryobject);
                        initRasterizer(rasterizer, canvas);
                        PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
                        PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
@@ -406,9 +406,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw
                                // convert and add scene
                                sceneconverter->ConvertScene(
                                        startscene,
-#ifndef DISABLE_PYTHON
-                                       dictionaryobject,
-#endif
                                        rendertools,
                                        canvas);
                                ketsjiengine->AddScene(startscene);
@@ -702,7 +699,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
 #ifndef DISABLE_PYTHON
                        // some python things
                        PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata);
-                       ketsjiengine->SetPythonDictionary(dictionaryobject);
+                       ketsjiengine->SetPyNamespace(dictionaryobject);
                        initRasterizer(rasterizer, canvas);
                        PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
                        PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
@@ -721,9 +718,6 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win,
                                // convert and add scene
                                sceneconverter->ConvertScene(
                                        startscene,
-#ifndef DISABLE_PYTHON
-                                       dictionaryobject,
-#endif
                                        rendertools,
                                        canvas);
                                ketsjiengine->AddScene(startscene);
index 8310294a73aa555b0ba9910890787d76d77021b2..db32f18f63b77e8836544522a1071e64ea33f3b7 100644 (file)
@@ -1897,9 +1897,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                          KX_Scene* kxscene,
                                                          KX_KetsjiEngine* ketsjiEngine,
                                                          e_PhysicsEngine       physics_engine,
-#ifndef DISABLE_PYTHON
-                                                         PyObject* pythondictionary,
-#endif
                                                          RAS_IRenderTools* rendertools,
                                                          RAS_ICanvas* canvas,
                                                          KX_BlenderSceneConverter* converter,
@@ -2655,11 +2652,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                struct Object* blenderobj = gameobj->GetBlenderObject();
                int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
                bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
-               BL_ConvertControllers(blenderobj,gameobj,logicmgr,
-#ifndef DISABLE_PYTHON
-                               pythondictionary,
-#endif
-                               layerMask,isInActiveLayer,converter);
+               BL_ConvertControllers(blenderobj,gameobj,logicmgr, layerMask,isInActiveLayer,converter);
        }
        for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
        {
index 96ef7d5bc7767a641581e39cc8640ebeabfd00c2..218b296b47bba9cf3ae62d7e6ac65e6711dbb714 100644 (file)
@@ -40,9 +40,6 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
                                                          class KX_Scene* kxscene,
                                                          class KX_KetsjiEngine* ketsjiEngine,
                                                          e_PhysicsEngine       physics_engine,
-#ifndef DISABLE_PYTHON
-                                                         PyObject* pythondictionary,
-#endif
                                                          class RAS_IRenderTools* rendertools,
                                                          class RAS_ICanvas* canvas, 
                                                          class KX_BlenderSceneConverter* sceneconverter, 
index f0f5e1d4f4121a9f7e2ffbec65f4ec4cf13142e8..26b4514061c808a86039ed2e3566b28a2743ed50 100644 (file)
@@ -243,9 +243,6 @@ struct      BlenderDebugDraw : public btIDebugDraw
 #endif
 
 void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
-#ifndef DISABLE_PYTHON
-                                                                                       PyObject* dictobj,
-#endif
                                                                                        class RAS_IRenderTools* rendertools,
                                                                                        class RAS_ICanvas* canvas)
 {
@@ -330,9 +327,6 @@ void KX_BlenderSceneConverter::ConvertScene(class KX_Scene* destinationscene,
                destinationscene,
                m_ketsjiEngine,
                physics_engine,
-#ifndef DISABLE_PYTHON
-               dictobj,
-#endif
                rendertools,
                canvas,
                this,
@@ -924,3 +918,10 @@ void       KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
 
 
 }
+
+#ifndef DISABLE_PYTHON
+PyObject *KX_BlenderSceneConverter::GetPyNamespace()
+{
+       return m_ketsjiEngine->GetPyNamespace();
+}
+#endif
index fa066aac27e849cab9725c2a6ce1d8382626bf95..f74944d3552ffce67ba451a032358b1f89816f2b 100644 (file)
@@ -89,9 +89,6 @@ public:
         */
        virtual void    ConvertScene(
                                                class KX_Scene* destinationscene,
-#ifndef DISABLE_PYTHON
-                                               PyObject* dictobj,
-#endif
                                                class RAS_IRenderTools* rendertools,
                                                class RAS_ICanvas* canvas
                                        );
@@ -145,6 +142,9 @@ public:
 
        struct Main* GetMain() { return m_maggie; };
 
+#ifndef DISABLE_PYTHON
+       PyObject *GetPyNamespace();
+#endif
        
 #ifdef WITH_CXX_GUARDEDALLOC
 public:
index 1cb15c932ac45b3d18733605d308a0885110235e..faef0feaf48c88e7cdf01dbdbeb01d7e03639d71 100644 (file)
@@ -92,9 +92,6 @@ void BL_ConvertControllers(
        struct Object* blenderobject,
        class KX_GameObject* gameobj,
        SCA_LogicManager* logicmgr,
-#ifndef DISABLE_PYTHON
-       PyObject* pythondictionary,
-#endif
        int activeLayerBitInfo,
        bool isInActiveLayer,
        KX_BlenderSceneConverter* converter
@@ -160,10 +157,9 @@ void BL_ConvertControllers(
                                bPythonCont* pycont = (bPythonCont*) bcontr->data;
                                SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode);
                                gamecontroller = pyctrl;
-                               
 #ifndef DISABLE_PYTHON
 
-                               pyctrl->SetDictionary(pythondictionary);
+                               pyctrl->SetNamespace(converter->GetPyNamespace());
                                
                                if(pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) {
                                        if (pycont->text)
index 3895ed2c87366a4826c61a893b5986803a14590e..2689ad446bd1aa16d618a396fa15a9158bc90739 100644 (file)
@@ -35,9 +35,6 @@ void BL_ConvertControllers(
        struct Object* blenderobject,
        class KX_GameObject* gameobj,
        class SCA_LogicManager* logicmgr,
-#ifndef DISABLE_PYTHON
-       PyObject* pythondictionary,
-#endif
        int activeLayerBitInfo,
        bool isInActiveLayer, 
        class KX_BlenderSceneConverter* converter
index 60335f8fe01dd479787373e335eb273e21635833..f078e12937804fa6726500a14c683c2cdff58cff 100644 (file)
@@ -219,6 +219,7 @@ public:
        typedef enum ObjectTypes {
                OBJ_ARMATURE=0,
                OBJ_CAMERA=1,
+               OBJ_LIGHT=2,
        }ObjectTypes;
 
 };
index 3a70d1485dcee7343ed9ae9d23f7236159c1aa9c..ac3e0434d20f3e20a8974ef3a722fa1897f8242d 100644 (file)
@@ -151,7 +151,7 @@ void SCA_PythonController::SetScriptName(const STR_String& name)
 
 
 #ifndef DISABLE_PYTHON
-void SCA_PythonController::SetDictionary(PyObject*     pythondictionary)
+void SCA_PythonController::SetNamespace(PyObject*      pythondictionary)
 {
        if (m_pythondictionary)
        {
index f6a1064b77df9d96c9ae20a0b5e7c5953f0c24ef..eeac710c6ea686e6b0998f165a7b436f7c0cf898 100644 (file)
@@ -84,7 +84,7 @@ class SCA_PythonController : public SCA_IController
        void    SetScriptText(const STR_String& text);
        void    SetScriptName(const STR_String& name);
 #ifndef DISABLE_PYTHON
-       void    SetDictionary(PyObject* pythondictionary);
+       void    SetNamespace(PyObject*  pythondictionary);
 #endif
        void    SetDebug(bool debug) { m_debug = debug; }
        void    AddTriggeredSensor(class SCA_ISensor* sensor)
index 8ec41968042e8160016ab1148199131bbc55bf04..3c989293c948686473ffd1ca7cfd5b93ce42b249 100644 (file)
@@ -679,7 +679,7 @@ bool GPG_Application::startEngine(void)
                
                // some python things
                PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest, m_maggie, m_argc, m_argv);
-               m_ketsjiengine->SetPythonDictionary(dictionaryobject);
+               m_ketsjiengine->SetPyNamespace(dictionaryobject);
                initRasterizer(m_rasterizer, m_canvas);
                PyObject *gameLogic = initGameLogic(m_ketsjiengine, startscene);
                PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
@@ -702,7 +702,6 @@ bool GPG_Application::startEngine(void)
                
                m_sceneconverter->ConvertScene(
                        startscene,
-                       dictionaryobject,
                        m_rendertools,
                        m_canvas);
                m_ketsjiengine->AddScene(startscene);
index 48ba573e01b4961dc802a20ec7bd9feb6d5a97ae..41e04eef91c177b0a1c8fc19d525bcb617ec1cd4 100644 (file)
@@ -748,14 +748,6 @@ public:
                void
        ) { return m_bIsNegativeScaling; }
 
-       /**
-        * Is this a light?
-        */
-               virtual bool
-       IsLight(
-               void
-       ) { return false; }
-
        /**
         * @section Logic bubbling methods.
         */
index 3c3d1d700c4bce8fe9c24009fbfe593555b4d848..e5b7c777fb4d746c2ac58c4ad52dd8e28c72c117 100644 (file)
@@ -53,9 +53,6 @@ public:
        */
        virtual void ConvertScene(
                class KX_Scene* destinationscene,
-#ifndef DISABLE_PYTHON
-               PyObject* dictobj,
-#endif
                class RAS_IRenderTools* rendertools, 
                class RAS_ICanvas*  canvas)=0;
        
index 734b74b7456cfbd1a0a009f6355bae61bb430c68..9f4fa9a7c02072ed984f4d2da35d9d3eb0cf2d88 100644 (file)
@@ -238,7 +238,7 @@ void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer)
  * At the moment the GameLogic module is imported into 'pythondictionary' after this function is called.
  * if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand.
  */
-void KX_KetsjiEngine::SetPythonDictionary(PyObject* pythondictionary)
+void KX_KetsjiEngine::SetPyNamespace(PyObject* pythondictionary)
 {
        MT_assert(pythondictionary);
        m_pythondictionary = pythondictionary;
@@ -1618,9 +1618,6 @@ KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename)
                                                                          scene);
 
        m_sceneconverter->ConvertScene(tmpscene,
-#ifndef DISABLE_PYTHON
-                                                         m_pythondictionary,
-#endif
                                                          m_rendertools,
                                                          m_canvas);
 
index 9cfca850bf3ef9d0e9486978dec0f33294d8a8e4..74d683fbad6eb8a27fd4889822867de0398281d5 100644 (file)
@@ -204,7 +204,8 @@ public:
        void                    SetRenderTools(RAS_IRenderTools* rendertools);
        void                    SetRasterizer(RAS_IRasterizer* rasterizer);
 #ifndef DISABLE_PYTHON
-       void                    SetPythonDictionary(PyObject* pythondictionary);
+       void                    SetPyNamespace(PyObject* pythondictionary);
+       PyObject*               GetPyNamespace(){return m_pythondictionary;};
 #endif
        void                    SetSceneConverter(KX_ISceneConverter* sceneconverter);
        void                    SetGame2IpoMode(bool game2ipo,int startFrame);
index 74d8abcfeacdb645eef1227f7987d0ee475b1a49..0e8484a4fe548e743af2feaa29ecec9337c35823 100644 (file)
@@ -64,6 +64,8 @@ public:
        void BindShadowBuffer(class RAS_IRasterizer *ras, class KX_Camera *cam, class MT_Transform& camtrans);
        void UnbindShadowBuffer(class RAS_IRasterizer *ras);
        void Update();
+       
+       virtual int GetGameObjectType() { return OBJ_LIGHT; }
 
 #ifndef DISABLE_PYTHON
        /* attributes */
@@ -73,8 +75,6 @@ public:
        static PyObject*        pyattr_get_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
        static int                      pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject* value);
 #endif
-
-       virtual bool IsLight(void) { return true; }
 };
 
 #endif //__KX_LIGHT
index 94f62b5b4b60bc210b32125c8d52751f6a4e6ef2..c93ead741822c111cb7dfd244ccb62845a81169f 100644 (file)
@@ -477,7 +477,7 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
 
        // this is the list of object that are send to the graphics pipeline
        m_objectlist->Add(newobj->AddRef());
-       if (newobj->IsLight())
+       if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT)
                m_lightlist->Add(newobj->AddRef());
        newobj->AddMeshUser();
 
@@ -753,7 +753,7 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
                // add the object in the layer of the parent
                (*git)->SetLayer(groupobj->GetLayer());
                // If the object was a light, we need to update it's RAS_LightObject as well
-               if ((*git)->IsLight())
+               if ((*git)->GetGameObjectType()==SCA_IObject::OBJ_LIGHT)
                {
                        KX_LightObject* lightobj = static_cast<KX_LightObject*>(*git);
                        lightobj->GetLightData()->m_layer = groupobj->GetLayer();
@@ -861,7 +861,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
                // add the object in the layer of the parent
                (*git)->SetLayer(parentobj->GetLayer());
                // If the object was a light, we need to update it's RAS_LightObject as well
-               if ((*git)->IsLight())
+               if ((*git)->GetGameObjectType()==SCA_IObject::OBJ_LIGHT)
                {
                        KX_LightObject* lightobj = static_cast<KX_LightObject*>(*git);
                        lightobj->GetLightData()->m_layer = parentobj->GetLayer();
@@ -982,7 +982,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj)
        
        newobj->RemoveMeshes();
        ret = 1;
-       if (newobj->IsLight() && m_lightlist->RemoveValue(newobj))
+       if (newobj->GetGameObjectType()==SCA_IObject::OBJ_LIGHT && m_lightlist->RemoveValue(newobj))
                ret = newobj->Release();
        if (m_objectlist->RemoveValue(newobj))
                ret = newobj->Release();