diff options
Diffstat (limited to 'source/gameengine/BlenderRoutines')
-rw-r--r-- | source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp | 41 | ||||
-rw-r--r-- | source/gameengine/BlenderRoutines/CMakeLists.txt | 7 | ||||
-rw-r--r-- | source/gameengine/BlenderRoutines/SConscript | 6 |
3 files changed, 41 insertions, 13 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 1ede16f017e..df7f35d7773 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,10 +371,11 @@ 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); + ketsjiengine->SetPyNamespace(dictionaryobject); initRasterizer(rasterizer, canvas); PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module. @@ -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,6 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, int alw // convert and add scene sceneconverter->ConvertScene( startscene, - dictionaryobject, rendertools, canvas); ketsjiengine->AddScene(startscene); @@ -468,7 +475,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 +495,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 +507,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 +566,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 +595,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,9 +696,10 @@ 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); + ketsjiengine->SetPyNamespace(dictionaryobject); initRasterizer(rasterizer, canvas); PyObject *gameLogic = initGameLogic(ketsjiengine, startscene); PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module @@ -694,13 +711,13 @@ extern "C" void StartKetsjiShellSimulation(struct wmWindow *win, #ifdef WITH_FFMPEG initVideoTexture(); #endif +#endif // DISABLE_PYTHON if (sceneconverter) { // convert and add scene sceneconverter->ConvertScene( startscene, - dictionaryobject, rendertools, canvas); ketsjiengine->AddScene(startscene); @@ -778,6 +795,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 } diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt index ce85c1185b0..f2d6528d797 100644 --- a/source/gameengine/BlenderRoutines/CMakeLists.txt +++ b/source/gameengine/BlenderRoutines/CMakeLists.txt @@ -35,12 +35,17 @@ SET(INC ../../../source/blender/gpu ../../../extern/bullet2/src ../../../extern/glew/include - ${PYTHON_INC} ) IF(WITH_FFMPEG) ADD_DEFINITIONS(-DWITH_FFMPEG) ENDIF(WITH_FFMPEG) +IF(WITH_PYTHON) + SET(INC ${INC} ${PYTHON_INC}) +ELSE(WITH_PYTHON) + ADD_DEFINITIONS(-DDISABLE_PYTHON) +ENDIF(WITH_PYTHON) + BLENDERLIB(bf_blroutines "${SRC}" "${INC}") #env.BlenderLib ( 'bf_bloutines', sources, Split(incs), [], libtype=['game', 'game2', 'player'], priority=[0, 0, 55] , compileflags=cxxflags) diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript index 1e8ff3c48e8..f076612e231 100644 --- a/source/gameengine/BlenderRoutines/SConscript +++ b/source/gameengine/BlenderRoutines/SConscript @@ -25,7 +25,11 @@ incs += ' #source/blender/windowmanager' if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') -incs += ' ' + env['BF_PYTHON_INC'] +if env['WITH_BF_PYTHON']: + incs += ' ' + env['BF_PYTHON_INC'] +else: + defs.append('DISABLE_PYTHON') + incs += ' ' + env['BF_BULLET_INC'] incs += ' ' + env['BF_OPENGL_INC'] |