[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19563] trunk/blender/source/gameengine: BGE Python API

Campbell Barton ideasman42 at gmail.com
Mon Apr 6 15:27:30 CEST 2009


Revision: 19563
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19563
Author:   campbellbarton
Date:     2009-04-06 15:27:28 +0200 (Mon, 06 Apr 2009)

Log Message:
-----------
BGE Python API
- added a module for the BGE - GameTypes, only contains types.
- added KX_PYATTRIBUTE_DUMMY attributes for KX_Light, KX_PolyProxy, KX_VertexProxy, so all types should give correct results from a dir().
- added a script to check for missing methods in the epydocs - bge_api_validate_py.txt
 

Modified Paths:
--------------
    trunk/blender/source/gameengine/GameLogic/SCA_MouseSensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_Light.cpp
    trunk/blender/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
    trunk/blender/source/gameengine/Ketsji/KX_VertexProxy.cpp

Added Paths:
-----------
    trunk/blender/source/gameengine/PyDoc/bge_api_validate_py.txt

Modified: trunk/blender/source/gameengine/GameLogic/SCA_MouseSensor.cpp
===================================================================
--- trunk/blender/source/gameengine/GameLogic/SCA_MouseSensor.cpp	2009-04-06 13:13:25 UTC (rev 19562)
+++ trunk/blender/source/gameengine/GameLogic/SCA_MouseSensor.cpp	2009-04-06 13:27:28 UTC (rev 19563)
@@ -275,7 +275,7 @@
 
 KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
 "getButtonStatus(button)\n"
-"\tGet the given button's status (KX_NO_INPUTSTATUS, KX_JUSTACTIVATED, KX_ACTIVE or KX_JUSTRELEASED).\n")
+"\tGet the given button's status (KX_INPUT_NONE, KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED).\n")
 {
 	if (PyInt_Check(value))
 	{

Modified: trunk/blender/source/gameengine/Ketsji/KX_Light.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Light.cpp	2009-04-06 13:13:25 UTC (rev 19562)
+++ trunk/blender/source/gameengine/Ketsji/KX_Light.cpp	2009-04-06 13:27:28 UTC (rev 19563)
@@ -236,7 +236,7 @@
 		}
 	}
 	
-	if (PyFloat_Check(pyvalue))
+	if (PyFloat_Check(pyvalue) || PyInt_Check(pyvalue))
 	{
 		float value = PyFloat_AsDouble(pyvalue);
 		if (!strcmp(attr_str, "energy"))
@@ -306,10 +306,22 @@
 };
 
 PyAttributeDef KX_LightObject::Attributes[] = {
+	KX_PYATTRIBUTE_DUMMY("layer"),
+	KX_PYATTRIBUTE_DUMMY("energy"),
+	KX_PYATTRIBUTE_DUMMY("distance"),
+	KX_PYATTRIBUTE_DUMMY("colour"),
+	KX_PYATTRIBUTE_DUMMY("color"),
+	KX_PYATTRIBUTE_DUMMY("lin_attenuation"),
+	KX_PYATTRIBUTE_DUMMY("quad_attenuation"),
+	KX_PYATTRIBUTE_DUMMY("spotsize"),
+	KX_PYATTRIBUTE_DUMMY("spotblend"),
+	KX_PYATTRIBUTE_DUMMY("SPOT"),
+	KX_PYATTRIBUTE_DUMMY("SUN"),
+	KX_PYATTRIBUTE_DUMMY("NORMAL"),
+	KX_PYATTRIBUTE_DUMMY("type"),
 	{ NULL }	//Sentinel
 };
 
