diff options
author | Mitchell Stokes <mogurijin@gmail.com> | 2012-12-25 12:11:21 +0400 |
---|---|---|
committer | Mitchell Stokes <mogurijin@gmail.com> | 2012-12-25 12:11:21 +0400 |
commit | f1270153e1efcd2c6ca1370a06691b0ccb3a9686 (patch) | |
tree | 2a3531200a7024d91882dd3bda60cb5d307781b6 /source | |
parent | a418dfb98c34914fde81bdde9b10967fd05ae648 (diff) |
BGE: Some various tweaks to try and get async lib loading to be a bit more stable on more complex scenes.
Diffstat (limited to 'source')
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 10 | ||||
-rw-r--r-- | source/gameengine/Converter/KX_ConvertControllers.cpp | 6 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Scene.cpp | 23 |
3 files changed, 27 insertions, 12 deletions
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index d0d6f9cb81c..a873f8ba281 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -1349,11 +1349,7 @@ static float my_boundbox_mesh(Mesh *me, float *loc, float *size) int a; if (me->bb==0) { - // This can be called in a seperate (not main) thread when doing async libload, - // so lets try to be safe... - BLI_begin_threaded_malloc(); - me->bb= (struct BoundBox *)MEM_callocN(sizeof(BoundBox), "boundbox"); - BLI_end_threaded_malloc(); + me->bb = BKE_boundbox_alloc_unit(); } bb= me->bb; @@ -2364,6 +2360,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie, set<Object*> allblobj; // all objects converted set<Object*> groupobj; // objects from groups (never in active layer) + // This is bad, but we use this to make sure the first time this is called + // is not in a separate thread. + BL_Texture::GetMaxUnits(); + if (alwaysUseExpandFraming) { frame_type = RAS_FrameSettings::e_frame_extend; aspect_width = canvas->GetWidth(); diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 769abd01ce0..5d3d0f33bec 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -157,7 +157,7 @@ void BL_ConvertControllers( SCA_PythonController* pyctrl = new SCA_PythonController(gameobj, pycont->mode); gamecontroller = pyctrl; #ifdef WITH_PYTHON - + PyGILState_STATE gstate = PyGILState_Ensure(); pyctrl->SetNamespace(converter->GetPyNamespace()); if (pycont->mode==SCA_PythonController::SCA_PYEXEC_SCRIPT) { @@ -186,6 +186,7 @@ void BL_ConvertControllers( } } + PyGILState_Release(gstate); #endif // WITH_PYTHON break; @@ -218,6 +219,7 @@ void BL_ConvertControllers( converter->RegisterGameController(gamecontroller, bcontr); #ifdef WITH_PYTHON + PyGILState_STATE gstate = PyGILState_Ensure(); if (bcontr->type==CONT_PYTHON) { SCA_PythonController *pyctrl= static_cast<SCA_PythonController*>(gamecontroller); /* not strictly needed but gives syntax errors early on and @@ -232,6 +234,8 @@ void BL_ConvertControllers( // pyctrl->Import(); } } + + PyGILState_Release(gstate); #endif // WITH_PYTHON //done with gamecontroller diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 72be5f57b95..9483b864d52 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -227,7 +227,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice, } #ifdef WITH_PYTHON - m_attr_dict = PyDict_New(); /* new ref */ + m_attr_dict = NULL; m_draw_call_pre = NULL; m_draw_call_post = NULL; #endif @@ -287,9 +287,11 @@ KX_Scene::~KX_Scene() } #ifdef WITH_PYTHON - PyDict_Clear(m_attr_dict); - /* Py_CLEAR: Py_DECREF's and NULL's */ - Py_CLEAR(m_attr_dict); + if (m_attr_dict) { + PyDict_Clear(m_attr_dict); + /* Py_CLEAR: Py_DECREF's and NULL's */ + Py_CLEAR(m_attr_dict); + } /* these may be NULL but the macro checks */ Py_CLEAR(m_draw_call_pre); @@ -2062,6 +2064,9 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, "BGE_PROXY_ERROR_MSG); return NULL; } + + if (!self->m_attr_dict) + self->m_attr_dict = PyDict_New(); if (self->m_attr_dict && (pyconvert=PyDict_GetItem(self->m_attr_dict, item))) { @@ -2089,7 +2094,10 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) PyErr_SetString(PyExc_SystemError, "scene[key] = value: KX_Scene, "BGE_PROXY_ERROR_MSG); return -1; } - + + if (!self->m_attr_dict) + self->m_attr_dict = PyDict_New(); + if (val==NULL) { /* del ob["key"] */ int del= 0; @@ -2133,7 +2141,10 @@ static int Seq_Contains(PyObject *self_v, PyObject *value) PyErr_SetString(PyExc_SystemError, "val in scene: KX_Scene, "BGE_PROXY_ERROR_MSG); return -1; } - + + if (!self->m_attr_dict) + self->m_attr_dict = PyDict_New(); + if (self->m_attr_dict && PyDict_GetItem(self->m_attr_dict, value)) return 1; |