Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPorteries Tristan <republicthunderbolt9@gmail.com>2015-10-26 22:27:08 +0300
committerPorteries Tristan <republicthunderbolt9@gmail.com>2015-10-26 22:27:08 +0300
commit95164a09a73b5f72cfb21abfe608dfd0873b7706 (patch)
tree440302a0ada2776edb2b27c7830633e984669d82 /source/gameengine/Ketsji/CMakeLists.txt
parent5b3af3dd46307fcf5389f1ede9cfb9da77b120a4 (diff)
BGE: generic python callback list + replace KX_PythonSeq.
I made this patch to declared a python list without converting all elements in python object (too slow) or use a CListValue which required CValue items (too expensive in memory). In the case of a big list of points like a collision contacts points list, to use a CListValue we must implement a new class based on CValue for 3D vector to create a python proxy even if mathutils do it perfectly, we must also convert all points (frequently ~100 points) when fill the CListValue even if the list is not used (in the case of the collision callback). The easy way is to use callback (it doesn't worth to do an inheritance) which convert the item in PyObject only during an acces. 5 callbacks are used : - Check if the list is valid = allow acces (like PyObjectPlus.invalid) - Get the list size - Get an item in the list by index. - Get an item name in the list by index (used for operator `list["name"]`) - Set an item in the list at the index position. All of these callback take as first argument the client instance. Why do we use a void * for the client instance ? : In KX_PythonInitTypes.cpp we have to initialize each python inherited class, if we use a template (the only other way) we must add this class each time we use a new type with in KX_PythonInitTypes.cpp To check if the list can be accessed from python by the user, we check if the python proxy, which is the `m_base` member, is still a valid proxy like in PyObjectPlus. But we can use a callback for more control of user access (e.g a list of collision point invalidate a frame later, in this case no real python owner). This python list is easily defined with : ``` CPythonCallBackList( void *client, // The client instance PyObject *base, // The python instance which owned this list, used to know if the list is valid (like in KX_PythonSeq) bool (*checkValid)(void *), // A callback to check if this list is till valid (optional) int (*getSize)(void *), // A callback to get size PyObject *(*getItem)(void *, int), // A callback to get an item const char *(*getItemName)(void *, int), // A callback to get an item name (optional) use for acces by string key bool (*setItem)(void *, int, PyObject *) // A callback to set an item (optional) ) ``` To show its usecase i replaced the odd KX_PythonSeq, it modify KX_Gameobject.sensors/controllers/actuators, SCA_IController.sensors/actuators and BL_ArmatureObject.constraints/channels. Example : {F245193}, See message in console, press R to erase the object and see invalid proxy error message. Reviewers: brita_, #game_python, youle, campbellbarton, moguri, agoose77, sergey Reviewed By: campbellbarton, moguri, agoose77, sergey Subscribers: sergey Projects: #game_engine Differential Revision: https://developer.blender.org/D1363
Diffstat (limited to 'source/gameengine/Ketsji/CMakeLists.txt')
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt2
1 files changed, 0 insertions, 2 deletions
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index 2607e2bb4b7..a5bdb2c7c5f 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -108,7 +108,6 @@ set(SRC
KX_PythonInit.cpp
KX_PythonInitTypes.cpp
KX_PythonMain.cpp
- KX_PythonSeq.cpp
KX_RadarSensor.cpp
KX_RayCast.cpp
KX_RayEventManager.cpp
@@ -188,7 +187,6 @@ set(SRC
KX_PythonInit.h
KX_PythonInitTypes.h
KX_PythonMain.h
- KX_PythonSeq.h
KX_RadarSensor.h
KX_RayCast.h
KX_RayEventManager.h