[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [18626] trunk/blender/source/gameengine: BGE API cleanup: shape action actuator.

Benoit Bolsee benoit.bolsee at online.be
Thu Jan 22 18:40:50 CET 2009


Revision: 18626
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18626
Author:   ben2610
Date:     2009-01-22 18:40:47 +0100 (Thu, 22 Jan 2009)

Log Message:
-----------
BGE API cleanup: shape action actuator.

Modified Paths:
--------------
    trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp
    trunk/blender/source/gameengine/Converter/BL_ActionActuator.h
    trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.cpp
    trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.h
    trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
    trunk/blender/source/gameengine/PyDoc/BL_ActionActuator.py
    trunk/blender/source/gameengine/PyDoc/BL_ShapeActionActuator.py

Modified: trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp	2009-01-22 15:52:04 UTC (rev 18625)
+++ trunk/blender/source/gameengine/Converter/BL_ActionActuator.cpp	2009-01-22 17:40:47 UTC (rev 18626)
@@ -39,10 +39,9 @@
 #include "BL_SkinDeformer.h"
 #include "KX_GameObject.h"
 #include "STR_HashedString.h"
-#include "DNA_action_types.h"
 #include "DNA_nla_types.h"
-#include "DNA_actuator_types.h"
 #include "BKE_action.h"
+#include "DNA_action_types.h"
 #include "DNA_armature_types.h"
 #include "MEM_guardedalloc.h"
 #include "BLI_blenlib.h"
@@ -51,7 +50,6 @@
 #include "BKE_utildefines.h"
 #include "FloatValue.h"
 #include "PyObjectPlus.h"
-
 #include "blendef.h"
 
 #ifdef HAVE_CONFIG_H
@@ -843,11 +841,11 @@
     }
 
 	switch (typeArg) {
-	case KX_ACT_ACTION_PLAY:
-	case KX_ACT_ACTION_FLIPPER:
-	case KX_ACT_ACTION_LOOPSTOP:
-	case KX_ACT_ACTION_LOOPEND:
-	case KX_ACT_ACTION_PROPERTY:
+	case ACT_ACTION_PLAY:
+	case ACT_ACTION_FLIPPER:
+	case ACT_ACTION_LOOP_STOP:
+	case ACT_ACTION_LOOP_END:
+	case ACT_ACTION_FROM_PROP:
 		m_playtype = typeArg;
 		break;
 	default:
@@ -1033,7 +1031,7 @@
 	KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ActionActuator, m_framepropname),
 	KX_PYATTRIBUTE_BOOL_RW("continue", BL_ActionActuator, m_end_reset),
 	KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
-	KX_PYATTRIBUTE_ENUM_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType),
+	KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ActionActuator,m_playtype,CheckType),
 	{ NULL }	//Sentinel
 };
 

Modified: trunk/blender/source/gameengine/Converter/BL_ActionActuator.h
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ActionActuator.h	2009-01-22 15:52:04 UTC (rev 18625)
+++ trunk/blender/source/gameengine/Converter/BL_ActionActuator.h	2009-01-22 17:40:47 UTC (rev 18626)
@@ -32,6 +32,7 @@
 
 #include "GEN_HashedPtr.h"
 #include "SCA_IActuator.h"
+#include "DNA_actuator_types.h"
 #include "MT_Point3.h"
 
 class BL_ActionActuator : public SCA_IActuator  
@@ -112,15 +113,6 @@
 	virtual PyObject* _getattr(const STR_String& attr);
 	virtual int _setattr(const STR_String& attr, PyObject* value);
 
