Blender Git Commit Log

Git Commits -> Revision 8d2cb5b

Revision 8d2cb5b by Campbell Barton (master)
April 19, 2009, 12:46 (GMT)
BGE Python API

This changes how the BGE classes and Python work together, which hasnt changed since blender went opensource.
The main difference is PyObjectPlus - the base class for most game engine classes, no longer inherit from PyObject, and cannot be cast to a PyObject.

This has the advantage that the BGE does not have to keep 2 reference counts valid for C++ and Python.

Previously C++ classes would never be freed while python held a reference, however this reference could be problematic eg: a GameObject that isnt in a scene anymore should not be used by python, doing so could even crash blender in some cases.

Instead PyObjectPlus has a member "PyObject *m_proxy" which is lazily initialized when python needs it. m_proxy reference counts are managed by python, though it should never be freed while the C++ class exists since it holds a reference to avoid making and freeing it all the time.
When the C++ class is free'd it sets the m_proxy reference to NULL, If python accesses this variable it will raise a RuntimeError, (check the isValid attribute to see if its valid without raising an error).
- This replaces the m_zombie bool and IsZombie() tests added recently.

In python return values that used to be..
return value->AddRef();
Are now
return value->GetProxy();
or...
return value->NewProxy(true); // true means python owns this C++ value which will be deleted when the PyObject is freed

Commit Details:

Full Hash: 8d2cb5bea44f4245dd17f2d82cbd0251d8090fd5
SVN Revision: 19788
Parent Commit: 92cea7c
Lines Changed: +377, -294

33 Modified Paths:

/source/gameengine/Converter/BL_BlenderDataConversion.cpp (+1, -1) (Diff)
/source/gameengine/Expressions/InputParser.cpp (+1, -1) (Diff)
/source/gameengine/Expressions/ListValue.cpp (+47, -20) (Diff)
/source/gameengine/Expressions/ListValue.h (+3, -1) (Diff)
/source/gameengine/Expressions/PyObjectPlus.cpp (+62, -7) (Diff)
/source/gameengine/Expressions/PyObjectPlus.h (+72, -65) (Diff)
/source/gameengine/Expressions/Value.cpp (+1, -10) (Diff)
/source/gameengine/Expressions/Value.h (+0, -16) (Diff)
/source/gameengine/GameLogic/SCA_ILogicBrick.cpp (+1, -2) (Diff)
/source/gameengine/GameLogic/SCA_PythonController.cpp (+8, -8) (Diff)
/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp (+8, -8) (Diff)
/source/gameengine/Ketsji/KX_BlenderMaterial.cpp (+3, -9) (Diff)
/source/gameengine/Ketsji/KX_CameraActuator.cpp (+2, -2) (Diff)
/source/gameengine/Ketsji/KX_GameObject.cpp (+67, -68) (Diff)
/source/gameengine/Ketsji/KX_GameObject.h (+4, -2) (Diff)
/source/gameengine/Ketsji/KX_MeshProxy.cpp (+4, -6) (Diff)
/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp (+2, -2) (Diff)
/source/gameengine/Ketsji/KX_ParentActuator.cpp (+2, -2) (Diff)
/source/gameengine/Ketsji/KX_PolygonMaterial.cpp (+1, -2) (Diff)
/source/gameengine/Ketsji/KX_PolyProxy.cpp (+5, -9) (Diff)
/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp (+2, -2) (Diff)
/source/gameengine/Ketsji/KX_PythonInit.cpp (+3, -8) (Diff)
/source/gameengine/Ketsji/KX_PythonInitTypes.cpp (+3, -3) (Diff)
/source/gameengine/Ketsji/KX_RaySensor.cpp (+2, -2) (Diff)
/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp (+4, -5) (Diff)
/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp (+1, -1) (Diff)
/source/gameengine/Ketsji/KX_Scene.cpp (+5, -8) (Diff)
/source/gameengine/Ketsji/KX_SceneActuator.cpp (+35, -9) (Diff)
/source/gameengine/Ketsji/KX_TouchSensor.cpp (+4, -4) (Diff)
/source/gameengine/Ketsji/KX_TrackToActuator.cpp (+2, -2) (Diff)
/source/gameengine/Ketsji/KX_VehicleWrapper.cpp (+4, -1) (Diff)
/source/gameengine/VideoTexture/FilterSource.h (+2, -1) (Diff)
/source/gameengine/VideoTexture/ImageRender.cpp (+16, -7) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021