blender/source/gameengine/Converter
Porteries Tristan 95164a09a7 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
2015-10-26 20:27:08 +01:00
..
BL_ActionActuator.cpp BGE: Fix T30179 action actuator not stoped when state changed. 2015-10-23 10:54:08 +02:00
BL_ActionActuator.h BGE: Fix T30179 action actuator not stoped when state changed. 2015-10-23 10:54:08 +02:00
BL_ArmatureActuator.cpp BGE: Multi-threading animation updates and skinning. 2014-04-06 16:30:59 -07:00
BL_ArmatureActuator.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
BL_ArmatureChannel.cpp mathutils: refactor instantiation 2015-01-04 17:43:57 +11:00
BL_ArmatureChannel.h BGE: generic python callback list + replace KX_PythonSeq. 2015-10-26 20:27:08 +01:00
BL_ArmatureConstraint.cpp BGE Cleanup: The value of ikconstraint cannot be NULL at this stage and 2015-05-28 17:18:50 +02:00
BL_ArmatureConstraint.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
BL_ArmatureObject.cpp BGE: generic python callback list + replace KX_PythonSeq. 2015-10-26 20:27:08 +01:00
BL_ArmatureObject.h BGE: Multi-threading animation updates and skinning. 2014-04-06 16:30:59 -07:00
BL_BlenderDataConversion.cpp BGE: Cleanup ConvertMaterial function. 2015-10-21 22:28:33 +02:00
BL_BlenderDataConversion.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
BL_DeformableGameObject.cpp style cleanup 2013-03-18 11:44:56 +00:00
BL_DeformableGameObject.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
BL_MeshDeformer.cpp style cleanup 2012-10-22 08:15:51 +00:00
BL_MeshDeformer.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
BL_ModifierDeformer.cpp Make sure materials are updated before passing to renderer in game 2014-12-03 18:12:31 +01:00
BL_ModifierDeformer.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
BL_ShapeActionActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
BL_ShapeActionActuator.h Cleanup 2014-08-17 12:18:40 +10:00
BL_ShapeDeformer.cpp Fix T40113: Skinned meshes with non-animated shape keys crashes the BGE. 2014-05-09 16:05:23 -07:00
BL_ShapeDeformer.h BGE: Multi-threading animation updates and skinning. 2014-04-06 16:30:59 -07:00
BL_SkinDeformer.cpp Cleanup: use BLI_listbase_count_ex to avoid redundant looping 2014-11-16 14:23:37 +01:00
BL_SkinDeformer.h BGE: Fixing shape key animations on meshes with no armature. 2014-05-09 16:03:54 -07:00
CMakeLists.txt Audaspace: fixing problems for the merge to master suggested by Campbell and Sergey. 2015-07-28 14:01:53 +02:00
KX_BlenderScalarInterpolator.cpp code cleanup: remove redundant casts 2012-10-14 08:49:01 +00:00
KX_BlenderScalarInterpolator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_BlenderSceneConverter.cpp BGE: Fix issues with async libload. 2015-10-25 19:22:29 +01:00
KX_BlenderSceneConverter.h BGE: Fix issues with async libload. 2015-10-25 19:22:29 +01:00
KX_ConvertActuators.cpp BGE: Fix T46556: check on null sound datablock pointer. 2015-10-22 20:11:05 +02:00
KX_ConvertActuators.h BGE: Removing an unused rendertools argument from BL_ConvertActuators(). 2013-09-05 04:19:05 +00:00
KX_ConvertControllers.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ConvertControllers.h Cleanup: whitespace 2015-08-06 13:03:07 +10:00
KX_ConvertProperties.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ConvertProperties.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_ConvertSensors.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ConvertSensors.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_LibLoadStatus.cpp BGE: Fix issues with async libload. 2015-10-25 19:22:29 +01:00
KX_LibLoadStatus.h BGE: Fix issues with async libload. 2015-10-25 19:22:29 +01:00
KX_SoftBodyDeformer.cpp BGE Cleanup: Moving reinstancing physics shapes from KX_ConvertPhysicsObject to PHY_IPhysicsController 2014-04-23 19:39:57 -07:00
KX_SoftBodyDeformer.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
SConscript Audaspace: fixing problems for the merge to master suggested by Campbell and Sergey. 2015-07-28 14:01:53 +02:00