diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-09-23 01:49:48 +0400 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-09-23 01:49:48 +0400 |
commit | 18c954e95ba8181a67a6e67246d5f507246db007 (patch) | |
tree | 606dd95c78cbf360a778346f3bb938feadea863c /source/gameengine | |
parent | 2875cc9cc68b9e57e7525d490fd8d57a3eba8653 (diff) |
BGE patch #17569 approved: Make FrameProp: work in Shape Action. PyDoc updated.
Diffstat (limited to 'source/gameengine')
5 files changed, 79 insertions, 4 deletions
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 721c24dfb94..7a73420fc7c 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -49,6 +49,7 @@ #include "BLI_arithb.h" #include "MT_Matrix4x4.h" #include "BKE_utildefines.h" +#include "FloatValue.h" #include "PyObjectPlus.h" #ifdef HAVE_CONFIG_H @@ -342,6 +343,18 @@ bool BL_ShapeActionActuator::Update(double curtime, bool frame) break; } + /* Set the property if its defined */ + if (m_framepropname[0] != '\0') { + CValue* propowner = GetParent(); + CValue* oldprop = propowner->GetProperty(m_framepropname); + CValue* newval = new CFloatValue(m_localtime); + if (oldprop) { + oldprop->SetValue(newval); + } else { + propowner->SetProperty(m_framepropname, newval); + } + newval->Release(); + } if (bNegativeEvent) m_blendframe=0.0f; @@ -442,6 +455,7 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = { {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc}, {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc}, {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc}, + {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, SetFrameProperty_doc}, {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc}, {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, GetAction_doc}, @@ -451,6 +465,7 @@ PyMethodDef BL_ShapeActionActuator::Methods[] = { {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, GetPriority_doc}, {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, GetFrame_doc}, {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, GetProperty_doc}, + {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, GetFrameProperty_doc}, {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, GetType_doc}, {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, SetType_doc}, {NULL,NULL} //Sentinel @@ -706,6 +721,20 @@ PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self, Py_RETURN_NONE; } +/* getProperty */ +const char BL_ShapeActionActuator::GetFrameProperty_doc[] = +"getFrameProperty()\n" +"\tReturns the name of the property, that is set to the current frame number.\n"; + +PyObject* BL_ShapeActionActuator::PyGetFrameProperty(PyObject* self) { + PyObject *result; + + result = Py_BuildValue("s", (const char *)m_framepropname); + + return result; +} + + /* setFrame */ const char BL_ShapeActionActuator::SetFrame_doc[] = "setFrame(frame)\n" @@ -753,6 +782,27 @@ PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self, Py_RETURN_NONE; } +/* setFrameProperty */ +const char BL_ShapeActionActuator::SetFrameProperty_doc[] = +"setFrameProperty(prop)\n" +"\t - prop : A string specifying the property of the frame set up update.\n"; + +PyObject* BL_ShapeActionActuator::PySetFrameProperty(PyObject* self, + PyObject* args, + PyObject* kwds) { + char *string; + + if (PyArg_ParseTuple(args,"s",&string)) + { + m_framepropname = string; + } + else { + return NULL; + } + + Py_RETURN_NONE; +} + /* getType */ const char BL_ShapeActionActuator::GetType_doc[] = "getType()\n" diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h index a9b9ad8fa86..30b2d41fc67 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.h +++ b/source/gameengine/Converter/BL_ShapeActionActuator.h @@ -42,6 +42,7 @@ public: Py_Header; BL_ShapeActionActuator(SCA_IObject* gameobj, const STR_String& propname, + const STR_String& framepropname, float starttime, float endtime, struct bAction *action, @@ -66,6 +67,7 @@ public: m_playtype(playtype), m_priority(priority), m_action(action), + m_framepropname(framepropname), m_propname(propname) { }; @@ -84,6 +86,7 @@ public: KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetEnd); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrame); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetProperty); + KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrameProperty); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendtime); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetChannel); @@ -94,6 +97,7 @@ public: KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetEnd); KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrame); KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetProperty); + KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrameProperty); // KX_PYMETHOD(BL_ActionActuator,GetChannel); KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType); KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType); @@ -126,6 +130,7 @@ protected: short m_priority; struct bAction *m_action; STR_String m_propname; + STR_String m_framepropname; vector<float> m_blendshape; }; diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index e8be8de95ed..78791c53d7c 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -210,10 +210,12 @@ void BL_ConvertActuators(char* maggiename, if (blenderobject->type==OB_MESH){ bActionActuator* actact = (bActionActuator*) bact->data; STR_String propname = (actact->name ? actact->name : ""); + STR_String propframe = (actact->frameProp ? actact->frameProp : ""); BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator( gameobj, propname, + propframe, actact->sta, actact->end, actact->act, diff --git a/source/gameengine/PyDoc/BL_ActionActuator.py b/source/gameengine/PyDoc/BL_ActionActuator.py index d56888cde80..b68d3014115 100644 --- a/source/gameengine/PyDoc/BL_ActionActuator.py +++ b/source/gameengine/PyDoc/BL_ActionActuator.py @@ -164,5 +164,14 @@ class BL_ActionActuator(SCA_IActuator): @param mode: True for armature/world space, False for bone space @type mode: boolean """ - - + def setFrameProperty(prop): + """ + @param prop: A string specifying the property of the object that will be updated with the action frame number. + @type prop: string + """ + def getFrameProperty(): + """ + Returns the name of the property that is set to the current frame number. + + @rtype: string + """ diff --git a/source/gameengine/PyDoc/BL_ShapeActionActuator.py b/source/gameengine/PyDoc/BL_ShapeActionActuator.py index 63cce253fa4..a26b276a2da 100644 --- a/source/gameengine/PyDoc/BL_ShapeActionActuator.py +++ b/source/gameengine/PyDoc/BL_ShapeActionActuator.py @@ -154,5 +154,14 @@ class BL_ShapeActionActuator(SCA_IActuator): @rtype: string """ - - + def setFrameProperty(prop): + """ + @param prop: A string specifying the property of the object that will be updated with the action frame number. + @type prop: string + """ + def getFrameProperty(): + """ + Returns the name of the property that is set to the current frame number. + + @rtype: string + """ |