BGE patch #18309 commited: Add an addObject() method to KX_Scene.
authorBenoit Bolsee <benoit.bolsee@online.be>
Sat, 28 Feb 2009 22:25:23 +0000 (22:25 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Sat, 28 Feb 2009 22:25:23 +0000 (22:25 +0000)
source/gameengine/Ketsji/KX_Scene.cpp
source/gameengine/Ketsji/KX_Scene.h

index 073cfc98bf1b191e434534016518f877ed768f0a..0fded15f1a150b08b602f27aa60ecd24bcd608b7 100644 (file)
@@ -1517,18 +1517,6 @@ double KX_Scene::getSuspendedDelta()
 //----------------------------------------------------------------------------
 //Python
 
-PyMethodDef KX_Scene::Methods[] = {
-       KX_PYMETHODTABLE_NOARGS(KX_Scene, getLightList),
-       KX_PYMETHODTABLE_NOARGS(KX_Scene, getObjectList),
-       KX_PYMETHODTABLE_NOARGS(KX_Scene, getName),
-       
-       {NULL,NULL} //Sentinel
-};
-
-PyAttributeDef KX_Scene::Attributes[] = {
-       { NULL }        //Sentinel
-};
-
 PyTypeObject KX_Scene::Type = {
        PyObject_HEAD_INIT(&PyType_Type)
                0,
@@ -1554,6 +1542,19 @@ PyParentObject KX_Scene::Parents[] = {
                NULL
 };
 
+PyMethodDef KX_Scene::Methods[] = {
+       KX_PYMETHODTABLE(KX_Scene, getLightList),
+       KX_PYMETHODTABLE(KX_Scene, getObjectList),
+       KX_PYMETHODTABLE(KX_Scene, getName),
+       KX_PYMETHODTABLE(KX_Scene, addObject),
+       
+       {NULL,NULL} //Sentinel
+};
+
+PyAttributeDef KX_Scene::Attributes[] = {
+       { NULL }        //Sentinel
+};
+
 PyObject* KX_Scene::_getattr(const char *attr)
 {
        if (!strcmp(attr, "name"))
@@ -1622,3 +1623,25 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Scene, getName,
 {
        return PyString_FromString(GetName());
 }
+
+KX_PYMETHODDEF_DOC(KX_Scene, addObject,
+"addObject(object, other, time=0)\n"
+"Returns the added object.\n")
+{
+       PyObject *pyob, *pyother;
+       KX_GameObject *ob, *other;
+
+       int time = 0;
+
+       if (!PyArg_ParseTuple(args, "OO|i", &pyob, &pyother, &time))
+               return NULL;
+
+       if (!ConvertPythonToGameObject(pyob, &ob, false)
+               || !ConvertPythonToGameObject(pyother, &other, false))
+               return NULL;
+
+
+       SCA_IObject* replica = AddReplicaObject((SCA_IObject*)ob, other, time);
+       replica->AddRef();
+       return replica;
+}
\ No newline at end of file
index e49a87b040259373a0e495664dad3125c9304d58..962db1a9b9641dde422878e3eb9ba319d7472bde 100644 (file)
@@ -550,6 +550,7 @@ public:
        KX_PYMETHOD_DOC_NOARGS(KX_Scene, getLightList);
        KX_PYMETHOD_DOC_NOARGS(KX_Scene, getObjectList);
        KX_PYMETHOD_DOC_NOARGS(KX_Scene, getName);
+       KX_PYMETHOD_DOC(KX_Scene, addObject);
 /*     
        KX_PYMETHOD_DOC(KX_Scene, getActiveCamera);
        KX_PYMETHOD_DOC(KX_Scene, getActiveCamera);