-	enum ActionActType
-	{
-		KX_ACT_ACTION_PLAY = 0,
-		KX_ACT_ACTION_FLIPPER = 2,
-		KX_ACT_ACTION_LOOPSTOP,
-		KX_ACT_ACTION_LOOPEND,
-		KX_ACT_ACTION_PROPERTY = 6
-	};
-
 	/* attribute check */
 	static int CheckFrame(void *self, const PyAttributeDef*)
 	{
@@ -138,7 +130,7 @@
 	{
 		BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
 
-		if (act->m_blendframe < act->m_blendin)
+		if (act->m_blendframe > act->m_blendin)
 			act->m_blendframe = act->m_blendin;
 
 		return 0;
@@ -149,11 +141,11 @@
 		BL_ActionActuator* act = reinterpret_cast<BL_ActionActuator*>(self);
 
 		switch (act->m_playtype) {
-			case KX_ACT_ACTION_PLAY:
-			case KX_ACT_ACTION_FLIPPER:
-			case KX_ACT_ACTION_LOOPSTOP:
-			case KX_ACT_ACTION_LOOPEND:
-			case KX_ACT_ACTION_PROPERTY:
+			case ACT_ACTION_PLAY:
+			case ACT_ACTION_FLIPPER:
+			case ACT_ACTION_LOOP_STOP:
+			case ACT_ACTION_LOOP_END:
+			case ACT_ACTION_FROM_PROP:
 				return 0;
 			default:
 				PyErr_SetString(PyExc_ValueError, "invalid type supplied");

Modified: trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.cpp	2009-01-22 15:52:04 UTC (rev 18625)
+++ trunk/blender/source/gameengine/Converter/BL_ShapeActionActuator.cpp	2009-01-22 17:40:47 UTC (rev 18626)
@@ -35,13 +35,11 @@
 
 #include "SCA_LogicManager.h"
 #include "BL_ShapeActionActuator.h"
-#include "BL_ActionActuator.h"
 #include "BL_ShapeDeformer.h"
 #include "KX_GameObject.h"
 #include "STR_HashedString.h"
+#include "DNA_nla_types.h"
 #include "DNA_action_types.h"
-#include "DNA_nla_types.h"
-#include "DNA_actuator_types.h"
 #include "BKE_action.h"
 #include "DNA_armature_types.h"
 #include "MEM_guardedalloc.h"
@@ -51,6 +49,7 @@
 #include "BKE_utildefines.h"
 #include "FloatValue.h"
 #include "PyObjectPlus.h"
+#include "blendef.h"
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
@@ -471,16 +470,73 @@
 	{NULL,NULL} //Sentinel
 };
 
+PyAttributeDef BL_ShapeActionActuator::Attributes[] = {
+	KX_PYATTRIBUTE_FLOAT_RW("start", 0, MAXFRAMEF, BL_ShapeActionActuator, m_startframe),
+	KX_PYATTRIBUTE_FLOAT_RW("end", 0, MAXFRAMEF, BL_ShapeActionActuator, m_endframe),
+	KX_PYATTRIBUTE_FLOAT_RW("blendin", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendin),
+	KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ShapeActionActuator, m_priority),
+	KX_PYATTRIBUTE_FLOAT_RW_CHECK("frame", 0, MAXFRAMEF, BL_ShapeActionActuator, m_localtime, CheckFrame),
+	KX_PYATTRIBUTE_STRING_RW("property", 0, 31, false, BL_ShapeActionActuator, m_propname),
+	KX_PYATTRIBUTE_STRING_RW("frameProperty", 0, 31, false, BL_ShapeActionActuator, m_framepropname),
+	KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ShapeActionActuator, m_blendframe, CheckBlendTime),
+	KX_PYATTRIBUTE_SHORT_RW_CHECK("type",0,100,false,BL_ShapeActionActuator,m_playtype,CheckType),
+	{ NULL }	//Sentinel
+};
+
+
 PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) {
+	if (attr == "action")
+		return PyString_FromString(m_action->id.name+2);
+	PyObject* object = _getattr_self(Attributes, this, attr);
+	if (object != NULL)
+		return object;
 	_getattr_up(SCA_IActuator);
 }
 
+int BL_ShapeActionActuator::_setattr(const STR_String& attr, PyObject* value) {
+	if (attr == "action")
+	{
+		if (!PyString_Check(value))
+		{
+			PyErr_SetString(PyExc_ValueError, "expected a string");
+			return 1;
+		}
+
+		STR_String val = PyString_AsString(value);
+		
+		if (val == "")
+		{
+			m_action = NULL;
+			return 0;
+		}
+
+		bAction *action;
+		
+		action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
+		
+
+		if (!action)
+		{
+			PyErr_SetString(PyExc_ValueError, "action not found!");
+			return 1;
+		}
+
+		m_action = action;
+		return 0;
+	}
+	int ret = _setattr_self(Attributes, this, attr, value);
+	if (ret >= 0)
+		return ret;
+	return SCA_IActuator::_setattr(attr, value);
+}
+
 /*     setStart                                                              */
 const char BL_ShapeActionActuator::GetAction_doc[] = 
 "getAction()\n"
 "\tReturns a string containing the name of the current action.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) {
