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_RadarSensor.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source/gameengine/Ketsji/KX_RadarSensor.cpp') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index fa8998cd81d..91ad60e8cee 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -259,13 +259,10 @@ PyTypeObject KX_RadarSensor::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_RadarSensor::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_RadarSensor.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'source/gameengine/Ketsji/KX_RadarSensor.cpp') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 91ad60e8cee..77cde79b54d 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -250,18 +250,21 @@ PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self) { /* Python Integration Hooks */ /* ------------------------------------------------------------------------- */ PyTypeObject KX_RadarSensor::Type = { - PyObject_HEAD_INIT(&PyType_Type) + PyObject_HEAD_INIT(NULL) 0, "KX_RadarSensor", sizeof(KX_RadarSensor), 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 }; @@ -295,20 +298,20 @@ PyAttributeDef KX_RadarSensor::Attributes[] = { {NULL} //Sentinel }; -PyObject* KX_RadarSensor::_getattr(const char *attr) +PyObject* KX_RadarSensor::py_getattro(PyObject *attr) { - PyObject* object = _getattr_self(Attributes, this, attr); + PyObject* object = py_getattro_self(Attributes, this, attr); if (object != NULL) return object; - _getattr_up(KX_NearSensor); + py_getattro_up(KX_NearSensor); } -int KX_RadarSensor::_setattr(const char *attr, PyObject* value) +int KX_RadarSensor::py_setattro(PyObject *attr, PyObject* value) { - int ret = _setattr_self(Attributes, this, attr, value); + int ret = py_setattro_self(Attributes, this, attr, value); if (ret >= 0) return ret; - return KX_NearSensor::_setattr(attr, value); + return KX_NearSensor::py_setattro(attr, value); } -- 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_RadarSensor.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source/gameengine/Ketsji/KX_RadarSensor.cpp') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 77cde79b54d..355ac89a926 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -300,18 +300,10 @@ PyAttributeDef KX_RadarSensor::Attributes[] = { PyObject* KX_RadarSensor::py_getattro(PyObject *attr) { - PyObject* object = py_getattro_self(Attributes, this, attr); - if (object != NULL) - return object; - py_getattro_up(KX_NearSensor); } int KX_RadarSensor::py_setattro(PyObject *attr, PyObject* value) { - int ret = py_setattro_self(Attributes, this, attr, value); - if (ret >= 0) - return ret; - - return KX_NearSensor::py_setattro(attr, value); + py_setattro_up(KX_NearSensor); } -- cgit v1.2.3 From 51b4145841293d4a695b7bbe88e90ebd98443fc8 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Tue, 7 Apr 2009 22:14:06 +0000 Subject: BGE Scenegraph and View frustrum culling improvement. This commit contains a number of performance improvements for the BGE in the Scenegraph (parent relation between objects in the scene) and view frustrum culling. The scenegraph improvement consists in avoiding position update if the object has not moved since last update and the removal of redundant updates and synchronization with the physics engine. The view frustrum culling improvement consists in using the DBVT broadphase facility of Bullet to build a tree of graphical objects in the scene. The elements of the tree are Aabb boxes (Aligned Axis Bounding Boxes) enclosing the objects. This provides good precision in closed and opened scenes. This new culling system is enabled by default but just in case, it can be disabled with a button in the World settings. There is no do_version in this commit but it will be added before the 2.49 release. For now you must manually enable the DBVT culling option in World settings when you open an old file. The above improvements speed up scenegraph and culling up to 5x. However, this performance improvement is only visible when you have hundreds or thousands of objects. The main interest of the DBVT tree is to allow easy occlusion culling and automatic LOD system. This will be the object of further improvements. --- source/gameengine/Ketsji/KX_RadarSensor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Ketsji/KX_RadarSensor.cpp') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 355ac89a926..b9abe69633e 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -100,8 +100,9 @@ CValue* KX_RadarSensor::GetReplica() //>m_sumoObj = new SM_Object(DT_NewCone(m_coneradius, m_coneheight),NULL,NULL,NULL); //replica->m_sumoObj->setMargin(m_Margin); //replica->m_sumoObj->setClientObject(replica->m_client_info); - - ((KX_GameObject*)replica->GetParent())->GetSGNode()->ComputeWorldTransforms(NULL); + //Wrong: see KX_TouchSensor + //bool parentUpdated = false; + //((KX_GameObject*)replica->GetParent())->GetSGNode()->ComputeWorldTransforms(NULL,parentUpdated); replica->SynchronizeTransform(); return replica; -- 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_RadarSensor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/gameengine/Ketsji/KX_RadarSensor.cpp') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index b9abe69633e..40af3b22aeb 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -254,9 +254,9 @@ PyTypeObject KX_RadarSensor::Type = { PyObject_HEAD_INIT(NULL) 0, "KX_RadarSensor", - sizeof(KX_RadarSensor), + 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_RadarSensor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/gameengine/Ketsji/KX_RadarSensor.cpp') diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index 40af3b22aeb..8277e7ef19c 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -207,7 +207,7 @@ const char KX_RadarSensor::GetConeOrigin_doc[] = "getConeOrigin()\n" "\tReturns the origin of the cone with which to test. The origin\n" "\tis in the middle of the cone."; -PyObject* KX_RadarSensor::PyGetConeOrigin(PyObject* self) { +PyObject* KX_RadarSensor::PyGetConeOrigin() { ShowDeprecationWarning("getConeOrigin()", "the coneOrigin property"); PyObject *retVal = PyList_New(3); @@ -223,7 +223,7 @@ PyObject* KX_RadarSensor::PyGetConeOrigin(PyObject* self) { const char KX_RadarSensor::GetConeTarget_doc[] = "getConeTarget()\n" "\tReturns the center of the bottom face of the cone with which to test.\n"; -PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self) { +PyObject* KX_RadarSensor::PyGetConeTarget() { ShowDeprecationWarning("getConeTarget()", "the coneTarget property"); PyObject *retVal = PyList_New(3); @@ -239,7 +239,7 @@ PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self) { const char KX_RadarSensor::GetConeHeight_doc[] = "getConeHeight()\n" "\tReturns the height of the cone with which to test.\n"; -PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self) { +PyObject* KX_RadarSensor::PyGetConeHeight() { ShowDeprecationWarning("getConeHeight()", "the distance property"); -- cgit v1.2.3