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_VertexProxy.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index da0e3dbdd8d..d7b5203795d 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -46,13 +46,10 @@ PyTypeObject KX_VertexProxy::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_VertexProxy::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_VertexProxy.cpp | 82 +++++++++++++++-------------- 1 file changed, 43 insertions(+), 39 deletions(-) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index d7b5203795d..8c8291ef791 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -37,18 +37,21 @@ #include "KX_PyMath.h" PyTypeObject KX_VertexProxy::Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, "KX_VertexProxy", sizeof(KX_VertexProxy), 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 }; @@ -80,43 +83,43 @@ PyAttributeDef KX_VertexProxy::Attributes[] = { }; PyObject* -KX_VertexProxy::_getattr(const char *attr) +KX_VertexProxy::py_getattro(PyObject *attr) { - - if (attr[1]=='\0') { // Group single letters + char *attr_str= PyString_AsString(attr); + if (attr_str[1]=='\0') { // Group single letters // pos - if (attr[0]=='x') + if (attr_str[0]=='x') return PyFloat_FromDouble(m_vertex->getXYZ()[0]); - if (attr[0]=='y') + if (attr_str[0]=='y') return PyFloat_FromDouble(m_vertex->getXYZ()[1]); - if (attr[0]=='z') + if (attr_str[0]=='z') return PyFloat_FromDouble(m_vertex->getXYZ()[2]); // Col - if (attr[0]=='r') + if (attr_str[0]=='r') return PyFloat_FromDouble(m_vertex->getRGBA()[0]/255.0); - if (attr[0]=='g') + if (attr_str[0]=='g') return PyFloat_FromDouble(m_vertex->getRGBA()[1]/255.0); - if (attr[0]=='b') + if (attr_str[0]=='b') return PyFloat_FromDouble(m_vertex->getRGBA()[2]/255.0); - if (attr[0]=='a') + if (attr_str[0]=='a') return PyFloat_FromDouble(m_vertex->getRGBA()[3]/255.0); // UV - if (attr[0]=='u') + if (attr_str[0]=='u') return PyFloat_FromDouble(m_vertex->getUV1()[0]); - if (attr[0]=='v') + if (attr_str[0]=='v') return PyFloat_FromDouble(m_vertex->getUV1()[1]); } - if (!strcmp(attr, "XYZ")) + if (!strcmp(attr_str, "XYZ")) return PyObjectFrom(MT_Vector3(m_vertex->getXYZ())); - if (!strcmp(attr, "UV")) + if (!strcmp(attr_str, "UV")) return PyObjectFrom(MT_Point2(m_vertex->getUV1())); - if (!strcmp(attr, "color") || !strcmp(attr, "colour")) + if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour")) { const unsigned char *colp = m_vertex->getRGBA(); MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]); @@ -124,19 +127,20 @@ KX_VertexProxy::_getattr(const char *attr) return PyObjectFrom(color); } - if (!strcmp(attr, "normal")) + if (!strcmp(attr_str, "normal")) { return PyObjectFrom(MT_Vector3(m_vertex->getNormal())); } - _getattr_up(SCA_IObject); + py_getattro_up(SCA_IObject); } -int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) +int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) { + char *attr_str= PyString_AsString(attr); if (PySequence_Check(pyvalue)) { - if (!strcmp(attr, "XYZ")) + if (!strcmp(attr_str, "XYZ")) { MT_Point3 vec; if (PyVecTo(pyvalue, vec)) @@ -148,7 +152,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) return 1; } - if (!strcmp(attr, "UV")) + if (!strcmp(attr_str, "UV")) { MT_Point2 vec; if (PyVecTo(pyvalue, vec)) @@ -160,7 +164,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) return 1; } - if (!strcmp(attr, "color") || !strcmp(attr, "colour")) + if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour")) { MT_Vector4 vec; if (PyVecTo(pyvalue, vec)) @@ -172,7 +176,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) return 1; } - if (!strcmp(attr, "normal")) + if (!strcmp(attr_str, "normal")) { MT_Vector3 vec; if (PyVecTo(pyvalue, vec)) @@ -190,7 +194,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) float val = PyFloat_AsDouble(pyvalue); // pos MT_Point3 pos(m_vertex->getXYZ()); - if (!strcmp(attr, "x")) + if (!strcmp(attr_str, "x")) { pos.x() = val; m_vertex->SetXYZ(pos); @@ -198,7 +202,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) return 0; } - if (!strcmp(attr, "y")) + if (!strcmp(attr_str, "y")) { pos.y() = val; m_vertex->SetXYZ(pos); @@ -206,7 +210,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) return 0; } - if (!strcmp(attr, "z")) + if (!strcmp(attr_str, "z")) { pos.z() = val; m_vertex->SetXYZ(pos); @@ -216,7 +220,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) // uv MT_Point2 uv = m_vertex->getUV1(); - if (!strcmp(attr, "u")) + if (!strcmp(attr_str, "u")) { uv[0] = val; m_vertex->SetUV(uv); @@ -224,7 +228,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) return 0; } - if (!strcmp(attr, "v")) + if (!strcmp(attr_str, "v")) { uv[1] = val; m_vertex->SetUV(uv); @@ -234,7 +238,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) // uv MT_Point2 uv2 = m_vertex->getUV2(); - if (!strcmp(attr, "u2")) + if (!strcmp(attr_str, "u2")) { uv[0] = val; m_vertex->SetUV2(uv); @@ -242,7 +246,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) return 0; } - if (!strcmp(attr, "v2")) + if (!strcmp(attr_str, "v2")) { uv[1] = val; m_vertex->SetUV2(uv); @@ -254,28 +258,28 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) unsigned int icol = *((const unsigned int *)m_vertex->getRGBA()); unsigned char *cp = (unsigned char*) &icol; val *= 255.0; - if (!strcmp(attr, "r")) + if (!strcmp(attr_str, "r")) { cp[0] = (unsigned char) val; m_vertex->SetRGBA(icol); m_mesh->SetMeshModified(true); return 0; } - if (!strcmp(attr, "g")) + if (!strcmp(attr_str, "g")) { cp[1] = (unsigned char) val; m_vertex->SetRGBA(icol); m_mesh->SetMeshModified(true); return 0; } - if (!strcmp(attr, "b")) + if (!strcmp(attr_str, "b")) { cp[2] = (unsigned char) val; m_vertex->SetRGBA(icol); m_mesh->SetMeshModified(true); return 0; } - if (!strcmp(attr, "a")) + if (!strcmp(attr_str, "a")) { cp[3] = (unsigned char) val; m_vertex->SetRGBA(icol); @@ -284,7 +288,7 @@ int KX_VertexProxy::_setattr(const char *attr, PyObject *pyvalue) } } - return SCA_IObject::_setattr(attr, pyvalue); + return SCA_IObject::py_setattro(attr, pyvalue); } KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex) -- cgit v1.2.3 From 46a440c7a5393177dbc74cef466d1eb5643e068d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Apr 2009 13:27:28 +0000 Subject: BGE Python API - added a module for the BGE - GameTypes, only contains types. - added KX_PYATTRIBUTE_DUMMY attributes for KX_Light, KX_PolyProxy, KX_VertexProxy, so all types should give correct results from a dir(). - added a script to check for missing methods in the epydocs - bge_api_validate_py.txt --- source/gameengine/Ketsji/KX_VertexProxy.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 8c8291ef791..f3e9bbf86b1 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -79,6 +79,30 @@ PyMethodDef KX_VertexProxy::Methods[] = { }; PyAttributeDef KX_VertexProxy::Attributes[] = { + + KX_PYATTRIBUTE_DUMMY("x"), + KX_PYATTRIBUTE_DUMMY("y"), + KX_PYATTRIBUTE_DUMMY("z"), + + KX_PYATTRIBUTE_DUMMY("r"), + KX_PYATTRIBUTE_DUMMY("g"), + KX_PYATTRIBUTE_DUMMY("b"), + KX_PYATTRIBUTE_DUMMY("a"), + + KX_PYATTRIBUTE_DUMMY("u"), + KX_PYATTRIBUTE_DUMMY("v"), + + KX_PYATTRIBUTE_DUMMY("u2"), + KX_PYATTRIBUTE_DUMMY("v2"), + + KX_PYATTRIBUTE_DUMMY("XYZ"), + KX_PYATTRIBUTE_DUMMY("UV"), + + KX_PYATTRIBUTE_DUMMY("color"), + KX_PYATTRIBUTE_DUMMY("colour"), + + KX_PYATTRIBUTE_DUMMY("normal"), + { NULL } //Sentinel }; -- cgit v1.2.3 From 33170295c8a2f3eb815b6086f47147113fd3de13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 06:41:01 +0000 Subject: use long long rather then int for storing game logic properties. There were also some problems with int to python conversion - assigning a PyLong to a KX_GameObject from python would raise an error - PyLong were coerced into floats when used with internal CValue arithmetic Changes... - PyLong is converted into CIntValue for coercing and assigning from python - CValue's generic GetNumber() function returns a double rather then a float. - Print an error when a PyType cant be coerced into a CValue Tested with python, expressions and property sensor. --- source/gameengine/Ketsji/KX_VertexProxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index f3e9bbf86b1..bb12f405332 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -332,7 +332,7 @@ CValue* KX_VertexProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;} CValue* KX_VertexProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;} STR_String sVertexName="vertex"; const STR_String & KX_VertexProxy::GetText() {return sVertexName;}; -float KX_VertexProxy::GetNumber() { return -1;} +double KX_VertexProxy::GetNumber() { return -1;} STR_String KX_VertexProxy::GetName() { return sVertexName;} void KX_VertexProxy::SetName(STR_String) { }; CValue* KX_VertexProxy::GetReplica() { return NULL;} -- cgit v1.2.3 From 5b306b7541bfc60342b70bcc55456d5c453a294a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Apr 2009 09:56:30 +0000 Subject: BGE Python API added defines PY_SET_ATTR_FAIL, PY_SET_ATTR_MISSING and PY_SET_ATTR_SUCCESS This is useful when objects that have user defined attributes (GameObject and Scene) When calling setattr on the parent, a return value of PY_SET_ATTR_FAIL means the attribute exists but failed to be set, so don't set the custom attribute. --- source/gameengine/Ketsji/KX_VertexProxy.cpp | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index bb12f405332..6a160dff7b7 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -171,9 +171,9 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) { m_vertex->SetXYZ(vec); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } - return 1; + return PY_SET_ATTR_FAIL; } if (!strcmp(attr_str, "UV")) @@ -183,9 +183,9 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) { m_vertex->SetUV(vec); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } - return 1; + return PY_SET_ATTR_FAIL; } if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour")) @@ -195,9 +195,9 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) { m_vertex->SetRGBA(vec); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } - return 1; + return PY_SET_ATTR_FAIL; } if (!strcmp(attr_str, "normal")) @@ -207,9 +207,9 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) { m_vertex->SetNormal(vec); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } - return 1; + return PY_SET_ATTR_FAIL; } } @@ -223,7 +223,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) pos.x() = val; m_vertex->SetXYZ(pos); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } if (!strcmp(attr_str, "y")) @@ -231,7 +231,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) pos.y() = val; m_vertex->SetXYZ(pos); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } if (!strcmp(attr_str, "z")) @@ -239,7 +239,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) pos.z() = val; m_vertex->SetXYZ(pos); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } // uv @@ -249,7 +249,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) uv[0] = val; m_vertex->SetUV(uv); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } if (!strcmp(attr_str, "v")) @@ -257,7 +257,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) uv[1] = val; m_vertex->SetUV(uv); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } // uv @@ -275,7 +275,7 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) uv[1] = val; m_vertex->SetUV2(uv); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } // col @@ -287,28 +287,28 @@ int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue) cp[0] = (unsigned char) val; m_vertex->SetRGBA(icol); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } if (!strcmp(attr_str, "g")) { cp[1] = (unsigned char) val; m_vertex->SetRGBA(icol); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } if (!strcmp(attr_str, "b")) { cp[2] = (unsigned char) val; m_vertex->SetRGBA(icol); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } if (!strcmp(attr_str, "a")) { cp[3] = (unsigned char) val; m_vertex->SetRGBA(icol); m_mesh->SetMeshModified(true); - return 0; + return PY_SET_ATTR_SUCCESS; } } -- 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_VertexProxy.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 6a160dff7b7..4954e94f3e4 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -40,9 +40,9 @@ PyTypeObject KX_VertexProxy::Type = { PyObject_HEAD_INIT(NULL) 0, "KX_VertexProxy", - sizeof(KX_VertexProxy), + 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_VertexProxy.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 4954e94f3e4..8be125011bb 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -341,12 +341,12 @@ void KX_VertexProxy::ReplicaSetName(STR_String) {}; // stuff for python integration -PyObject* KX_VertexProxy::PyGetXYZ(PyObject*) +PyObject* KX_VertexProxy::PyGetXYZ() { return PyObjectFrom(MT_Point3(m_vertex->getXYZ())); } -PyObject* KX_VertexProxy::PySetXYZ(PyObject*, PyObject* value) +PyObject* KX_VertexProxy::PySetXYZ(PyObject* value) { MT_Point3 vec; if (!PyVecTo(value, vec)) @@ -357,12 +357,12 @@ PyObject* KX_VertexProxy::PySetXYZ(PyObject*, PyObject* value) Py_RETURN_NONE; } -PyObject* KX_VertexProxy::PyGetNormal(PyObject*) +PyObject* KX_VertexProxy::PyGetNormal() { return PyObjectFrom(MT_Vector3(m_vertex->getNormal())); } -PyObject* KX_VertexProxy::PySetNormal(PyObject*, PyObject* value) +PyObject* KX_VertexProxy::PySetNormal(PyObject* value) { MT_Vector3 vec; if (!PyVecTo(value, vec)) @@ -374,13 +374,13 @@ PyObject* KX_VertexProxy::PySetNormal(PyObject*, PyObject* value) } -PyObject* KX_VertexProxy::PyGetRGBA(PyObject*) +PyObject* KX_VertexProxy::PyGetRGBA() { int *rgba = (int *) m_vertex->getRGBA(); return PyInt_FromLong(*rgba); } -PyObject* KX_VertexProxy::PySetRGBA(PyObject*, PyObject* value) +PyObject* KX_VertexProxy::PySetRGBA(PyObject* value) { if PyInt_Check(value) { int rgba = PyInt_AsLong(value); @@ -403,12 +403,12 @@ PyObject* KX_VertexProxy::PySetRGBA(PyObject*, PyObject* value) } -PyObject* KX_VertexProxy::PyGetUV(PyObject*) +PyObject* KX_VertexProxy::PyGetUV() { return PyObjectFrom(MT_Vector2(m_vertex->getUV1())); } -PyObject* KX_VertexProxy::PySetUV(PyObject*, PyObject* value) +PyObject* KX_VertexProxy::PySetUV(PyObject* value) { MT_Point2 vec; if (!PyVecTo(value, vec)) @@ -419,12 +419,12 @@ PyObject* KX_VertexProxy::PySetUV(PyObject*, PyObject* value) Py_RETURN_NONE; } -PyObject* KX_VertexProxy::PyGetUV2(PyObject*) +PyObject* KX_VertexProxy::PyGetUV2() { return PyObjectFrom(MT_Vector2(m_vertex->getUV2())); } -PyObject* KX_VertexProxy::PySetUV2(PyObject*, PyObject* args) +PyObject* KX_VertexProxy::PySetUV2(PyObject* args) { MT_Point2 vec; unsigned int unit=0; -- cgit v1.2.3 From f5fc4ebdd8ede5263f4b34f161ebe139d40466dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Apr 2009 21:01:12 +0000 Subject: BGE Python API - More verbose error messages. - BL_Shader wasnt setting error messages on some errors - FilterNormal depth attribute was checking for float which is bad because scripts often expect ints assigned to float attributes. - Added a check to PyVecTo for a tuple rather then always using a generic python sequence. On my system this is over 2x faster with an optmized build. --- source/gameengine/Ketsji/KX_VertexProxy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/gameengine/Ketsji/KX_VertexProxy.cpp') diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 8be125011bb..88f63334285 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -398,7 +398,7 @@ PyObject* KX_VertexProxy::PySetRGBA(PyObject* value) } } - PyErr_SetString(PyExc_TypeError, "expected a 4D vector or an int"); + PyErr_SetString(PyExc_TypeError, "vert.setRGBA(value): KX_VertexProxy, expected a 4D vector or an int"); return NULL; } -- cgit v1.2.3