blender/source/gameengine/GameLogic
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
..
Joystick BGE: Fix for regressions T43883 and T43456 (and T43876 likely). SDL joystick related 2015-03-07 21:27:30 +01:00
CMakeLists.txt clang/cmake - quiet warnings for external libs and reference moto as a system include. 2013-07-15 08:26:16 +00:00
SCA_2DFilterActuator.cpp BGE: Fixing a crash that occurred when LibLoading a scene with a 2D Filter Actuator. The actuator was still referencing the old scene. 2012-12-31 21:32:46 +00:00
SCA_2DFilterActuator.h BGE: Fixing a crash that occurred when LibLoading a scene with a 2D Filter Actuator. The actuator was still referencing the old scene. 2012-12-31 21:32:46 +00:00
SCA_ActuatorEventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
SCA_ActuatorEventManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_ActuatorSensor.cpp use defines for property name lenghths in the BGE, were using 31,32,64,100. 2012-01-16 05:27:11 +00:00
SCA_ActuatorSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_AlwaysEventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
SCA_AlwaysEventManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_AlwaysSensor.cpp code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
SCA_AlwaysSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_ANDController.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_ANDController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_BasicEventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
SCA_BasicEventManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_DelaySensor.cpp code cleanup: check for msvc directly when using warning pragma's. 2012-10-15 02:15:07 +00:00
SCA_DelaySensor.h Cleanup: warning & whitespace 2015-10-26 22:22:30 +11:00
SCA_EventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
SCA_EventManager.h BGE cleanup: Removing the unused SCA_EventManager::Replace_PhysicsScene(). 2014-05-01 19:43:07 -07:00
SCA_ExpressionController.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_ExpressionController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_IActuator.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
SCA_IActuator.h BGE: Fix T30179 action actuator not stoped when state changed. 2015-10-23 10:54:08 +02:00
SCA_IController.cpp BGE: generic python callback list + replace KX_PythonSeq. 2015-10-26 20:27:08 +01:00
SCA_IController.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_IInputDevice.cpp style cleanup 2012-09-16 04:58:18 +00:00
SCA_IInputDevice.h Cleanup: style 2015-01-21 11:57:11 +11:00
SCA_ILogicBrick.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_ILogicBrick.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_IObject.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_IObject.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_IScene.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_IScene.h BGE debug API and actuator 2014-07-11 16:00:14 -07:00
SCA_ISensor.cpp BGE: Fix for T42341 Sensor.frequency is badly named 2015-04-16 06:39:33 +02:00
SCA_ISensor.h BGE: Fix for T42341 Sensor.frequency is badly named 2015-04-16 06:39:33 +02:00
SCA_JoystickManager.cpp BGE: Adding a Python interface for handling joysticks without needing logic bricks. These new SCA_PythonJoystick objects can be accessed using bge.logic.joysticks, which is a list of joysticks. The length of the list is the number of maximum supported joysticks, and indexes that do not have a joystick available are set to None. This means joysticks can be checked for using something like: 2012-12-21 02:28:59 +00:00
SCA_JoystickManager.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
SCA_JoystickSensor.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_JoystickSensor.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_KeyboardManager.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_KeyboardManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_KeyboardSensor.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_KeyboardSensor.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_LogicManager.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_LogicManager.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_MouseManager.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_MouseManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_MouseSensor.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_MouseSensor.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_NANDController.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_NANDController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_NORController.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_NORController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_ORController.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_ORController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_PropertyActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_PropertyActuator.h BGE: Add level mode to property actuator 2014-07-17 22:49:40 -07:00
SCA_PropertyEventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
SCA_PropertyEventManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_PropertySensor.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_PropertySensor.h BGE: New Property sensor evaluation types 2014-06-16 14:56:36 -07:00
SCA_PythonController.cpp BGE: make error message more clear when trying to de/activate actuator from non-active controller 2015-09-15 00:01:32 -03:00
SCA_PythonController.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_PythonJoystick.cpp BGE: Fix for [#33839] "a logic.joysticks Crashes BGE" reported by Josiah Lane (solarlune). 2013-01-12 05:44:08 +00:00
SCA_PythonJoystick.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_PythonKeyboard.cpp py api cleanup, replace use... 2012-11-21 02:28:36 +00:00
SCA_PythonKeyboard.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_PythonMouse.cpp py api cleanup, replace use... 2012-11-21 02:28:36 +00:00
SCA_PythonMouse.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_RandomActuator.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_RandomActuator.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_RandomEventManager.cpp remove $Id: tags after discussion on the mailign list: http://markmail.org/message/fp7ozcywxum3ar7n 2011-10-23 17:52:20 +00:00
SCA_RandomEventManager.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_RandomNumberGenerator.cpp style cleanup, use { on newline after function definition. 2012-02-25 16:49:59 +00:00
SCA_RandomNumberGenerator.h optionally use guarded alloc for tiles compositor, also replace allocation functions with a macro. 2012-06-25 09:14:37 +00:00
SCA_RandomSensor.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_RandomSensor.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_TimeEventManager.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_TimeEventManager.h BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_XNORController.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_XNORController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SCA_XORController.cpp BGE Clean-up: New EXP prefix for the BGE Expression module 2015-07-12 16:58:12 +02:00
SCA_XORController.h code cleanup: make header defines more consistent, JOYSENSOR header guard had a typo too. 2012-10-09 13:36:42 +00:00
SConscript split bge includes for scons onto their own lines (for easier merging) 2013-05-29 21:56:55 +00:00