blender/source/gameengine/Ketsji
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
..
KXNetwork BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
BL_Action.cpp BGE: Cleanup BL_Action 2015-10-19 20:28:05 +02:00
BL_Action.h BGE: Cleanup BL_Action. 2015-10-19 20:27:04 +02:00
BL_ActionManager.cpp BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
BL_ActionManager.h BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
BL_BlenderShader.cpp OpenSubdiv: Commit of OpenSubdiv integration into Blender 2015-07-20 22:29:26 +02:00
BL_BlenderShader.h Fix a few compiler warnings reported by clang. 2013-08-18 14:15:51 +00:00
BL_Material.cpp Move from MTFace to MTexPoly w/ texture checks 2015-07-14 22:36:00 +10:00
BL_Material.h Move from MTFace to MTexPoly w/ texture checks 2015-07-14 22:36:00 +10:00
BL_Shader.cpp BGE: Cleanup: Code style BL_Shader 2015-10-25 19:43:46 +01:00
BL_Shader.h BGE: Cleanup: Code style BL_Shader 2015-10-25 19:43:46 +01:00
BL_Texture.cpp BGE: Fix T37074: GLSL max texture units limit 2015-07-27 20:34:13 +02:00
BL_Texture.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
CMakeLists.txt BGE: generic python callback list + replace KX_PythonSeq. 2015-10-26 20:27:08 +01:00
KX_ArmatureSensor.cpp style cleanup 2013-03-18 11:44:56 +00:00
KX_ArmatureSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_BlenderMaterial.cpp Move from MTFace to MTexPoly w/ texture checks 2015-07-14 22:36:00 +10:00
KX_BlenderMaterial.h Move from MTFace to MTexPoly w/ texture checks 2015-07-14 22:36:00 +10:00
KX_Camera.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_Camera.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_CameraActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_CameraActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_CameraIpoSGController.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_CameraIpoSGController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_CharacterWrapper.cpp BGE: Adding a Max Jumps value to the character physic window 2015-10-11 18:28:43 +02:00
KX_CharacterWrapper.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ClientObjectInfo.h BGE: Fix T35288 Touch/Ray/Mouse sensor and Constraint actuator with material check doesn't work. 2015-07-25 09:43:06 +02:00
KX_ConstraintActuator.cpp BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_ConstraintActuator.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_ConstraintWrapper.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ConstraintWrapper.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_Dome.cpp BGE: Fix T45110, T44174, armature animations update and mirror render. 2015-06-22 18:16:31 +02:00
KX_Dome.h Ghost Context Refactor 2014-10-07 15:47:32 -05:00
KX_EmptyObject.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_EmptyObject.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_FontObject.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_FontObject.h fix D1130 renamed the enum OBJ_FONT to OBJ_TEXT to avoid naming conflicts in Windows 2015-03-16 18:46:40 +01:00
KX_GameActuator.cpp BGE: Adding a screenshot function to game actuator 2015-10-11 13:41:38 +02:00
KX_GameActuator.h BGE: Adding a screenshot function to game actuator 2015-10-11 13:41:38 +02:00
KX_GameObject.cpp BGE: generic python callback list + replace KX_PythonSeq. 2015-10-26 20:27:08 +01:00
KX_GameObject.h BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
KX_IInterpolator.h style cleanup 2012-09-16 04:58:18 +00:00
KX_IPO_SGController.cpp BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_IPO_SGController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_IpoActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_IpoActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_IpoConvert.cpp BGE: Adding material IPO support to GLSL materials 2015-05-11 23:05:04 -07:00
KX_IpoConvert.h BGE: Fix T27322: World F-Curve 2015-03-23 21:43:42 +01:00
KX_IPOTransform.h style cleanup 2012-10-29 02:11:40 +00:00
KX_IScalarInterpolator.h style cleanup 2012-09-16 04:58:18 +00:00
KX_ISceneConverter.h BGE: Fix issues with async libload. 2015-10-25 19:22:29 +01:00
KX_ISystem.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_KetsjiEngine.cpp BGE: Fix issues with async libload. 2015-10-25 19:22:29 +01:00
KX_KetsjiEngine.h BGE: added bge.logic.{get,set}AnimRecordFrame functions 2015-08-25 13:42:09 +02:00
KX_Light.cpp BGE : addObject in python without reference object. 2015-04-26 16:29:58 +02:00
KX_Light.h BGE : addObject in python without reference object. 2015-04-26 16:29:58 +02:00
KX_LightIpoSGController.cpp BGE code cleanup: Removing OpenGL and bf_gpu code from KX_LightObject 2014-03-27 22:32:06 -07:00
KX_LightIpoSGController.h Code cleanup: RAS_ILightObject is class, not a struct. 2014-04-12 20:12:07 +02:00
KX_MaterialIpoController.cpp BGE: Adding material IPO support to GLSL materials 2015-05-11 23:05:04 -07:00
KX_MaterialIpoController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_MeshProxy.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_MeshProxy.h style cleanup 2013-03-29 06:21:28 +00:00
KX_MotionState.cpp BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_MotionState.h BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_MouseActuator.cpp Fix for building without Python 2015-06-14 04:53:10 +10:00
KX_MouseActuator.h Fix for building without Python 2015-06-14 04:53:10 +10:00
KX_MouseFocusSensor.cpp BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_MouseFocusSensor.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_NavMeshObject.cpp BGE: Navmesh fixes and improvements 2015-07-28 13:54:41 +02:00
KX_NavMeshObject.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_NearSensor.cpp Fix T38539: Can't set near sensor distance above 100 via python 2014-02-22 13:57:12 +11:00
KX_NearSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_ObColorIpoSGController.cpp BGE: Object color channels can now be animated separately without zeroing out the other channels. Problem reported by Dalai via IRC. 2013-02-23 01:17:01 +00:00
KX_ObColorIpoSGController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_ObjectActuator.cpp Fix T44919: BGE marhutils attrs leak memory 2015-06-02 11:08:17 +10:00
KX_ObjectActuator.h BGE: Fix: Double jumps are not working with character motion actuator 2015-05-14 09:45:51 +02:00
KX_ObstacleSimulation.cpp fix memory leak in KX_ObstacleSimulation 2013-08-04 17:20:03 +00:00
KX_ObstacleSimulation.h style cleanup 2012-09-16 04:58:18 +00:00
KX_OrientationInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_OrientationInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_ParentActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_ParentActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_PhysicsEngineEnums.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_PolyProxy.cpp BGE: Fix T38030: wrong vertex index returned by KX_PolyProxy 2015-06-20 14:21:31 +02:00
KX_PolyProxy.h code cleanup: remove unused define, correct header guard mismatch, add NULL check so DM_to_mesh() can have a NULL object passed (currently not used) and remove redundant NULL check. 2013-08-03 23:58:17 +00:00
KX_PositionInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_PositionInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_PyConstraintBinding.cpp BGE: Fix memory leak and crash with certain physic types 2015-08-16 11:38:25 +02:00
KX_PyConstraintBinding.h BGE: python API cleanup - bge submodules definitions 2015-02-03 15:32:54 +00:00
KX_PyMath.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_PyMath.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_PythonInit.cpp Cleanup: remove _POSIX_C_SOURCE undefine 2015-10-20 14:06:29 +11:00
KX_PythonInit.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_PythonInitTypes.cpp BGE: generic python callback list + replace KX_PythonSeq. 2015-10-26 20:27:08 +01:00
KX_PythonInitTypes.h Recreating bge python modules instead of using existing 2015-02-09 20:56:38 +00:00
KX_PythonMain.cpp code cleanup: remove $Id's that crept back in, also osl style edits 2012-10-23 11:47:23 +00:00
KX_PythonMain.h Fix T37488: Crash with --debug reading userpref.blend 2013-11-18 18:13:23 +06:00
KX_RadarSensor.cpp BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_RadarSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_RayCast.cpp BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_RayCast.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_RayEventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_RayEventManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_RaySensor.cpp BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_RaySensor.h BGE : Collision mask support in raycast + and raycast cleanup. 2015-10-07 22:14:43 +02:00
KX_SCA_AddObjectActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_SCA_AddObjectActuator.h style cleanup: trailing tabs & expand some non prefix tabs into spaces. 2012-10-21 05:46:41 +00:00
KX_SCA_DynamicActuator.cpp BGE: Fix T19377 restore dynamics after unparenting object. 2015-08-10 17:08:11 +02:00
KX_SCA_DynamicActuator.h BGE: Cleaning up the BGE's physics code and removing KX_IPhysicsController and KX_BulletPhysicsController. Instead, we just use PHY_IPhysicsController, which removes a lot of duplicate code. 2013-11-04 19:22:47 +00:00
KX_SCA_EndObjectActuator.cpp code cleanup: some warnings and formatting for PyMethodDef's in the BGE. 2012-11-10 05:42:50 +00:00
KX_SCA_EndObjectActuator.h style cleanup: also correct some doxy comments 2012-08-18 13:07:48 +00:00
KX_SCA_ReplaceMeshActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_SCA_ReplaceMeshActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_ScalarInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_ScalarInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_ScalingInterpolator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
KX_ScalingInterpolator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
KX_Scene.cpp BGE: Fix T46381 : last action frame not updated. 2015-10-19 16:03:40 +02:00
KX_Scene.h BGE: Add recursive dupli group deletion 2015-10-11 14:08:38 +02:00
KX_SceneActuator.cpp style cleanup: 2013-03-26 07:29:01 +00:00
KX_SceneActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
KX_SG_BoneParentNodeRelationship.cpp style cleanup 2012-09-16 04:58:18 +00:00
KX_SG_BoneParentNodeRelationship.h style cleanup 2012-09-16 04:58:18 +00:00
KX_SG_NodeRelationships.cpp style cleanup 2012-09-16 04:58:18 +00:00
KX_SG_NodeRelationships.h style cleanup 2012-09-16 04:58:18 +00:00
KX_SoundActuator.cpp Fix T46458: BGE Crash on load 2015-10-13 08:43:41 +11:00
KX_SoundActuator.h Audaspace: fixing problems for the merge to master suggested by Campbell and Sergey. 2015-07-28 14:01:53 +02:00
KX_StateActuator.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_StateActuator.h use __ prefix on header guards to avoid mixing up defines with api functions / classes. 2012-02-23 10:41:31 +00:00
KX_SteeringActuator.cpp Cleanup: style 2015-09-02 18:39:19 +10:00
KX_SteeringActuator.h BGE: Fix T41502 Path following jumping 2015-02-18 23:24:02 +01:00
KX_TimeCategoryLogger.cpp code cleanup: float formatting was confusing in some cases - eg: (0.,0.,0.) 2012-04-11 08:15:13 +00:00
KX_TimeCategoryLogger.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
KX_TimeLogger.cpp code cleanup: float formatting was confusing in some cases - eg: (0.,0.,0.) 2012-04-11 08:15:13 +00:00
KX_TimeLogger.h code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
KX_TouchEventManager.cpp BGE physics: When colliding, report first contact point to Python 2015-02-08 15:52:13 +01:00
KX_TouchEventManager.h BGE physics: When colliding, report first contact point to Python 2015-02-08 15:52:13 +01:00
KX_TouchSensor.cpp BGE: Fix T35288 Touch/Ray/Mouse sensor and Constraint actuator with material check doesn't work. 2015-07-25 09:43:06 +02:00
KX_TouchSensor.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_TrackToActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_TrackToActuator.h BGE: TrackTo actuator: increasing up & track axis options 2014-07-14 18:30:27 -07:00
KX_VehicleWrapper.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_VehicleWrapper.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
KX_VertexProxy.cpp Revert "BGE : KX_VertexProxy support for more than 2 UV channel." 2015-06-06 13:12:27 -07:00
KX_VertexProxy.h Revert "BGE : KX_VertexProxy support for more than 2 UV channel." 2015-06-06 13:12:27 -07:00
KX_VisibilityActuator.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
KX_VisibilityActuator.h use __ prefix on header guards to avoid mixing up defines with api functions / classes. 2012-02-23 10:41:31 +00:00
KX_WorldInfo.cpp BGE: Change KX_WolrdInfo mathutils vector to color 2015-10-11 18:43:05 +02:00
KX_WorldInfo.h Fix for building with C++ guarded alloc 2015-09-08 19:42:58 +10:00
KX_WorldIpoController.cpp BGE: Fix T27322: World F-Curve 2015-03-23 21:43:42 +01:00
KX_WorldIpoController.h BGE: Fix T27322: World F-Curve 2015-03-23 21:43:42 +01:00
SConscript SCons: Fix for really nasty bug with polluting configuration environment 2015-08-04 18:06:28 +02:00