-
 PyTypeObject KX_LightObject::Type = {
 	PyObject_HEAD_INIT(NULL)
 		0,

Modified: trunk/blender/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp	2009-04-06 13:13:25 UTC (rev 19562)
+++ trunk/blender/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp	2009-04-06 13:27:28 UTC (rev 19563)
@@ -343,7 +343,7 @@
 
 const char KX_MouseFocusSensor::GetHitObject_doc[] = 
 "getHitObject()\n"
-"\tReturns the name of the object that was hit by this ray.\n";
+"\tReturns the object that was hit by this ray.\n";
 PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self)
 {
 	if (m_hitObject)
@@ -374,7 +374,7 @@
 
 const char KX_MouseFocusSensor::GetHitNormal_doc[] = 
 "getHitNormal()\n"
-"\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n";
+"\tReturns the normal (in worldcoordinates) at the point of collision where the object was hit by this ray.\n";
 PyObject* KX_MouseFocusSensor::PyGetHitNormal(PyObject* self)
 {
 	return PyObjectFrom(m_hitNormal);

Modified: trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp	2009-04-06 13:13:25 UTC (rev 19562)
+++ trunk/blender/source/gameengine/Ketsji/KX_PolyProxy.cpp	2009-04-06 13:27:28 UTC (rev 19563)
@@ -78,6 +78,17 @@
 };
 
 PyAttributeDef KX_PolyProxy::Attributes[] = {
+	/* All dummy's so they come up in a dir() */
+	KX_PYATTRIBUTE_DUMMY("matname"),
+	KX_PYATTRIBUTE_DUMMY("texture"),
+	KX_PYATTRIBUTE_DUMMY("material"),
+	KX_PYATTRIBUTE_DUMMY("matid"),
+	KX_PYATTRIBUTE_DUMMY("v1"),
+	KX_PYATTRIBUTE_DUMMY("v2"),
+	KX_PYATTRIBUTE_DUMMY("v3"),
+	KX_PYATTRIBUTE_DUMMY("v4"),
+	KX_PYATTRIBUTE_DUMMY("visible"),
+	KX_PYATTRIBUTE_DUMMY("collide"),
 	{ NULL }	//Sentinel
 };
 

Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInitTypes.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInitTypes.cpp	2009-04-06 13:13:25 UTC (rev 19562)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInitTypes.cpp	2009-04-06 13:27:28 UTC (rev 19563)
@@ -129,6 +129,13 @@
 
 
 
+static int PyType_Ready_ADD(PyObject *dict, PyTypeObject * tp)
+{
+	PyType_Ready(tp);
+	PyDict_SetItemString(dict, tp->tp_name, (PyObject *)tp);
+}
+
+
 void initPyTypes(void)
 {
 	
@@ -138,69 +145,76 @@
 */
 
 	/* For now just do PyType_Ready */
-
-	PyType_Ready(&BL_ActionActuator::Type);
-	PyType_Ready(&BL_Shader::Type);
-	PyType_Ready(&BL_ShapeActionActuator::Type);
-	PyType_Ready(&CListValue::Type);
-	PyType_Ready(&CValue::Type);
-	PyType_Ready(&KX_BlenderMaterial::Type);
-	PyType_Ready(&KX_CDActuator::Type);
-	PyType_Ready(&KX_Camera::Type);
-	PyType_Ready(&KX_CameraActuator::Type);
-	PyType_Ready(&KX_ConstraintActuator::Type);
-	PyType_Ready(&KX_ConstraintWrapper::Type);
-	PyType_Ready(&KX_GameActuator::Type);
-	PyType_Ready(&KX_GameObject::Type);
-	PyType_Ready(&KX_IpoActuator::Type);
-	PyType_Ready(&KX_LightObject::Type);
-	PyType_Ready(&KX_MeshProxy::Type);
-	PyType_Ready(&KX_MouseFocusSensor::Type);
-	PyType_Ready(&KX_NearSensor::Type);
-	PyType_Ready(&KX_NetworkMessageActuator::Type);
-	PyType_Ready(&KX_NetworkMessageSensor::Type);
-	PyType_Ready(&KX_ObjectActuator::Type);
-	PyType_Ready(&KX_ParentActuator::Type);
-	PyType_Ready(&KX_PhysicsObjectWrapper::Type);
-	PyType_Ready(&KX_PolyProxy::Type);
-	PyType_Ready(&KX_PolygonMaterial::Type);
-	PyType_Ready(&KX_RadarSensor::Type);
-	PyType_Ready(&KX_RaySensor::Type);
-	PyType_Ready(&KX_SCA_AddObjectActuator::Type);
-	PyType_Ready(&KX_SCA_DynamicActuator::Type);
-	PyType_Ready(&KX_SCA_EndObjectActuator::Type);
-	PyType_Ready(&KX_SCA_ReplaceMeshActuator::Type);
-	PyType_Ready(&KX_Scene::Type);
-	PyType_Ready(&KX_SceneActuator::Type);
-	PyType_Ready(&KX_SoundActuator::Type);
-	PyType_Ready(&KX_StateActuator::Type);
-	PyType_Ready(&KX_TouchSensor::Type);
-	PyType_Ready(&KX_TrackToActuator::Type);
-	PyType_Ready(&KX_VehicleWrapper::Type);
-	PyType_Ready(&KX_VertexProxy::Type);
-	PyType_Ready(&KX_VisibilityActuator::Type);
-	PyType_Ready(&PyObjectPlus::Type);
-	PyType_Ready(&SCA_2DFilterActuator::Type);
-	PyType_Ready(&SCA_ANDController::Type);
-	PyType_Ready(&SCA_ActuatorSensor::Type);
-	PyType_Ready(&SCA_AlwaysSensor::Type);
-	PyType_Ready(&SCA_DelaySensor::Type);
-	PyType_Ready(&SCA_ILogicBrick::Type);
-	PyType_Ready(&SCA_IObject::Type);
-	PyType_Ready(&SCA_ISensor::Type);
-	PyType_Ready(&SCA_JoystickSensor::Type);
-	PyType_Ready(&SCA_KeyboardSensor::Type);
-	PyType_Ready(&SCA_MouseSensor::Type);
-	PyType_Ready(&SCA_NANDController::Type);
-	PyType_Ready(&SCA_NORController::Type);
-	PyType_Ready(&SCA_ORController::Type);
-	PyType_Ready(&SCA_PropertyActuator::Type);
-	PyType_Ready(&SCA_PropertySensor::Type);
-	PyType_Ready(&SCA_PythonController::Type);
-	PyType_Ready(&SCA_RandomActuator::Type);
-	PyType_Ready(&SCA_RandomSensor::Type);
-	PyType_Ready(&SCA_XNORController::Type);
-	PyType_Ready(&SCA_XORController::Type);
+	PyObject *mod= PyModule_New("GameTypes");
+	PyObject *dict= PyModule_GetDict(mod);
+	PyDict_SetItemString(PySys_GetObject("modules"), "GameTypes", mod);
+	Py_DECREF(mod);
+	
+	PyType_Ready_ADD(dict, &BL_ActionActuator::Type);
+	PyType_Ready_ADD(dict, &BL_Shader::Type);
+	PyType_Ready_ADD(dict, &BL_ShapeActionActuator::Type);
+	PyType_Ready_ADD(dict, &CListValue::Type);
+	PyType_Ready_ADD(dict, &CValue::Type);
+	PyType_Ready_ADD(dict, &KX_BlenderMaterial::Type);
+	PyType_Ready_ADD(dict, &KX_CDActuator::Type);
+	PyType_Ready_ADD(dict, &KX_Camera::Type);
+	PyType_Ready_ADD(dict, &KX_CameraActuator::Type);
+	PyType_Ready_ADD(dict, &KX_ConstraintActuator::Type);
+	PyType_Ready_ADD(dict, &KX_ConstraintWrapper::Type);
+	PyType_Ready_ADD(dict, &KX_GameActuator::Type);
+	PyType_Ready_ADD(dict, &KX_GameObject::Type);
+	PyType_Ready_ADD(dict, &KX_IpoActuator::Type);
+	PyType_Ready_ADD(dict, &KX_LightObject::Type);
+	PyType_Ready_ADD(dict, &KX_MeshProxy::Type);
+	PyType_Ready_ADD(dict, &KX_MouseFocusSensor::Type);
+	PyType_Ready_ADD(dict, &KX_NearSensor::Type);
+	PyType_Ready_ADD(dict, &KX_NetworkMessageActuator::Type);
+	PyType_Ready_ADD(dict, &KX_NetworkMessageSensor::Type);
+	PyType_Ready_ADD(dict, &KX_ObjectActuator::Type);
+	PyType_Ready_ADD(dict, &KX_ParentActuator::Type);
+	PyType_Ready_ADD(dict, &KX_PhysicsObjectWrapper::Type);
+	PyType_Ready_ADD(dict, &KX_PolyProxy::Type);
+	PyType_Ready_ADD(dict, &KX_PolygonMaterial::Type);
+	PyType_Ready_ADD(dict, &KX_RadarSensor::Type);
+	PyType_Ready_ADD(dict, &KX_RaySensor::Type);
+	PyType_Ready_ADD(dict, &KX_SCA_AddObjectActuator::Type);
+	PyType_Ready_ADD(dict, &KX_SCA_DynamicActuator::Type);
+	PyType_Ready_ADD(dict, &KX_SCA_EndObjectActuator::Type);
+	PyType_Ready_ADD(dict, &KX_SCA_ReplaceMeshActuator::Type);
+	PyType_Ready_ADD(dict, &KX_Scene::Type);
+	PyType_Ready_ADD(dict, &KX_SceneActuator::Type);
+	PyType_Ready_ADD(dict, &KX_SoundActuator::Type);
+	PyType_Ready_ADD(dict, &KX_StateActuator::Type);
+	PyType_Ready_ADD(dict, &KX_TouchSensor::Type);
+	PyType_Ready_ADD(dict, &KX_TrackToActuator::Type);
+	PyType_Ready_ADD(dict, &KX_VehicleWrapper::Type);
+	PyType_Ready_ADD(dict, &KX_VertexProxy::Type);
+	PyType_Ready_ADD(dict, &KX_VisibilityActuator::Type);
+	PyType_Ready_ADD(dict, &PyObjectPlus::Type);
+	PyType_Ready_ADD(dict, &SCA_2DFilterActuator::Type);
+	PyType_Ready_ADD(dict, &SCA_ANDController::Type);
+	PyType_Ready_ADD(dict, &SCA_ActuatorSensor::Type);
+	PyType_Ready_ADD(dict, &SCA_AlwaysSensor::Type);
+	PyType_Ready_ADD(dict, &SCA_DelaySensor::Type);
+	PyType_Ready_ADD(dict, &SCA_ILogicBrick::Type);
+	PyType_Ready_ADD(dict, &SCA_IObject::Type);
+	PyType_Ready_ADD(dict, &SCA_ISensor::Type);
+	PyType_Ready_ADD(dict, &SCA_JoystickSensor::Type);
+	PyType_Ready_ADD(dict, &SCA_KeyboardSensor::Type);
+	PyType_Ready_ADD(dict, &SCA_MouseSensor::Type);
+	PyType_Ready_ADD(dict, &SCA_NANDController::Type);
+	PyType_Ready_ADD(dict, &SCA_NORController::Type);
+	PyType_Ready_ADD(dict, &SCA_ORController::Type);
+	PyType_Ready_ADD(dict, &SCA_PropertyActuator::Type);
+	PyType_Ready_ADD(dict, &SCA_PropertySensor::Type);
+	PyType_Ready_ADD(dict, &SCA_PythonController::Type);
+	PyType_Ready_ADD(dict, &SCA_RandomActuator::Type);
+	PyType_Ready_ADD(dict, &SCA_RandomSensor::Type);
+	PyType_Ready_ADD(dict, &SCA_XNORController::Type);
+	PyType_Ready_ADD(dict, &SCA_XORController::Type);
+	
+	
+	
 }
 
 #endif
\ No newline at end of file

Modified: trunk/blender/source/gameengine/Ketsji/KX_VertexProxy.cpp

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list