Fix for [#32213] "Action actuator doesn't finish playing if frame rate drops" reporte...
[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                         break;
149                 case ACT_ACTION_LOOP_END:
150                         // Put the time back to the beginning
151                         m_localtime = m_startframe;
152                         m_starttime = curtime;
153                         break;
154                 case ACT_ACTION_PINGPONG:
155                         // Swap the start and end frames
156                         float temp = m_startframe;
157                         m_startframe = m_endframe;
158                         m_endframe = temp;
159
160                         m_starttime = curtime;
161
162                         m_flag ^= ACT_FLAG_REVERSE;
163
164                         break;
165                 }
166         }
167 }
168
169 void BL_ActionActuator::ResetStartTime(float curtime)
170 {
171         float dt = m_localtime - m_startframe;
172
173         m_starttime = curtime - dt / (KX_KetsjiEngine::GetAnimFrameRate());
174         //SetLocalTime(curtime);
175 }
176
177 CValue* BL_ActionActuator::GetReplica()
178 {
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 m_flag & ACT_FLAG_ACTIVE;
342 }
343
344 #ifdef WITH_PYTHON
345
346 /* ------------------------------------------------------------------------- */
347 /* Python functions                                                          */
348 /* ------------------------------------------------------------------------- */
349
350 PyObject* BL_ActionActuator::PyGetChannel(PyObject* value)
351 {
352         PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead");
353         return NULL;
354 #if 0 // XXX To be removed in a later version (first removed in 2.64)
355         const char *string= _PyUnicode_AsString(value);
356
357         if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
358         {
359                 PyErr_SetString(PyExc_NotImplementedError, "actuator.getChannel(): Only armatures support channels");
360                 return NULL;
361         }
362         
363         if (!string) {
364                 PyErr_SetString(PyExc_TypeError, "expected a single string");
365                 return NULL;
366         }
367         
368         bPoseChannel *pchan;
369         
370         if (m_userpose==NULL && m_pose==NULL) {
371                 BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
372                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
373         }
374         
375         // BKE_pose_channel_find_name accounts for NULL pose, run on both in case one exists but
376         // the channel doesnt
377         if (            !(pchan=BKE_pose_channel_find_name(m_userpose, string)) &&
378                         !(pchan=BKE_pose_channel_find_name(m_pose, string))  )
379         {
380                 PyErr_SetString(PyExc_ValueError, "channel doesnt exist");
381                 return NULL;
382         }
383
384         PyObject *ret = PyTuple_New(3);
385         
386         PyObject *list = PyList_New(3); 
387         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->loc[0]));
388         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->loc[1]));
389         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->loc[2]));
390         PyTuple_SET_ITEM(ret, 0, list);
391         
392         list = PyList_New(3);
393         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->size[0]));
394         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->size[1]));
395         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->size[2]));
396         PyTuple_SET_ITEM(ret, 1, list);
397         
398         list = PyList_New(4);
399         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->quat[0]));
400         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->quat[1]));
401         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->quat[2]));
402         PyList_SET_ITEM(list, 3, PyFloat_FromDouble(pchan->quat[3]));
403         PyTuple_SET_ITEM(ret, 2, list);
404
405         return ret;
406 #if 0
407         return Py_BuildValue("([fff][fff][ffff])",
408                 pchan->loc[0], pchan->loc[1], pchan->loc[2],
409                 pchan->size[0], pchan->size[1], pchan->size[2],
410                 pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] );
411 #endif
412 #endif
413 }
414
415 /*     setChannel                                                         */
416 KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
417 "setChannel(channel, matrix)\n"
418 "\t - channel   : A string specifying the name of the bone channel.\n"
419 "\t - matrix    : A 4x4 matrix specifying the overriding transformation\n"
420 "\t               as an offset from the bone's rest position.\n")
421 {
422         PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.setChannel() no longer works, please use BL_ArmatureObject.channels instead");
423         return NULL;
424
425 #if 0 // XXX To be removed in a later version (first removed in 2.64)
426         BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
427         char *string;
428         PyObject *pymat= NULL;
429         PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL;
430         bPoseChannel *pchan;
431
432         if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
433         {
434                 PyErr_SetString(PyExc_NotImplementedError, "actuator.setChannel(): Only armatures support channels");
435                 return NULL;
436         }
437         
438         if (PyTuple_Size(args)==2) {
439                 if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix
440                         return NULL;
441         }
442         else if (PyTuple_Size(args)==4) {
443                 if (!PyArg_ParseTuple(args,"sOOO:setChannel", &string, &pyloc, &pysize, &pyquat)) // loc/size/quat
444                         return NULL;
445         }
446         else {
447                 PyErr_SetString(PyExc_ValueError, "Expected a string and a 4x4 matrix (2 args) or a string and loc/size/quat sequences (4 args)");
448                 return NULL;
449         }
450         
451         if (pymat) {
452                 float matrix[4][4];
453                 MT_Matrix4x4 mat;
454                 
455                 if (!PyMatTo(pymat, mat))
456                         return NULL;
457                 
458                 mat.getValue((float*)matrix);
459                 
460                 BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
461                 
462                 if (!m_userpose) {
463                         if (!m_pose)
464                                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
465                         game_copy_pose(&m_userpose, m_pose, 0);
466                 }
467                 // pchan= BKE_pose_channel_verify(m_userpose, string); // adds the channel if its not there.
468                 pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
469                 
470                 if (pchan) {
471                         copy_v3_v3(pchan->loc, matrix[3]);
472                         mat4_to_size(pchan->size, matrix);
473                         mat4_to_quat(pchan->quat, matrix);
474                 }
475         }
476         else {
477                 MT_Vector3 loc;
478                 MT_Vector3 size;
479                 MT_Quaternion quat;
480                 
481                 if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyQuatTo(pyquat, quat))
482                         return NULL;
483                 
484                 // same as above
485                 if (!m_userpose) {
486                         if (!m_pose)
487                                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
488                         game_copy_pose(&m_userpose, m_pose, 0);
489                 }
490                 // pchan= BKE_pose_channel_verify(m_userpose, string);
491                 pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
492                 
493                 // for some reason loc.setValue(pchan->loc) fails
494                 if (pchan) {
495                         pchan->loc[0]= loc[0]; pchan->loc[1]= loc[1]; pchan->loc[2]= loc[2];
496                         pchan->size[0]= size[0]; pchan->size[1]= size[1]; pchan->size[2]= size[2];
497                         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 */
498                 }
499         }
500         
501         if (pchan==NULL) {
502                 PyErr_SetString(PyExc_ValueError, "Channel could not be found, use the 'channelNames' attribute to get a list of valid channels");
503                 return NULL;
504         }
505         
506         Py_RETURN_NONE;
507 #endif
508 }
509
510 /* ------------------------------------------------------------------------- */
511 /* Python Integration Hooks                                                                      */
512 /* ------------------------------------------------------------------------- */
513
514 PyTypeObject BL_ActionActuator::Type = {
515         PyVarObject_HEAD_INIT(NULL, 0)
516         "BL_ActionActuator",
517         sizeof(PyObjectPlus_Proxy),
518         0,
519         py_base_dealloc,
520         0,
521         0,
522         0,
523         0,
524         py_base_repr,
525         0,0,0,0,0,0,0,0,0,
526         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
527         0,0,0,0,0,0,0,
528         Methods,
529         0,
530         0,
531         &SCA_IActuator::Type,
532         0,0,0,0,0,0,
533         py_base_new
534 };
535
536 PyMethodDef BL_ActionActuator::Methods[] = {
537         {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_O},
538         KX_PYMETHODTABLE(BL_ActionActuator, setChannel),
539         {NULL,NULL} //Sentinel
540 };
541
542 PyAttributeDef BL_ActionActuator::Attributes[] = {
543         KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
544         KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
545         KX_PYATTRIBUTE_FLOAT_RW("blendIn", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
546         KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
547         KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names),
548         KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
549         KX_PYATTRIBUTE_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame),
550         KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_propname),
551         KX_PYATTRIBUTE_STRING_RW("framePropName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_framepropname),
552         KX_PYATTRIBUTE_RW_FUNCTION("useContinue", BL_ActionActuator, pyattr_get_use_continue, pyattr_set_use_continue),
553         KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
554         KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ActionActuator,m_playtype,CheckType),
555         { NULL }        //Sentinel
556 };
557
558 PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
559 {
560         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
561         return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
562 }
563
564 int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
565 {
566         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
567         
568         if (!PyUnicode_Check(value))
569         {
570                 PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
571                 return PY_SET_ATTR_FAIL;
572         }
573
574         bAction *action= NULL;
575         STR_String val = _PyUnicode_AsString(value);
576         
577         if (val != "")
578         {
579                 action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
580                 if (!action)
581                 {
582                         PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
583                         return PY_SET_ATTR_FAIL;
584                 }
585         }
586         
587         self->SetAction(action);
588         return PY_SET_ATTR_SUCCESS;
589
590 }
591
592 PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
593 {
594         PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.channelNames no longer works, please use BL_ArmatureObject.channels instead");
595         return NULL;
596
597 #if 0 // XXX To be removed in a later version (first removed in 2.64)
598         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
599         PyObject *ret= PyList_New(0);
600         PyObject *item;
601         
602         if (self->GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
603         {
604                 PyErr_SetString(PyExc_NotImplementedError, "actuator.channelNames: Only armatures support channels");
605                 return NULL;
606         }
607
608         bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose();
609         
610         if (pose) {
611                 bPoseChannel *pchan;
612                 for (pchan= (bPoseChannel *)pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) {
613                         item= PyUnicode_FromString(pchan->name);
614                         PyList_Append(ret, item);
615                         Py_DECREF(item);
616                 }
617         }
618         
619         return ret;
620 #endif
621 }
622
623 PyObject* BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
624 {
625         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
626         return PyBool_FromLong(self->m_flag & ACT_FLAG_CONTINUE);
627 }
628
629 int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
630 {
631         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
632         
633         if (PyObject_IsTrue(value))
634                 self->m_flag |= ACT_FLAG_CONTINUE;
635         else
636                 self->m_flag &= ~ACT_FLAG_CONTINUE;
637         
638         return PY_SET_ATTR_SUCCESS;
639 }
640
641 PyObject* BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
642 {
643         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
644         return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer));
645 }
646
647 int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
648 {
649         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
650         
651         ((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value));
652         
653         return PY_SET_ATTR_SUCCESS;
654 }
655
656 #endif // WITH_PYTHON