BGE: Fix T48071: Global logic manager
Previously the logic manager was used as a global variable for SCA_ILogicBrick::m_sCurrentLogicManager, this request to always update it before run any python script and allow call function like ConvertPythonTo[GameObject/Mesh]. The bug showed in T48071 is that as exepted the global m_sCurrentLogicManager is not updated with the proper scene logic manager. Instead of trying to fix it by updating the logic manager everywhere and wait next bug report to add a similar line. The following patch propose a different way: - Every logic brick now contain its logic manager to SCA_ILogicBrick::m_logicManager, this value is set and get by SCA_ILogicBrick::[Set/Get]LogicManager, It's initialized from blender conversion and scene merging. - Function ConvertPythonTo[GameObject/mesh] now take as first argument the logic manager to find name coresponding object or mesh. Only ConvertPythonToCamera doesn't do that because it uses the KX_Scene::FindCamera function. Reviewers: moguri Differential Revision: https://developer.blender.org/D1913
This commit is contained in:
@@ -386,8 +386,7 @@ bool SCA_PythonController::Import()
|
||||
void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
|
||||
{
|
||||
m_sCurrentController = this;
|
||||
m_sCurrentLogicManager = logicmgr;
|
||||
|
||||
|
||||
PyObject *excdict= NULL;
|
||||
PyObject *resultobj= NULL;
|
||||
|
||||
@@ -478,7 +477,7 @@ PyObject *SCA_PythonController::PyActivate(PyObject *value)
|
||||
if (actu==NULL)
|
||||
return NULL;
|
||||
|
||||
m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, true);
|
||||
m_logicManager->AddActiveActuator((SCA_IActuator*)actu, true);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
@@ -493,7 +492,7 @@ PyObject *SCA_PythonController::PyDeActivate(PyObject *value)
|
||||
if (actu==NULL)
|
||||
return NULL;
|
||||
|
||||
m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, false);
|
||||
m_logicManager->AddActiveActuator((SCA_IActuator*)actu, false);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user