+	ShowDeprecationWarning("getAction()", "the action property");
 	if (m_action){
 		return PyString_FromString(m_action->id.name+2);
 	}
@@ -493,6 +549,7 @@
 "\tReturns the name of the property to be used in FromProp mode.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self) {
+	ShowDeprecationWarning("getProperty()", "the property property");
 	PyObject *result;
 	
 	result = Py_BuildValue("s", (const char *)m_propname);
@@ -506,6 +563,7 @@
 "\tReturns the current frame number.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self) {
+	ShowDeprecationWarning("getFrame()", "the frame property");
 	PyObject *result;
 	
 	result = Py_BuildValue("f", m_localtime);
@@ -519,6 +577,7 @@
 "\tReturns the last frame of the action.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self) {
+	ShowDeprecationWarning("getEnd()", "the end property");
 	PyObject *result;
 	
 	result = Py_BuildValue("f", m_endframe);
@@ -532,6 +591,7 @@
 "\tReturns the starting frame of the action.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self) {
+	ShowDeprecationWarning("getStart()", "the start property");
 	PyObject *result;
 	
 	result = Py_BuildValue("f", m_startframe);
@@ -546,6 +606,7 @@
 "\tgenerated when this actuator is triggered.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self) {
+	ShowDeprecationWarning("getBlendin()", "the blendin property");
 	PyObject *result;
 	
 	result = Py_BuildValue("f", m_blendin);
@@ -560,6 +621,7 @@
 "\tPriority numbers will override actuators with higher numbers.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self) {
+	ShowDeprecationWarning("getPriority()", "the priority property");
 	PyObject *result;
 	
 	result = Py_BuildValue("i", m_priority);
@@ -581,6 +643,7 @@
 PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self, 
 											  PyObject* args, 
 											  PyObject* kwds) {
+	ShowDeprecationWarning("setAction()", "the action property");
 	char *string;
 	int	reset = 1;
 
@@ -615,6 +678,7 @@
 PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self, 
 											 PyObject* args, 
 											 PyObject* kwds) {
+	ShowDeprecationWarning("setStart()", "the start property");
 	float start;
 	
 	if (PyArg_ParseTuple(args,"f",&start))
@@ -636,6 +700,7 @@
 PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self, 
 										   PyObject* args, 
 										   PyObject* kwds) {
+	ShowDeprecationWarning("setEnd()", "the end property");
 	float end;
 	
 	if (PyArg_ParseTuple(args,"f",&end))
@@ -658,6 +723,7 @@
 PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self, 
 											   PyObject* args, 
 											   PyObject* kwds) {
+	ShowDeprecationWarning("setBlendin()", "the blendin property");
 	float blendin;
 	
 	if (PyArg_ParseTuple(args,"f",&blendin))
@@ -681,6 +747,7 @@
 PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self, 
 												 PyObject* args, 
 												   PyObject* kwds) {
+	ShowDeprecationWarning("setBlendtime()", "the blendTime property");
 	float blendframe;
 	
 	if (PyArg_ParseTuple(args,"f",&blendframe))
@@ -708,6 +775,7 @@
 PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, 
 												PyObject* args, 
 												PyObject* kwds) {
+	ShowDeprecationWarning("setPriority()", "the priority property");
 	int priority;
 	
 	if (PyArg_ParseTuple(args,"i",&priority))
@@ -727,6 +795,7 @@
 "\tReturns the name of the property, that is set to the current frame number.\n";
 
 PyObject* BL_ShapeActionActuator::PyGetFrameProperty(PyObject* self) {
+	ShowDeprecationWarning("getFrameProperty()", "the frameProperty property");
 	PyObject *result;
 	
 	result = Py_BuildValue("s", (const char *)m_framepropname);
@@ -743,6 +812,7 @@
 PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self, 
 											 PyObject* args, 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list