BGE patch #17569 approved: Make FrameProp: work in Shape Action. PyDoc updated.
authorBenoit Bolsee <benoit.bolsee@online.be>
Mon, 22 Sep 2008 21:49:48 +0000 (21:49 +0000)
committerBenoit Bolsee <benoit.bolsee@online.be>
Mon, 22 Sep 2008 21:49:48 +0000 (21:49 +0000)
source/gameengine/Converter/BL_ShapeActionActuator.cpp
source/gameengine/Converter/BL_ShapeActionActuator.h
source/gameengine/Converter/KX_ConvertActuators.cpp
source/gameengine/PyDoc/BL_ActionActuator.py
source/gameengine/PyDoc/BL_ShapeActionActuator.py

index 721c24dfb94bdcdc9c21d535a27488e1ee1f62ba..7a73420fc7ce8d38637e0425351943e734c6230b 100644 (file)
@@ -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"
index a9b9ad8fa865ff448be41afd7c6dfb30f03d1822..30b2d41fc67e1574d3eebc3be5fe45288eb9b4a0 100644 (file)
@@ -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;
 };
 
index e8be8de95ed7c2156f47db0b2270ffcab02275f9..78791c53d7c0646be5973b9fb072c1176d321663 100644 (file)
@@ -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,
index d56888cde8006a0a5b6784795d53426a61e1d220..b68d301411545e8587fb178a6e47c5b0cbafda09 100644 (file)
@@ -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
+               """
index 63cce253fa474ca0bf62d5448d23b6d49b015c24..a26b276a2dab948757436083e3800da3d9f86d41 100644 (file)
@@ -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
+               """