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>2009-04-12 00:58:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-04-12 00:58:09 +0400
commit4cd088b1059afa2e7b998c184b2c9deecd4be4a9 (patch)
tree48483da057f8a56a99db81e3dfbf5f1086d46374 /source/gameengine/Ketsji
parent37e53b2e1f8107cb8ddbee2d67bf984a70a71276 (diff)
BGE Py API
- setting the scene attributes would always add to the scenes custom dictionary. - new CListValue method from_id(id) so you can store a Game Objects id and use it to get the game object back. ob_id = id(gameOb) ... gameOb = scene.objects.from_id(ob_id) This is useful because names are not always unique.
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp6
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h21
2 files changed, 23 insertions, 4 deletions
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 7842076de66..2f7c1b77794 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -1588,7 +1588,7 @@ PyTypeObject KX_Scene::Type = {
py_base_repr,
0,0,0,0,0,0,
py_base_getattro,
- py_base_setattro,
+ py_base_setattro_scene, /* unlike almost all other types we need out own because user attributes are supported */
0,0,0,0,0,0,0,0,0,
Methods
};
@@ -1669,11 +1669,9 @@ int KX_Scene::py_delattro(PyObject *attr)
return 0;
}
+/* py_base_setattro_scene deals with setting the dict, it will run if this returns an error */
int KX_Scene::py_setattro(PyObject *attr, PyObject *pyvalue)
{
- if (!PyDict_SetItem(m_attrlist, attr, pyvalue))
- return 0;
-
return PyObjectPlus::py_setattro(attr, pyvalue);
}
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index 9f05ddf70c2..1bdfbd45d20 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -590,6 +590,27 @@ public:
/* for dir(), python3 uses __dir__() */
static PyObject* pyattr_get_dir_dict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
+ static int py_base_setattro_scene(PyObject * self, PyObject *attr, PyObject *value)
+ {
+ if (value==NULL)
+ return ((PyObjectPlus*) self)->py_delattro(attr);
+
+ int ret= ((PyObjectPlus*) self)->py_setattro(attr, value);
+
+ if (ret) {
+ if (!PyDict_SetItem(((KX_Scene *) self)->m_attrlist, attr, value)) {
+ PyErr_Clear();
+ ret= 0;
+ }
+ else {
+ ret= -1;
+ }
+ }
+
+ return ret;
+ }
+
+
virtual PyObject* py_getattro(PyObject *attr); /* name, active_camera, gravity, suspended, viewport, framing, activity_culling, activity_culling_radius */
virtual int py_setattro(PyObject *attr, PyObject *pyvalue);