diff options
Diffstat (limited to 'source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp')
-rw-r--r-- | source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 1ede16f017e..5b825899739 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -34,6 +34,7 @@ #include <signal.h> #include <stdlib.h> +#include <stdio.h> #ifdef WIN32 // don't show stl-warnings @@ -137,6 +138,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); BLI_strncpy(oldsce, G.sce, sizeof(oldsce)); +#ifndef DISABLE_PYTHON resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path setGamePythonPath(G.sce); @@ -145,6 +147,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw PyGILState_STATE gilstate = PyGILState_Ensure(); PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */ +#endif bgl::InitExtensions(true); @@ -206,8 +209,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); +#ifndef DISABLE_PYTHON CValue::SetDeprecationWarnings(nodepwarnings); - +#endif //lock frame and camera enabled - storing global values int tmp_lay= scene->lay; @@ -288,7 +292,9 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw if(blenderdata) { BLI_strncpy(G.sce, blenderdata->name, sizeof(G.sce)); BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); +#ifndef DISABLE_PYTHON setGamePythonPath(G.sce); +#endif } } // else forget it, we can't find it @@ -365,7 +371,8 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw networkdevice, startscenename, blscene); - + +#ifndef DISABLE_PYTHON // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); ketsjiengine->SetPythonDictionary(dictionaryobject); @@ -383,6 +390,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw #ifdef WITH_FFMPEG initVideoTexture(); #endif +#endif // DISABLE_PYTHON //initialize Dome Settings if(blscene->gm.stereoflag == STEREO_DOME) @@ -398,7 +406,9 @@ 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); @@ -468,7 +478,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw // when exiting the mainloop - +#ifndef DISABLE_PYTHON // Clears the dictionary by hand: // This prevents, extra references to global variables // inside the GameLogic dictionary when the python interpreter is finalized. @@ -488,9 +498,11 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw } Py_DECREF(gameLogic_keys_new); gameLogic_keys_new = NULL; - +#endif ketsjiengine->StopEngine(); +#ifndef DISABLE_PYTHON exitGamePythonScripting(); +#endif networkdevice->Disconnect(); } if (sceneconverter) @@ -498,9 +510,11 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw delete sceneconverter; sceneconverter = NULL; } - + +#ifndef DISABLE_PYTHON Py_DECREF(gameLogic_keys); gameLogic_keys = NULL; +#endif } //lock frame and camera enabled - restoring global values if (v3d->scenelock==0){ @@ -555,14 +569,17 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); - Py_DECREF(pyGlobalDict); - if (bfd) BLO_blendfiledata_free(bfd); BLI_strncpy(G.sce, oldsce, sizeof(G.sce)); +#ifndef DISABLE_PYTHON + Py_DECREF(pyGlobalDict); + // Release Python's GIL PyGILState_Release(gilstate); +#endif + } extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, @@ -581,9 +598,11 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, BLI_strncpy(pathname, blenderdata->name, sizeof(pathname)); +#ifndef DISABLE_PYTHON // Acquire Python's GIL (global interpreter lock) // so we can safely run Python code and API calls PyGILState_STATE gilstate = PyGILState_Ensure(); +#endif bgl::InitExtensions(true); @@ -680,6 +699,7 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, startscenename, blscene); +#ifndef DISABLE_PYTHON // some python things PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest, blenderdata); ketsjiengine->SetPythonDictionary(dictionaryobject); @@ -694,13 +714,16 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, #ifdef WITH_FFMPEG initVideoTexture(); #endif +#endif // DISABLE_PYTHON if (sceneconverter) { // convert and add scene sceneconverter->ConvertScene( startscene, +#ifndef DISABLE_PYTHON dictionaryobject, +#endif rendertools, canvas); ketsjiengine->AddScene(startscene); @@ -778,6 +801,8 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, } while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME); +#ifndef DISABLE_PYTHON // Release Python's GIL PyGILState_Release(gilstate); +#endif } |