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