diff options
Diffstat (limited to 'source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp index 630df2d21d9..18a297d6c92 100644 --- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp +++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp @@ -80,7 +80,7 @@ PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = { PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = { - {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_VARARGS, SetMesh_doc}, + {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, SetMesh_doc}, KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh), KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh), @@ -99,28 +99,29 @@ PyObject* KX_SCA_ReplaceMeshActuator::_getattr(const STR_String& attr) /* 1. setMesh */ char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] = "setMesh(name)\n" - "\t- name: string\n" + "\t- name: string or None\n" "\tSet the mesh that will be substituted for the current one.\n"; -PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self, PyObject* value) { - char* meshname; - - if (!PyArg_ParseTuple(args, "s", &meshname)) - { - return NULL; - } - - void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname)); - - if (mesh) { + if (value == Py_None) { + m_mesh = NULL; + } else { + char* meshname = PyString_AsString(value); + if (!meshname) { + PyErr_SetString(PyExc_ValueError, "Expected the name of a mesh or None"); + return NULL; + } + void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname)); + + if (mesh==NULL) { + PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist"); + return NULL; + } m_mesh= (class RAS_MeshObject*)mesh; - Py_Return; } - return NULL; + Py_RETURN_NONE; } KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh, @@ -129,7 +130,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh, ) { if (!m_mesh) - Py_Return; + Py_RETURN_NONE; return PyString_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr())); } @@ -139,7 +140,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh, "instantReplaceMesh() : immediately replace mesh without delay\n") { InstantReplaceMesh(); - Py_Return; + Py_RETURN_NONE; } /* ------------------------------------------------------------------------- */ |