diff options
author | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-08-23 15:30:44 +0300 |
---|---|---|
committer | Porteries Tristan <republicthunderbolt9@gmail.com> | 2015-08-23 15:34:04 +0300 |
commit | 8444f7ba2b2bbcc465b4890e2fe4d473181c0ef1 (patch) | |
tree | dc08cb1215704ad9e0f50f44560730a4168caa77 /source/gameengine | |
parent | 2672ee77a0f9b3334ccd348ff3618b8df98798b6 (diff) |
BGE: Fix T42679: Python physics environment not setted for python control script.
Diffstat (limited to 'source/gameengine')
4 files changed, 26 insertions, 7 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 4e07af9f3d8..41011cdee38 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -544,6 +544,10 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c if (python_main) { char *python_code = KX_GetPythonCode(blenderdata, python_main); if (python_code) { + // Set python environement variable. + KX_SetActiveScene(startscene); + PHY_SetActiveEnvironment(startscene->GetPhysicsEnvironment()); + ketsjinextframestate.ketsjiengine = ketsjiengine; ketsjinextframestate.C = C; ketsjinextframestate.win = win; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index c3eb07d18a1..2b357f43031 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -112,6 +112,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system) : m_startSceneName(""), m_startScene(0), m_maggie(0), + m_kxStartScene(NULL), m_exitRequested(0), m_system(system), m_mainWindow(0), @@ -714,7 +715,7 @@ bool GPG_Application::startEngine(void) m_sceneconverter = new KX_BlenderSceneConverter(m_maggie, m_ketsjiengine); if (m_sceneconverter) { - STR_String startscenename = m_startSceneName.Ptr(); + STR_String m_kxStartScenename = m_startSceneName.Ptr(); m_ketsjiengine->SetSceneConverter(m_sceneconverter); // if (always_use_expand_framing) @@ -726,17 +727,17 @@ bool GPG_Application::startEngine(void) if (m_startScene->gm.flag & GAME_NO_MATERIAL_CACHING) m_sceneconverter->SetCacheMaterials(false); - KX_Scene* startscene = new KX_Scene(m_keyboard, + m_kxStartScene = new KX_Scene(m_keyboard, m_mouse, m_networkdevice, - startscenename, + m_kxStartScenename, m_startScene, m_canvas); #ifdef WITH_PYTHON // some python things PyObject *gameLogic, *gameLogic_keys; - setupGamePython(m_ketsjiengine, startscene, m_maggie, NULL, &gameLogic, &gameLogic_keys, m_argc, m_argv); + setupGamePython(m_ketsjiengine, m_kxStartScene, m_maggie, NULL, &gameLogic, &gameLogic_keys, m_argc, m_argv); #endif // WITH_PYTHON //initialize Dome Settings @@ -755,10 +756,10 @@ bool GPG_Application::startEngine(void) loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length); #endif m_sceneconverter->ConvertScene( - startscene, + m_kxStartScene, m_rasterizer, m_canvas); - m_ketsjiengine->AddScene(startscene); + m_ketsjiengine->AddScene(m_kxStartScene); // Create a timer that is used to kick the engine if (!m_frameTimer) { @@ -771,7 +772,7 @@ bool GPG_Application::startEngine(void) // Set the animation playback rate for ipo's and actions // the framerate below should patch with FPS macro defined in blendef.h // Could be in StartEngine set the framerate, we need the scene to do this - Scene *scene= startscene->GetBlenderScene(); // needed for macro + Scene *scene= m_kxStartScene->GetBlenderScene(); // needed for macro m_ketsjiengine->SetAnimFrameRate(FPS); } diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index 2d21b50e664..b6f545c2de8 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -40,6 +40,7 @@ #include "KX_KetsjiEngine.h" class KX_KetsjiEngine; +class KX_Scene; class KX_ISceneConverter; class NG_LoopBackNetworkDeviceInterface; class RAS_IRasterizer; @@ -83,6 +84,12 @@ public: int getExitRequested(void); const STR_String& getExitString(void); GlobalSettings* getGlobalSettings(void); + + inline KX_Scene *GetStartScene() const + { + return m_kxStartScene; + } + bool StartGameEngine(int stereoMode); void StopGameEngine(); void EngineNextFrame(); @@ -118,6 +125,7 @@ protected: STR_String m_startSceneName; struct Scene* m_startScene; struct Main* m_maggie; + KX_Scene *m_kxStartScene; /* Exit state. */ int m_exitRequested; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 6ff8451f1d9..23d5b89f140 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -43,6 +43,7 @@ #include "KX_KetsjiEngine.h" #include "KX_PythonInit.h" #include "KX_PythonMain.h" +#include "KX_PyConstraintBinding.h" // for PHY_SetActiveEnvironment /********************************** * Begin Blender include block @@ -1080,6 +1081,11 @@ int main(int argc, char** argv) char *python_code = KX_GetPythonCode(maggie, python_main); if (python_code) { #ifdef WITH_PYTHON + // Set python environement variable. + KX_Scene *startscene = app.GetStartScene(); + KX_SetActiveScene(startscene); + PHY_SetActiveEnvironment(startscene->GetPhysicsEnvironment()); + gpg_nextframestate.system = system; gpg_nextframestate.app = &app; gpg_nextframestate.gs = &gs; |