From d573e9c5390a438b6e606a12d05dc2c6ad06a174 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2009 04:12:20 +0000 Subject: BGE Python api Added the method into the PyType so python knows about the methods (its supposed to work this way). This means in the future the api can use PyType_Ready() to store the methods in the types dictionary. Python3 removes Py_FindMethod and we should not be using it anyway since its not that efficient. --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 65f3aea12f9..08afa2853c3 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -380,13 +380,10 @@ PyTypeObject KX_CameraActuator::Type = { 0, __getattr, __setattr, - 0, //&MyPyCompare, - __repr, - 0, //&cvalue_as_number, - 0, 0, - 0, - 0 + __repr, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + Methods }; PyParentObject KX_CameraActuator::Parents[] = { -- cgit v1.2.3 From fd2b1156783d52dbb7c93c53fe008d9e14cbffdd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Apr 2009 14:51:06 +0000 Subject: Python BGE API - Initialize python types with PyType_Ready, which adds methods to the type dictionary. - use Pythons get/setattro (uses a python string for the attribute rather then char*). Using basic C strings seems nice but internally python converts them to python strings and discards them for most functions that accept char arrays. - Method lookups use the PyTypes dictionary (should be faster then Py_FindMethod) - Renamed __getattr -> py_base_getattro, _getattr -> py_getattro, __repr -> py_base_repr, py_delattro, py_getattro_self etc. From here is possible to put all the parent classes methods into each python types dictionary to avoid nested lookups (api has 4 levels of lookups in some places), tested this but its not ready yet. Simple tests for getting a method within a loop show this to be between 0.5 and 3.2x faster then using Py_FindMethod() --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 08afa2853c3..354143f1e69 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -371,18 +371,21 @@ bool KX_CameraActuator::string2axischoice(const char *axisString) /* Integration hooks ------------------------------------------------------- */ PyTypeObject KX_CameraActuator::Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, "KX_CameraActuator", sizeof(KX_CameraActuator), 0, PyDestructor, 0, - __getattr, - __setattr, 0, - __repr, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0, + 0, + py_base_repr, + 0,0,0,0,0,0, + py_base_getattro, + py_base_setattro, + 0,0,0,0,0,0,0,0,0, Methods }; @@ -414,27 +417,28 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("max",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_maxHeight), KX_PYATTRIBUTE_FLOAT_RW("height",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_height), KX_PYATTRIBUTE_BOOL_RW("xy",KX_CameraActuator,m_x), + KX_PYATTRIBUTE_DUMMY("object"), {NULL} }; -PyObject* KX_CameraActuator::_getattr(const char *attr) { +PyObject* KX_CameraActuator::py_getattro(PyObject *attr) { PyObject* object; - - if (!strcmp(attr, "object")) { + char *attr_str= PyString_AsString(attr); + if (!strcmp(attr_str, "object")) { if (!m_ob) Py_RETURN_NONE; else return m_ob->AddRef(); } - object = _getattr_self(Attributes, this, attr); + object = py_getattro_self(Attributes, this, attr); if (object != NULL) return object; - _getattr_up(SCA_IActuator); + py_getattro_up(SCA_IActuator); } -int KX_CameraActuator::_setattr(const char *attr, PyObject* value) { +int KX_CameraActuator::py_setattro(PyObject *attr, PyObject* value) { int ret; - - if (!strcmp(attr, "object")) { + char *attr_str= PyString_AsString(attr); + if (!strcmp(attr_str, "object")) { KX_GameObject *gameobj; if (!ConvertPythonToGameObject(value, &gameobj, true)) @@ -451,10 +455,10 @@ int KX_CameraActuator::_setattr(const char *attr, PyObject* value) { return 0; } - ret = _setattr_self(Attributes, this, attr, value); + ret = py_setattro_self(Attributes, this, attr, value); if (ret >= 0) return ret; - return SCA_IActuator::_setattr(attr, value); + return SCA_IActuator::py_setattro(attr, value); } /* get obj ---------------------------------------------------------- */ -- cgit v1.2.3 From 6be69211843ee37ab9be763df0621db94dbfd69b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 4 Apr 2009 02:57:35 +0000 Subject: moved more attributes from getattr into PyAttributeDef's --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 55 +++++++++++++------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 354143f1e69..526c2dc404b 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -417,19 +417,12 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { KX_PYATTRIBUTE_FLOAT_RW("max",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_maxHeight), KX_PYATTRIBUTE_FLOAT_RW("height",-MAXFLOAT,MAXFLOAT,KX_CameraActuator,m_height), KX_PYATTRIBUTE_BOOL_RW("xy",KX_CameraActuator,m_x), - KX_PYATTRIBUTE_DUMMY("object"), + KX_PYATTRIBUTE_RW_FUNCTION("object", KX_CameraActuator, pyattr_get_object, pyattr_set_object), {NULL} }; PyObject* KX_CameraActuator::py_getattro(PyObject *attr) { - PyObject* object; - char *attr_str= PyString_AsString(attr); - if (!strcmp(attr_str, "object")) { - if (!m_ob) Py_RETURN_NONE; - else return m_ob->AddRef(); - } - - object = py_getattro_self(Attributes, this, attr); + PyObject* object = py_getattro_self(Attributes, this, attr); if (object != NULL) return object; py_getattro_up(SCA_IActuator); @@ -437,24 +430,6 @@ PyObject* KX_CameraActuator::py_getattro(PyObject *attr) { int KX_CameraActuator::py_setattro(PyObject *attr, PyObject* value) { int ret; - char *attr_str= PyString_AsString(attr); - if (!strcmp(attr_str, "object")) { - KX_GameObject *gameobj; - - if (!ConvertPythonToGameObject(value, &gameobj, true)) - return 1; // ConvertPythonToGameObject sets the error - - if (m_ob != NULL) - m_ob->UnregisterActuator(this); - - m_ob = (SCA_IObject*)gameobj; - - if (m_ob) - m_ob->RegisterActuator(this); - - return 0; - } - ret = py_setattro_self(Attributes, this, attr, value); if (ret >= 0) return ret; @@ -623,4 +598,30 @@ PyObject* KX_CameraActuator::PyGetXY(PyObject* self, return PyInt_FromLong(m_x); } +PyObject* KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) +{ + KX_CameraActuator* self= static_cast(self_v); + if (self->m_ob==NULL) + Py_RETURN_NONE; + else + return self->m_ob->AddRef(); +} + +int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) +{ + KX_CameraActuator* self= static_cast(self_v); + KX_GameObject *gameobj; + + if (!ConvertPythonToGameObject(value, &gameobj, true)) + return 1; // ConvertPythonToGameObject sets the error + + if (self->m_ob) + self->m_ob->UnregisterActuator(self); + + if (self->m_ob = (SCA_IObject*)gameobj) + self->m_ob->RegisterActuator(self); + + return 0; +} + /* eof */ -- cgit v1.2.3 From 5d64dd019e7e8150db40505097d1b4048f4e0153 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Apr 2009 11:06:35 +0000 Subject: BGE Python API Use each types dictionary to store attributes PyAttributeDef's so it uses pythons hash lookup (which it was already doing for methods) rather then doing a string lookup on the array each time. This also means attributes can be found in the type without having to do a dir() on the instance. --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 526c2dc404b..4db24a6e365 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -422,18 +422,11 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { }; PyObject* KX_CameraActuator::py_getattro(PyObject *attr) { - PyObject* object = py_getattro_self(Attributes, this, attr); - if (object != NULL) - return object; py_getattro_up(SCA_IActuator); } int KX_CameraActuator::py_setattro(PyObject *attr, PyObject* value) { - int ret; - ret = py_setattro_self(Attributes, this, attr, value); - if (ret >= 0) - return ret; - return SCA_IActuator::py_setattro(attr, value); + py_setattro_up(SCA_IActuator); } /* get obj ---------------------------------------------------------- */ -- cgit v1.2.3 From 2fff90bbb4a922f454c15dbf2d6215bd4d8c519c Mon Sep 17 00:00:00 2001 From: Andre Susano Pinto Date: Fri, 10 Apr 2009 16:45:19 +0000 Subject: Added function name to many of the PyArg_ParseTuple calls in gameengine This way python raises more useful messages. --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 4db24a6e365..0118e490773 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -440,7 +440,7 @@ PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args) ShowDeprecationWarning("getObject()", "the object property"); - if (!PyArg_ParseTuple(args, "|i", &ret_name_only)) + if (!PyArg_ParseTuple(args, "|i:getObject", &ret_name_only)) return NULL; if (!m_ob) @@ -496,7 +496,7 @@ PyObject* KX_CameraActuator::PySetMin(PyObject* self, { ShowDeprecationWarning("setMin()", "the min property"); float min; - if(PyArg_ParseTuple(args,"f", &min)) + if(PyArg_ParseTuple(args,"f:setMin", &min)) { m_minHeight = min; Py_RETURN_NONE; @@ -524,7 +524,7 @@ PyObject* KX_CameraActuator::PySetMax(PyObject* self, { ShowDeprecationWarning("getMax()", "the max property"); float max; - if(PyArg_ParseTuple(args,"f", &max)) + if(PyArg_ParseTuple(args,"f:setMax", &max)) { m_maxHeight = max; Py_RETURN_NONE; @@ -552,7 +552,7 @@ PyObject* KX_CameraActuator::PySetHeight(PyObject* self, { ShowDeprecationWarning("getHeight()", "the height property"); float height; - if(PyArg_ParseTuple(args,"f", &height)) + if(PyArg_ParseTuple(args,"f:setHeight", &height)) { m_height = height; Py_RETURN_NONE; @@ -570,7 +570,7 @@ PyObject* KX_CameraActuator::PySetXY(PyObject* self, { ShowDeprecationWarning("setXY()", "the xy property"); int value; - if(PyArg_ParseTuple(args,"i", &value)) + if(PyArg_ParseTuple(args,"i:setXY", &value)) { m_x = value != 0; Py_RETURN_NONE; -- cgit v1.2.3 From efb7dd86ff001efe26fba1caef70a87806d138f6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Apr 2009 04:34:27 +0000 Subject: Fix for own recent reference count error. - The armature weakref list was being incref'd twice then decrefed twice (incref and decref were used incorrectly), now only once. My 'fix' broke this. - In bpy_pydriver_create_dict the 2 refs added from running PyDict_SetItemString twice were undone when clearing the dictionary (added comment) - changed Py_XDECREF to Py_DECREF int BPY_pyconstraint_update and BPY_pyconstraint_target, Py_XDECREF checs for NULL value which would have crashed blender before it got to Py_XDECREF anyway. - after every error is reported (PyErr_Print), remove sys.last_traceback and clear the error, I found this fixed certain crashes (usually when starting the game engine or exiting blender), so best do this all the time. - header_text.c, CcdPhysicsEnvironment.cpp, KX_CameraActuator.cpp - remove some warnings. --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 0118e490773..329d31cfa25 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -611,7 +611,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF if (self->m_ob) self->m_ob->UnregisterActuator(self); - if (self->m_ob = (SCA_IObject*)gameobj) + if ((self->m_ob = (SCA_IObject*)gameobj)) self->m_ob->RegisterActuator(self); return 0; -- cgit v1.2.3 From 8d2cb5bea44f4245dd17f2d82cbd0251d8090fd5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Apr 2009 12:46:39 +0000 Subject: BGE Python API This changes how the BGE classes and Python work together, which hasnt changed since blender went opensource. The main difference is PyObjectPlus - the base class for most game engine classes, no longer inherit from PyObject, and cannot be cast to a PyObject. This has the advantage that the BGE does not have to keep 2 reference counts valid for C++ and Python. Previously C++ classes would never be freed while python held a reference, however this reference could be problematic eg: a GameObject that isnt in a scene anymore should not be used by python, doing so could even crash blender in some cases. Instead PyObjectPlus has a member "PyObject *m_proxy" which is lazily initialized when python needs it. m_proxy reference counts are managed by python, though it should never be freed while the C++ class exists since it holds a reference to avoid making and freeing it all the time. When the C++ class is free'd it sets the m_proxy reference to NULL, If python accesses this variable it will raise a RuntimeError, (check the isValid attribute to see if its valid without raising an error). - This replaces the m_zombie bool and IsZombie() tests added recently. In python return values that used to be.. return value->AddRef(); Are now return value->GetProxy(); or... return value->NewProxy(true); // true means python owns this C++ value which will be deleted when the PyObject is freed --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 329d31cfa25..a1159dbc23f 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -449,7 +449,7 @@ PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args) if (ret_name_only) return PyString_FromString(m_ob->GetName()); else - return m_ob->AddRef(); + return m_ob->GetProxy(); } /* set obj ---------------------------------------------------------- */ const char KX_CameraActuator::SetObject_doc[] = @@ -597,7 +597,7 @@ PyObject* KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUT if (self->m_ob==NULL) Py_RETURN_NONE; else - return self->m_ob->AddRef(); + return self->m_ob->GetProxy(); } int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) -- cgit v1.2.3 From 7dbc9dc719c3eb0823e4f9e7ae94a479f9427ea7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Apr 2009 14:57:52 +0000 Subject: BGE Python API cleanup - no functionality changes - comments to PyObjectPlus.h - remove unused/commented junk. - renamed PyDestructor to py_base_dealloc for consistency - all the PyTypeObject's were still using the sizeof() their class, can use sizeof(PyObjectPlus_Proxy) now which is smaller too. --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index a1159dbc23f..35165af1f82 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -374,9 +374,9 @@ PyTypeObject KX_CameraActuator::Type = { PyObject_HEAD_INIT(NULL) 0, "KX_CameraActuator", - sizeof(KX_CameraActuator), + sizeof(PyObjectPlus_Proxy), 0, - PyDestructor, + py_base_dealloc, 0, 0, 0, -- cgit v1.2.3 From 6bc162e679d8b52b28e205de76985a1735abbf0a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Apr 2009 17:29:07 +0000 Subject: BGE Python API removed redundant (PyObject *self) argument from python functions that are not exposed to python directly. --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 38 ++++++++------------------ 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 35165af1f82..6cc48856a94 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -408,7 +408,7 @@ PyMethodDef KX_CameraActuator::Methods[] = { {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, (PY_METHODCHAR)SetHeight_doc}, {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, (PY_METHODCHAR)GetHeight_doc}, {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, (PY_METHODCHAR)SetXY_doc}, - {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_VARARGS, (PY_METHODCHAR)GetXY_doc}, + {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_NOARGS, (PY_METHODCHAR)GetXY_doc}, {NULL,NULL,NULL,NULL} //Sentinel }; @@ -434,7 +434,7 @@ const char KX_CameraActuator::GetObject_doc[] = "getObject(name_only = 1)\n" "name_only - optional arg, when true will return the KX_GameObject rather then its name\n" "\tReturns the object this sensor reacts to.\n"; -PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args) +PyObject* KX_CameraActuator::PyGetObject(PyObject* args) { int ret_name_only = 1; @@ -456,7 +456,7 @@ const char KX_CameraActuator::SetObject_doc[] = "setObject(object)\n" "\t- object: KX_GameObject, string or None\n" "\tSets the object this sensor reacts to.\n"; -PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* value) +PyObject* KX_CameraActuator::PySetObject(PyObject* value) { KX_GameObject *gameobj; @@ -479,9 +479,7 @@ PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* value) const char KX_CameraActuator::GetMin_doc[] = "getMin\n" "\tReturns the minimum value set in the Min: field.\n"; -PyObject* KX_CameraActuator::PyGetMin(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PyGetMin() { ShowDeprecationWarning("getMin()", "the min property"); return PyFloat_FromDouble(m_minHeight); @@ -490,9 +488,7 @@ PyObject* KX_CameraActuator::PyGetMin(PyObject* self, const char KX_CameraActuator::SetMin_doc[] = "setMin\n" "\tSets the minimum value.\n"; -PyObject* KX_CameraActuator::PySetMin(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PySetMin(PyObject* args) { ShowDeprecationWarning("setMin()", "the min property"); float min; @@ -507,9 +503,7 @@ PyObject* KX_CameraActuator::PySetMin(PyObject* self, const char KX_CameraActuator::GetMax_doc[] = "getMax\n" "\tReturns the maximum value set in the Max: field.\n"; -PyObject* KX_CameraActuator::PyGetMax(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PyGetMax() { ShowDeprecationWarning("getMax()", "the max property"); return PyFloat_FromDouble(m_maxHeight); @@ -518,9 +512,7 @@ PyObject* KX_CameraActuator::PyGetMax(PyObject* self, const char KX_CameraActuator::SetMax_doc[] = "setMax\n" "\tSets the maximum value.\n"; -PyObject* KX_CameraActuator::PySetMax(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PySetMax(PyObject* args) { ShowDeprecationWarning("getMax()", "the max property"); float max; @@ -535,9 +527,7 @@ PyObject* KX_CameraActuator::PySetMax(PyObject* self, const char KX_CameraActuator::GetHeight_doc[] = "getHeight\n" "\tReturns the height value set in the height: field.\n"; -PyObject* KX_CameraActuator::PyGetHeight(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PyGetHeight() { ShowDeprecationWarning("getHeight()", "the height property"); return PyFloat_FromDouble(m_height); @@ -546,9 +536,7 @@ PyObject* KX_CameraActuator::PyGetHeight(PyObject* self, const char KX_CameraActuator::SetHeight_doc[] = "setHeight\n" "\tSets the height value.\n"; -PyObject* KX_CameraActuator::PySetHeight(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PySetHeight(PyObject* args) { ShowDeprecationWarning("getHeight()", "the height property"); float height; @@ -564,9 +552,7 @@ const char KX_CameraActuator::SetXY_doc[] = "setXY\n" "\tSets axis the camera tries to get behind.\n" "\t1=x, 0=y\n"; -PyObject* KX_CameraActuator::PySetXY(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PySetXY(PyObject* args) { ShowDeprecationWarning("setXY()", "the xy property"); int value; @@ -583,9 +569,7 @@ const char KX_CameraActuator::GetXY_doc[] = "getXY\n" "\tGets the axis the camera tries to get behind.\n" "\tTrue = X, False = Y\n"; -PyObject* KX_CameraActuator::PyGetXY(PyObject* self, - PyObject* args, - PyObject* kwds) +PyObject* KX_CameraActuator::PyGetXY() { ShowDeprecationWarning("getXY()", "the xy property"); return PyInt_FromLong(m_x); -- cgit v1.2.3 From dee32d0b3f409007f5a392668068b92c3810026a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Apr 2009 09:13:59 +0000 Subject: BGE Python API - initialize pythons sys.argv in the blenderplayer - ignore all arguments after a single " - " in the blenderplayer (like in blender), so args can be passed to the game. - add a utility function PyOrientationTo() - to take a Py euler, quat or 3x3 matrix and convert into a C++ MT_Matrix3x3. - add utility function ConvertPythonToMesh to get a RAS_MeshObject from a KX_MeshProxy or a name. - Added error prefix arguments to ConvertPythonToGameObject, ConvertPythonToMesh and PyOrientationTo so the error messages can include what function they came from. - deprecated brick.getOwner() for the "owner" attribute. --- source/gameengine/Ketsji/KX_CameraActuator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Ketsji/KX_CameraActuator.cpp') diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 6cc48856a94..355cdbb6263 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -462,7 +462,7 @@ PyObject* KX_CameraActuator::PySetObject(PyObject* value) ShowDeprecationWarning("setObject()", "the object property"); - if (!ConvertPythonToGameObject(value, &gameobj, true)) + if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.setObject(value): KX_CameraActuator")) return NULL; // ConvertPythonToGameObject sets the error if (m_ob != NULL) @@ -589,7 +589,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF KX_CameraActuator* self= static_cast(self_v); KX_GameObject *gameobj; - if (!ConvertPythonToGameObject(value, &gameobj, true)) + if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_CameraActuator")) return 1; // ConvertPythonToGameObject sets the error if (self->m_ob) -- cgit v1.2.3