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:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2016-04-10 18:36:10 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2016-04-11 00:57:43 +0300
commit2050ecc307de9159b50c7f9798e47a366f505f2e (patch)
treeedda985383ebe538858a255b5b0d68b6c54d6ead /source/gameengine/Converter
parent3a80d5e1d0e4952caa76f1d655429375c0da1884 (diff)
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
Diffstat (limited to 'source/gameengine/Converter')
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp2
-rw-r--r--source/gameengine/Converter/BL_ArmatureActuator.cpp2
-rw-r--r--source/gameengine/Converter/BL_ArmatureConstraint.cpp6
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.cpp2
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp1
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.cpp1
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp1
7 files changed, 10 insertions, 5 deletions
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index d9865c1f4fb..d28cdb84275 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -584,7 +584,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF
if (val != "")
{
- action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
+ action= (bAction*)self->GetLogicManager()->GetActionByName(val);
if (!action)
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
diff --git a/source/gameengine/Converter/BL_ArmatureActuator.cpp b/source/gameengine/Converter/BL_ArmatureActuator.cpp
index e38cb6eadaf..67cc7d2c291 100644
--- a/source/gameengine/Converter/BL_ArmatureActuator.cpp
+++ b/source/gameengine/Converter/BL_ArmatureActuator.cpp
@@ -243,7 +243,7 @@ int BL_ArmatureActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBU
KX_GameObject* &target = (!strcmp(attrdef->m_name, "target")) ? actuator->m_gametarget : actuator->m_gamesubtarget;
KX_GameObject *gameobj;
- if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: BL_ArmatureActuator"))
+ if (!ConvertPythonToGameObject(actuator->GetLogicManager(), value, &gameobj, true, "actuator.object = value: BL_ArmatureActuator"))
return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
if (target != NULL)
diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp
index 88d82e21d61..d0c7e061fb7 100644
--- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp
+++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp
@@ -36,6 +36,7 @@
#include "BL_ArmatureObject.h"
#include "BLI_math.h"
#include "BLI_string.h"
+#include "KX_PythonInit.h"
#ifdef WITH_PYTHON
@@ -360,6 +361,7 @@ int BL_ArmatureConstraint::py_attr_setattr(void *self_v, const struct KX_PYATTRI
int ival;
double dval;
// char* sval;
+ SCA_LogicManager *logicmgr = KX_GetActiveScene()->GetLogicManager();
KX_GameObject *oval;
if (!constraint) {
@@ -387,13 +389,13 @@ int BL_ArmatureConstraint::py_attr_setattr(void *self_v, const struct KX_PYATTRI
return PY_SET_ATTR_SUCCESS;
case BCA_TARGET:
- if (!ConvertPythonToGameObject(value, &oval, true, "constraint.target = value: BL_ArmatureConstraint"))
+ if (!ConvertPythonToGameObject(logicmgr, value, &oval, true, "constraint.target = value: BL_ArmatureConstraint"))
return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
self->SetTarget(oval);
return PY_SET_ATTR_SUCCESS;
case BCA_SUBTARGET:
- if (!ConvertPythonToGameObject(value, &oval, true, "constraint.subtarget = value: BL_ArmatureConstraint"))
+ if (!ConvertPythonToGameObject(logicmgr, value, &oval, true, "constraint.subtarget = value: BL_ArmatureConstraint"))
return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
self->SetSubtarget(oval);
return PY_SET_ATTR_SUCCESS;
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
index e8f451213f5..f21db419ebc 100644
--- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
@@ -547,7 +547,7 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE
if (val != "")
{
- action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
+ action= (bAction*)self->GetLogicManager()->GetActionByName(val);
if (action==NULL)
{
PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, action not found!");
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 021111b4fe5..455fef0aceb 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -1127,6 +1127,7 @@ void BL_ConvertActuators(const char* maggiename,
uniquename += uniqueval->GetText();
uniqueval->Release();
baseact->SetName(bact->name);
+ baseact->SetLogicManager(logicmgr);
//gameobj->SetProperty(uniquename,baseact);
gameobj->AddActuator(baseact);
diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp
index e3697087ea9..f55d81adb80 100644
--- a/source/gameengine/Converter/KX_ConvertControllers.cpp
+++ b/source/gameengine/Converter/KX_ConvertControllers.cpp
@@ -214,6 +214,7 @@ void BL_ConvertControllers(
//at some point it should either be implemented globally (and saved as a separate var) or removed.
//gamecontroller->SetName(uniquename);
gamecontroller->SetName(bcontr->name);
+ gamecontroller->SetLogicManager(logicmgr);
gameobj->AddController(gamecontroller);
converter->RegisterGameController(gamecontroller, bcontr);
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 79fd9cb9254..5e897bb4a62 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -608,6 +608,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
gamesensor->SetLevel(level);
gamesensor->SetTap(tap);
gamesensor->SetName(sens->name);
+ gamesensor->SetLogicManager(logicmgr);
gameobj->AddSensor(gamesensor);