Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-01-11 01:03:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-01-11 01:03:26 +0300
commitaffe84a4536c6b7966aee227ae01edbf0861c60b (patch)
treeba39edeb7d497cd803bd173517f0169caf2dd09e /source/gameengine/Ketsji/KX_PythonInit.cpp
parent34794eafe495586761af883b292c16a939d17df8 (diff)
get rid of annoying duplicate python initialization code, added setupGamePython() which initializes modules
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index ed422b81ec6..cd0bcefff3b 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -1926,6 +1926,38 @@ void exitGamePythonScripting()
PyObjectPlus::ClearDeprecationWarning();
}
+/* similar to the above functions except it sets up the namespace
+ * and other more general things */
+void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene* startscene, Main *blenderdata, PyObject * pyGlobalDict, PyObject **gameLogic, PyObject **gameLogic_keys, int argc, char** argv)
+{
+ PyObject* dictionaryobject;
+
+ if(argv) /* player only */
+ dictionaryobject= initGamePlayerPythonScripting("Ketsji", psl_Lowest, blenderdata, argc, argv);
+ else
+ dictionaryobject= initGamePythonScripting("Ketsji", psl_Lowest, blenderdata);
+
+ ketsjiengine->SetPyNamespace(dictionaryobject);
+ initRasterizer(ketsjiengine->GetRasterizer(), ketsjiengine->GetCanvas());
+ *gameLogic = initGameLogic(ketsjiengine, startscene);
+
+ /* is set in initGameLogic so only set here if we want it to persist between scenes */
+ if(pyGlobalDict)
+ PyDict_SetItemString(PyModule_GetDict(*gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
+
+ *gameLogic_keys = PyDict_Keys(PyModule_GetDict(*gameLogic));
+ PyDict_SetItemString(dictionaryobject, "GameLogic", *gameLogic); // Same as importing the module.
+
+ initGameKeys();
+ initPythonConstraintBinding();
+ initMathutils();
+ initGeometry();
+ initBGL();
+
+#ifdef WITH_FFMPEG
+ initVideoTexture();
+#endif
+}
static struct PyModuleDef Rasterizer_module_def = {
{}, /* m_base */