svn merge ^/trunk/blender -r43124:43160
[blender.git] / source / gameengine / Converter / BL_ActionActuator.cpp
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19  * All rights reserved.
20  *
21  * The Original Code is: all of this file.
22  *
23  * Contributor(s): none yet.
24  *
25  * ***** END GPL LICENSE BLOCK *****
26  */
27
28 /** \file gameengine/Converter/BL_ActionActuator.cpp
29  *  \ingroup bgeconv
30  */
31
32
33 #include "SCA_LogicManager.h"
34 #include "BL_ActionActuator.h"
35 #include "BL_ArmatureObject.h"
36 #include "BL_SkinDeformer.h"
37 #include "BL_Action.h"
38 #include "KX_GameObject.h"
39 #include "STR_HashedString.h"
40 #include "MEM_guardedalloc.h"
41 #include "DNA_nla_types.h"
42 #include "DNA_action_types.h"
43 #include "DNA_armature_types.h"
44 #include "DNA_scene_types.h"
45 #include "BLI_blenlib.h"
46 #include "BLI_math.h"
47 #include "BLI_utildefines.h"
48 #include "MT_Matrix4x4.h"
49
50 #include "BKE_action.h"
51 #include "FloatValue.h"
52 #include "PyObjectPlus.h"
53 #include "KX_PyMath.h"
54
55 extern "C" {
56 #include "BKE_animsys.h"
57 #include "BKE_action.h"
58 #include "RNA_access.h"
59 #include "RNA_define.h"
60 }
61
62 BL_ActionActuator::BL_ActionActuator(SCA_IObject* gameobj,
63                                         const STR_String& propname,
64                                         const STR_String& framepropname,
65                                         float starttime,
66                                         float endtime,
67                                         struct bAction *action,
68                                         short   playtype,
69                                         short   blendin,
70                                         short   priority,
71                                         short   layer,
72                                         float   layer_weight,
73                                         short   ipo_flags,
74                                         short   end_reset,
75                                         float   stride) 
76         : SCA_IActuator(gameobj, KX_ACT_ACTION),
77                 
78         m_lastpos(0, 0, 0),
79         m_blendframe(0),
80         m_flag(0),
81         m_startframe (starttime),
82         m_endframe(endtime) ,
83         m_starttime(0),
84         m_localtime(starttime),
85         m_lastUpdate(-1),
86         m_blendin(blendin),
87         m_blendstart(0),
88         m_stridelength(stride),
89         m_layer_weight(layer_weight),
90         m_playtype(playtype),
91         m_priority(priority),
92         m_layer(layer),
93         m_ipo_flags(ipo_flags),
94         m_pose(NULL),
95         m_blendpose(NULL),
96         m_userpose(NULL),
97         m_action(action),
98         m_propname(propname),
99         m_framepropname(framepropname)          
100 {
101         if (!end_reset)
102                 m_flag |= ACT_FLAG_CONTINUE;
103 };
104
105 BL_ActionActuator::~BL_ActionActuator()
106 {
107         if (m_pose)
108                 game_free_pose(m_pose);
109         if (m_userpose)
110                 game_free_pose(m_userpose);
111         if (m_blendpose)
112                 game_free_pose(m_blendpose);
113 }
114
115 void BL_ActionActuator::ProcessReplica()
116 {
117         SCA_IActuator::ProcessReplica();
118         
119         m_pose = NULL;
120         m_blendpose = NULL;
121         m_localtime=m_startframe;
122         m_lastUpdate=-1;
123         
124 }
125
126 void BL_ActionActuator::SetBlendTime (float newtime)
127 {
128         m_blendframe = newtime;
129 }
130
131 void BL_ActionActuator::SetLocalTime(float curtime)
132 {
133         float dt = (curtime-m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
134
135         if (m_endframe < m_startframe)
136                 dt = -dt;
137
138         m_localtime = m_startframe + dt;
139         
140         // Handle wrap around
141         if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe))
142         {
143                 switch(m_playtype)
144                 {
145                 case ACT_ACTION_PLAY:
146                         // Clamp
147                         m_localtime = m_endframe;
148                         ((KX_GameObject*)GetParent())->StopAction(m_layer);
149                         break;
150                 case ACT_ACTION_LOOP_END:
151                         // Put the time back to the beginning
152                         m_localtime = m_startframe;
153                         m_starttime = curtime;
154                         break;
155                 case ACT_ACTION_PINGPONG:
156                         // Swap the start and end frames
157                         float temp = m_startframe;
158                         m_startframe = m_endframe;
159                         m_endframe = temp;
160
161                         m_starttime = curtime;
162
163                         m_flag ^= ACT_FLAG_REVERSE;
164
165                         break;
166                 }
167         }
168 }
169
170 void BL_ActionActuator::ResetStartTime(float curtime)
171 {
172         float dt = m_localtime - m_startframe;
173
174         m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate());
175         //SetLocalTime(curtime);
176 }
177
178 CValue* BL_ActionActuator::GetReplica() {
179         BL_ActionActuator* replica = new BL_ActionActuator(*this);//m_float,GetName());
180         replica->ProcessReplica();
181         return replica;
182 }
183
184 bool BL_ActionActuator::Update(double curtime, bool frame)
185 {
186         bool bNegativeEvent = false;
187         bool bPositiveEvent = false;
188         bool bUseContinue = false;
189         KX_GameObject *obj = (KX_GameObject*)GetParent();
190         short playtype = BL_Action::ACT_MODE_PLAY;
191         float start = m_startframe;
192         float end = m_endframe;
193
194         // If we don't have an action, we can't do anything
195         if (!m_action)
196                 return false;
197
198         // Convert our playtype to one that BL_Action likes
199         switch(m_playtype)
200         {
201                 case ACT_ACTION_LOOP_END:
202                 case ACT_ACTION_LOOP_STOP:
203                         playtype = BL_Action::ACT_MODE_LOOP;
204                         break;
205
206                 case ACT_ACTION_PINGPONG:
207                         // We handle ping pong ourselves to increase compabitility
208                         // with files made prior to animation changes from GSoC 2011.
209                         playtype = BL_Action::ACT_MODE_PLAY;
210                 
211                         if (m_flag & ACT_FLAG_REVERSE)
212                         {
213                                 start = m_endframe;
214                                 end = m_startframe;
215                         }
216
217                         break;
218                 case ACT_ACTION_FROM_PROP:
219                         CValue* prop = GetParent()->GetProperty(m_propname);
220
221                         // If we don't have a property, we can't do anything, so just bail
222                         if (!prop) return false;
223
224                         playtype = BL_Action::ACT_MODE_PLAY;
225                         start = end = prop->GetNumber();
226
227                         break;
228         }
229
230         if (m_flag & ACT_FLAG_CONTINUE)
231                 bUseContinue = true;
232         
233         
234         // Handle events
235         if (frame)
236         {
237                 bNegativeEvent = m_negevent;
238                 bPositiveEvent = m_posevent;
239                 RemoveAllEvents();
240         }
241
242         // "Active" actions need to keep updating their current frame
243         if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE))
244                 m_localtime = obj->GetActionFrame(m_layer);
245
246         if (m_flag & ACT_FLAG_ATTEMPT_PLAY)
247                 SetLocalTime(curtime);
248         else
249                 ResetStartTime(curtime);
250
251         // Handle a frame property if it's defined
252         if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0)
253         {
254                 CValue* oldprop = obj->GetProperty(m_framepropname);
255                 CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
256                 if (oldprop)
257                         oldprop->SetValue(newval);
258                 else
259                         obj->SetProperty(m_framepropname, newval);
260
261                 newval->Release();
262         }
263
264         // Handle a finished animation
265         if ((m_flag & ACT_FLAG_PLAY_END) && (m_flag & ACT_FLAG_ACTIVE) && obj->IsActionDone(m_layer))
266         {
267                 m_flag &= ~ACT_FLAG_ACTIVE;
268                 m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;
269
270                 if (m_playtype == ACT_ACTION_PINGPONG)
271                         m_flag ^= ACT_FLAG_REVERSE;
272                 return false;
273         }
274         
275         // If a different action is playing, we've been overruled and are no longer active
276         if (obj->GetCurrentAction(m_layer) != m_action && !obj->IsActionDone(m_layer))
277                 m_flag &= ~ACT_FLAG_ACTIVE;
278
279         if (bPositiveEvent || (m_flag & ACT_FLAG_ATTEMPT_PLAY && !(m_flag & ACT_FLAG_ACTIVE)))
280         {
281                 if (bPositiveEvent && m_playtype == ACT_ACTION_PLAY)
282                 {
283                         if (obj->IsActionDone(m_layer))
284                                 m_localtime = start;
285                         ResetStartTime(curtime);
286                 }
287
288                 if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags))
289                 {
290                         m_flag |= ACT_FLAG_ACTIVE;
291                         if (bUseContinue)
292                                 obj->SetActionFrame(m_layer, m_localtime);
293
294                         if (m_playtype == ACT_ACTION_PLAY || m_playtype == ACT_ACTION_PINGPONG)
295                                 m_flag |= ACT_FLAG_PLAY_END;
296                         else
297                                 m_flag &= ~ACT_FLAG_PLAY_END;
298                 }
299                 m_flag |= ACT_FLAG_ATTEMPT_PLAY;
300         }
301         else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent)
302         {       
303                 m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;
304                 m_localtime = obj->GetActionFrame(m_layer);
305                 bAction *curr_action = obj->GetCurrentAction(m_layer);
306                 if (curr_action && curr_action != m_action)
307                 {
308                         // Someone changed the action on us, so we wont mess with it
309                         // Hopefully there wont be too many problems with two actuators using
310                         // the same action...
311                         m_flag &= ~ACT_FLAG_ACTIVE;
312                         return false;
313                 }
314
315                 switch(m_playtype)
316                 {
317                         case ACT_ACTION_LOOP_STOP:
318                                 obj->StopAction(m_layer); // Stop the action after getting the frame
319
320                                 // We're done
321                                 m_flag &= ~ACT_FLAG_ACTIVE;
322                                 return false;
323                         case ACT_ACTION_LOOP_END:
324                                 // Convert into a play and let it finish
325                                 obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY);
326
327                                 m_flag |= ACT_FLAG_PLAY_END;
328                                 break;
329         
330                         case ACT_ACTION_FLIPPER:
331                                 // Convert into a play action and play back to the beginning
332                                 end = start;
333                                 start = obj->GetActionFrame(m_layer);
334                                 obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, 0, BL_Action::ACT_MODE_PLAY, m_layer_weight, m_ipo_flags);
335
336                                 m_flag |= ACT_FLAG_PLAY_END;
337                                 break;
338                 }
339         }
340
341         return true;
342 }
343
344 #ifdef WITH_PYTHON
345
346 /* ------------------------------------------------------------------------- */
347 /* Python functions                                                          */
348 /* ------------------------------------------------------------------------- */
349
350 PyObject* BL_ActionActuator::PyGetChannel(PyObject* value)
351 {
352         const char *string= _PyUnicode_AsString(value);
353         
354         if (!string) {
355                 PyErr_SetString(PyExc_TypeError, "expected a single string");
356                 return NULL;
357         }
358         
359         bPoseChannel *pchan;
360         
361         if(m_userpose==NULL && m_pose==NULL) {
362                 BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
363                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
364         }
365         
366         // get_pose_channel accounts for NULL pose, run on both incase one exists but
367         // the channel doesnt
368         if(             !(pchan=get_pose_channel(m_userpose, string)) &&
369                         !(pchan=get_pose_channel(m_pose, string))  )
370         {
371                 PyErr_SetString(PyExc_ValueError, "channel doesnt exist");
372                 return NULL;
373         }
374
375         PyObject *ret = PyTuple_New(3);
376         
377         PyObject *list = PyList_New(3); 
378         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->loc[0]));
379         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->loc[1]));
380         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->loc[2]));
381         PyTuple_SET_ITEM(ret, 0, list);
382         
383         list = PyList_New(3);
384         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->size[0]));
385         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->size[1]));
386         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->size[2]));
387         PyTuple_SET_ITEM(ret, 1, list);
388         
389         list = PyList_New(4);
390         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->quat[0]));
391         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->quat[1]));
392         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->quat[2]));
393         PyList_SET_ITEM(list, 3, PyFloat_FromDouble(pchan->quat[3]));
394         PyTuple_SET_ITEM(ret, 2, list);
395
396         return ret;
397 /*
398         return Py_BuildValue("([fff][fff][ffff])",
399                 pchan->loc[0], pchan->loc[1], pchan->loc[2],
400                 pchan->size[0], pchan->size[1], pchan->size[2],
401                 pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] );
402 */
403 }
404
405 /*     setChannel                                                         */
406 KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
407 "setChannel(channel, matrix)\n"
408 "\t - channel   : A string specifying the name of the bone channel.\n"
409 "\t - matrix    : A 4x4 matrix specifying the overriding transformation\n"
410 "\t               as an offset from the bone's rest position.\n")
411 {
412         BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
413         char *string;
414         PyObject *pymat= NULL;
415         PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL;
416         bPoseChannel *pchan;
417         
418         if(PyTuple_Size(args)==2) {
419                 if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix
420                         return NULL;
421         }
422         else if(PyTuple_Size(args)==4) {
423                 if (!PyArg_ParseTuple(args,"sOOO:setChannel", &string, &pyloc, &pysize, &pyquat)) // loc/size/quat
424                         return NULL;
425         }
426         else {
427                 PyErr_SetString(PyExc_ValueError, "Expected a string and a 4x4 matrix (2 args) or a string and loc/size/quat sequences (4 args)");
428                 return NULL;
429         }
430         
431         if(pymat) {
432                 float matrix[4][4];
433                 MT_Matrix4x4 mat;
434                 
435                 if(!PyMatTo(pymat, mat))
436                         return NULL;
437                 
438                 mat.getValue((float*)matrix);
439                 
440                 BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
441                 
442                 if (!m_userpose) {
443                         if(!m_pose)
444                                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
445                         game_copy_pose(&m_userpose, m_pose, 0);
446                 }
447                 // pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there.
448                 pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there.
449                 
450                 if(pchan) {
451                         copy_v3_v3(pchan->loc, matrix[3]);
452                         mat4_to_size(pchan->size, matrix);
453                         mat4_to_quat(pchan->quat, matrix);
454                 }
455         }
456         else {
457                 MT_Vector3 loc;
458                 MT_Vector3 size;
459                 MT_Quaternion quat;
460                 
461                 if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyQuatTo(pyquat, quat))
462                         return NULL;
463                 
464                 // same as above
465                 if (!m_userpose) {
466                         if(!m_pose)
467                                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
468                         game_copy_pose(&m_userpose, m_pose, 0);
469                 }
470                 // pchan= verify_pose_channel(m_userpose, string);
471                 pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there.
472                 
473                 // for some reason loc.setValue(pchan->loc) fails
474                 if(pchan) {
475                         pchan->loc[0]= loc[0]; pchan->loc[1]= loc[1]; pchan->loc[2]= loc[2];
476                         pchan->size[0]= size[0]; pchan->size[1]= size[1]; pchan->size[2]= size[2];
477                         pchan->quat[0]= quat[3]; pchan->quat[1]= quat[0]; pchan->quat[2]= quat[1]; pchan->quat[3]= quat[2]; /* notice xyzw -> wxyz is intentional */
478                 }
479         }
480         
481         if(pchan==NULL) {
482                 PyErr_SetString(PyExc_ValueError, "Channel could not be found, use the 'channelNames' attribute to get a list of valid channels");
483                 return NULL;
484         }
485         
486         Py_RETURN_NONE;
487 }
488
489 /* ------------------------------------------------------------------------- */
490 /* Python Integration Hooks                                                                      */
491 /* ------------------------------------------------------------------------- */
492
493 PyTypeObject BL_ActionActuator::Type = {
494         PyVarObject_HEAD_INIT(NULL, 0)
495         "BL_ActionActuator",
496         sizeof(PyObjectPlus_Proxy),
497         0,
498         py_base_dealloc,
499         0,
500         0,
501         0,
502         0,
503         py_base_repr,
504         0,0,0,0,0,0,0,0,0,
505         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
506         0,0,0,0,0,0,0,
507         Methods,
508         0,
509         0,
510         &SCA_IActuator::Type,
511         0,0,0,0,0,0,
512         py_base_new
513 };
514
515 PyMethodDef BL_ActionActuator::Methods[] = {
516         {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_O},
517         KX_PYMETHODTABLE(BL_ActionActuator, setChannel),
518         {NULL,NULL} //Sentinel
519 };
520
521 PyAttributeDef BL_ActionActuator::Attributes[] = {
522         KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
523         KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
524         KX_PYATTRIBUTE_FLOAT_RW("blendIn", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
525         KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
526         KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names),
527         KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
528         KX_PYATTRIBUTE_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame),
529         KX_PYATTRIBUTE_STRING_RW("propName", 0, 31, false, BL_ActionActuator, m_propname),
530         KX_PYATTRIBUTE_STRING_RW("framePropName", 0, 31, false, BL_ActionActuator, m_framepropname),
531         KX_PYATTRIBUTE_RW_FUNCTION("useContinue", BL_ActionActuator, pyattr_get_use_continue, pyattr_set_use_continue),
532         KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
533         KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ActionActuator,m_playtype,CheckType),
534         { NULL }        //Sentinel
535 };
536
537 PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
538 {
539         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
540         return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
541 }
542
543 int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
544 {
545         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
546         
547         if (!PyUnicode_Check(value))
548         {
549                 PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
550                 return PY_SET_ATTR_FAIL;
551         }
552
553         bAction *action= NULL;
554         STR_String val = _PyUnicode_AsString(value);
555         
556         if (val != "")
557         {
558                 action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
559                 if (!action)
560                 {
561                         PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
562                         return PY_SET_ATTR_FAIL;
563                 }
564         }
565         
566         self->SetAction(action);
567         return PY_SET_ATTR_SUCCESS;
568
569 }
570
571 PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
572 {
573         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
574         PyObject *ret= PyList_New(0);
575         PyObject *item;
576         
577         bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose();
578         
579         if(pose) {
580                 bPoseChannel *pchan;
581                 for(pchan= (bPoseChannel *)pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) {
582                         item= PyUnicode_FromString(pchan->name);
583                         PyList_Append(ret, item);
584                         Py_DECREF(item);
585                 }
586         }
587         
588         return ret;
589 }
590
591 PyObject* BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
592 {
593         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
594         return PyBool_FromLong(self->m_flag & ACT_FLAG_CONTINUE);
595 }
596
597 int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
598 {
599         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
600         
601         if (PyObject_IsTrue(value))
602                 self->m_flag |= ACT_FLAG_CONTINUE;
603         else
604                 self->m_flag &= ~ACT_FLAG_CONTINUE;
605         
606         return PY_SET_ATTR_SUCCESS;
607 }
608
609 PyObject* BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
610 {
611         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
612         return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer));
613 }
614
615 int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
616 {
617         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
618         
619         ((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value));
620         
621         return PY_SET_ATTR_SUCCESS;
622 }
623
624 #endif // WITH_PYTHON