BGE: The Action Actuator now returns correct values to work with the Actuator Sensor.
[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 {
180         BL_ActionActuator* replica = new BL_ActionActuator(*this);//m_float,GetName());
181         replica->ProcessReplica();
182         return replica;
183 }
184
185 bool BL_ActionActuator::Update(double curtime, bool frame)
186 {
187         bool bNegativeEvent = false;
188         bool bPositiveEvent = false;
189         bool bUseContinue = false;
190         KX_GameObject *obj = (KX_GameObject*)GetParent();
191         short playtype = BL_Action::ACT_MODE_PLAY;
192         float start = m_startframe;
193         float end = m_endframe;
194
195         // If we don't have an action, we can't do anything
196         if (!m_action)
197                 return false;
198
199         // Convert our playtype to one that BL_Action likes
200         switch(m_playtype)
201         {
202                 case ACT_ACTION_LOOP_END:
203                 case ACT_ACTION_LOOP_STOP:
204                         playtype = BL_Action::ACT_MODE_LOOP;
205                         break;
206
207                 case ACT_ACTION_PINGPONG:
208                         // We handle ping pong ourselves to increase compabitility
209                         // with files made prior to animation changes from GSoC 2011.
210                         playtype = BL_Action::ACT_MODE_PLAY;
211                 
212                         if (m_flag & ACT_FLAG_REVERSE)
213                         {
214                                 start = m_endframe;
215                                 end = m_startframe;
216                         }
217
218                         break;
219                 case ACT_ACTION_FROM_PROP:
220                         CValue* prop = GetParent()->GetProperty(m_propname);
221
222                         // If we don't have a property, we can't do anything, so just bail
223                         if (!prop) return false;
224
225                         playtype = BL_Action::ACT_MODE_PLAY;
226                         start = end = prop->GetNumber();
227
228                         break;
229         }
230
231         if (m_flag & ACT_FLAG_CONTINUE)
232                 bUseContinue = true;
233         
234         
235         // Handle events
236         if (frame)
237         {
238                 bNegativeEvent = m_negevent;
239                 bPositiveEvent = m_posevent;
240                 RemoveAllEvents();
241         }
242
243         // "Active" actions need to keep updating their current frame
244         if (bUseContinue && (m_flag & ACT_FLAG_ACTIVE))
245                 m_localtime = obj->GetActionFrame(m_layer);
246
247         if (m_flag & ACT_FLAG_ATTEMPT_PLAY)
248                 SetLocalTime(curtime);
249         else
250                 ResetStartTime(curtime);
251
252         // Handle a frame property if it's defined
253         if ((m_flag & ACT_FLAG_ACTIVE) && m_framepropname[0] != 0)
254         {
255                 CValue* oldprop = obj->GetProperty(m_framepropname);
256                 CValue* newval = new CFloatValue(obj->GetActionFrame(m_layer));
257                 if (oldprop)
258                         oldprop->SetValue(newval);
259                 else
260                         obj->SetProperty(m_framepropname, newval);
261
262                 newval->Release();
263         }
264
265         // Handle a finished animation
266         if ((m_flag & ACT_FLAG_PLAY_END) && (m_flag & ACT_FLAG_ACTIVE) && obj->IsActionDone(m_layer))
267         {
268                 m_flag &= ~ACT_FLAG_ACTIVE;
269                 m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;
270
271                 if (m_playtype == ACT_ACTION_PINGPONG)
272                         m_flag ^= ACT_FLAG_REVERSE;
273                 return false;
274         }
275         
276         // If a different action is playing, we've been overruled and are no longer active
277         if (obj->GetCurrentAction(m_layer) != m_action && !obj->IsActionDone(m_layer))
278                 m_flag &= ~ACT_FLAG_ACTIVE;
279
280         if (bPositiveEvent || (m_flag & ACT_FLAG_ATTEMPT_PLAY && !(m_flag & ACT_FLAG_ACTIVE)))
281         {
282                 if (bPositiveEvent && m_playtype == ACT_ACTION_PLAY)
283                 {
284                         if (obj->IsActionDone(m_layer))
285                                 m_localtime = start;
286                         ResetStartTime(curtime);
287                 }
288
289                 if (obj->PlayAction(m_action->id.name+2, start, end, m_layer, m_priority, m_blendin, playtype, m_layer_weight, m_ipo_flags))
290                 {
291                         m_flag |= ACT_FLAG_ACTIVE;
292                         if (bUseContinue)
293                                 obj->SetActionFrame(m_layer, m_localtime);
294
295                         if (m_playtype == ACT_ACTION_PLAY || m_playtype == ACT_ACTION_PINGPONG)
296                                 m_flag |= ACT_FLAG_PLAY_END;
297                         else
298                                 m_flag &= ~ACT_FLAG_PLAY_END;
299                 }
300                 m_flag |= ACT_FLAG_ATTEMPT_PLAY;
301         }
302         else if ((m_flag & ACT_FLAG_ACTIVE) && bNegativeEvent)
303         {       
304                 m_flag &= ~ACT_FLAG_ATTEMPT_PLAY;
305                 m_localtime = obj->GetActionFrame(m_layer);
306                 bAction *curr_action = obj->GetCurrentAction(m_layer);
307                 if (curr_action && curr_action != m_action)
308                 {
309                         // Someone changed the action on us, so we wont mess with it
310                         // Hopefully there wont be too many problems with two actuators using
311                         // the same action...
312                         m_flag &= ~ACT_FLAG_ACTIVE;
313                         return false;
314                 }
315
316                 switch(m_playtype)
317                 {
318                         case ACT_ACTION_LOOP_STOP:
319                                 obj->StopAction(m_layer); // Stop the action after getting the frame
320
321                                 // We're done
322                                 m_flag &= ~ACT_FLAG_ACTIVE;
323                                 return false;
324                         case ACT_ACTION_LOOP_END:
325                                 // Convert into a play and let it finish
326                                 obj->SetPlayMode(m_layer, BL_Action::ACT_MODE_PLAY);
327
328                                 m_flag |= ACT_FLAG_PLAY_END;
329                                 break;
330         
331                         case ACT_ACTION_FLIPPER:
332                                 // Convert into a play action and play back to the beginning
333                                 end = start;
334                                 start = obj->GetActionFrame(m_layer);
335                                 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);
336
337                                 m_flag |= ACT_FLAG_PLAY_END;
338                                 break;
339                 }
340         }
341
342         return m_flag & ACT_FLAG_ATTEMPT_PLAY;
343 }
344
345 #ifdef WITH_PYTHON
346
347 /* ------------------------------------------------------------------------- */
348 /* Python functions                                                          */
349 /* ------------------------------------------------------------------------- */
350
351 PyObject* BL_ActionActuator::PyGetChannel(PyObject* value)
352 {
353         PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.getChannel() no longer works, please use BL_ArmatureObject.channels instead");
354         return NULL;
355 #if 0 // XXX To be removed in a later version (first removed in 2.64)
356         const char *string= _PyUnicode_AsString(value);
357
358         if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
359         {
360                 PyErr_SetString(PyExc_NotImplementedError, "actuator.getChannel(): Only armatures support channels");
361                 return NULL;
362         }
363         
364         if (!string) {
365                 PyErr_SetString(PyExc_TypeError, "expected a single string");
366                 return NULL;
367         }
368         
369         bPoseChannel *pchan;
370         
371         if (m_userpose==NULL && m_pose==NULL) {
372                 BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
373                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
374         }
375         
376         // BKE_pose_channel_find_name accounts for NULL pose, run on both in case one exists but
377         // the channel doesnt
378         if (            !(pchan=BKE_pose_channel_find_name(m_userpose, string)) &&
379                         !(pchan=BKE_pose_channel_find_name(m_pose, string))  )
380         {
381                 PyErr_SetString(PyExc_ValueError, "channel doesnt exist");
382                 return NULL;
383         }
384
385         PyObject *ret = PyTuple_New(3);
386         
387         PyObject *list = PyList_New(3); 
388         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->loc[0]));
389         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->loc[1]));
390         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->loc[2]));
391         PyTuple_SET_ITEM(ret, 0, list);
392         
393         list = PyList_New(3);
394         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->size[0]));
395         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->size[1]));
396         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->size[2]));
397         PyTuple_SET_ITEM(ret, 1, list);
398         
399         list = PyList_New(4);
400         PyList_SET_ITEM(list, 0, PyFloat_FromDouble(pchan->quat[0]));
401         PyList_SET_ITEM(list, 1, PyFloat_FromDouble(pchan->quat[1]));
402         PyList_SET_ITEM(list, 2, PyFloat_FromDouble(pchan->quat[2]));
403         PyList_SET_ITEM(list, 3, PyFloat_FromDouble(pchan->quat[3]));
404         PyTuple_SET_ITEM(ret, 2, list);
405
406         return ret;
407 #if 0
408         return Py_BuildValue("([fff][fff][ffff])",
409                 pchan->loc[0], pchan->loc[1], pchan->loc[2],
410                 pchan->size[0], pchan->size[1], pchan->size[2],
411                 pchan->quat[0], pchan->quat[1], pchan->quat[2], pchan->quat[3] );
412 #endif
413 #endif
414 }
415
416 /*     setChannel                                                         */
417 KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel,
418 "setChannel(channel, matrix)\n"
419 "\t - channel   : A string specifying the name of the bone channel.\n"
420 "\t - matrix    : A 4x4 matrix specifying the overriding transformation\n"
421 "\t               as an offset from the bone's rest position.\n")
422 {
423         PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.setChannel() no longer works, please use BL_ArmatureObject.channels instead");
424         return NULL;
425
426 #if 0 // XXX To be removed in a later version (first removed in 2.64)
427         BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
428         char *string;
429         PyObject *pymat= NULL;
430         PyObject *pyloc= NULL, *pysize= NULL, *pyquat= NULL;
431         bPoseChannel *pchan;
432
433         if (GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
434         {
435                 PyErr_SetString(PyExc_NotImplementedError, "actuator.setChannel(): Only armatures support channels");
436                 return NULL;
437         }
438         
439         if (PyTuple_Size(args)==2) {
440                 if (!PyArg_ParseTuple(args,"sO:setChannel", &string, &pymat)) // matrix
441                         return NULL;
442         }
443         else if (PyTuple_Size(args)==4) {
444                 if (!PyArg_ParseTuple(args,"sOOO:setChannel", &string, &pyloc, &pysize, &pyquat)) // loc/size/quat
445                         return NULL;
446         }
447         else {
448                 PyErr_SetString(PyExc_ValueError, "Expected a string and a 4x4 matrix (2 args) or a string and loc/size/quat sequences (4 args)");
449                 return NULL;
450         }
451         
452         if (pymat) {
453                 float matrix[4][4];
454                 MT_Matrix4x4 mat;
455                 
456                 if (!PyMatTo(pymat, mat))
457                         return NULL;
458                 
459                 mat.getValue((float*)matrix);
460                 
461                 BL_ArmatureObject *obj = (BL_ArmatureObject*)GetParent();
462                 
463                 if (!m_userpose) {
464                         if (!m_pose)
465                                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
466                         game_copy_pose(&m_userpose, m_pose, 0);
467                 }
468                 // pchan= BKE_pose_channel_verify(m_userpose, string); // adds the channel if its not there.
469                 pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
470                 
471                 if (pchan) {
472                         copy_v3_v3(pchan->loc, matrix[3]);
473                         mat4_to_size(pchan->size, matrix);
474                         mat4_to_quat(pchan->quat, matrix);
475                 }
476         }
477         else {
478                 MT_Vector3 loc;
479                 MT_Vector3 size;
480                 MT_Quaternion quat;
481                 
482                 if (!PyVecTo(pyloc, loc) || !PyVecTo(pysize, size) || !PyQuatTo(pyquat, quat))
483                         return NULL;
484                 
485                 // same as above
486                 if (!m_userpose) {
487                         if (!m_pose)
488                                 obj->GetPose(&m_pose); /* Get the underlying pose from the armature */
489                         game_copy_pose(&m_userpose, m_pose, 0);
490                 }
491                 // pchan= BKE_pose_channel_verify(m_userpose, string);
492                 pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there.
493                 
494                 // for some reason loc.setValue(pchan->loc) fails
495                 if (pchan) {
496                         pchan->loc[0]= loc[0]; pchan->loc[1]= loc[1]; pchan->loc[2]= loc[2];
497                         pchan->size[0]= size[0]; pchan->size[1]= size[1]; pchan->size[2]= size[2];
498                         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 */
499                 }
500         }
501         
502         if (pchan==NULL) {
503                 PyErr_SetString(PyExc_ValueError, "Channel could not be found, use the 'channelNames' attribute to get a list of valid channels");
504                 return NULL;
505         }
506         
507         Py_RETURN_NONE;
508 #endif
509 }
510
511 /* ------------------------------------------------------------------------- */
512 /* Python Integration Hooks                                                                      */
513 /* ------------------------------------------------------------------------- */
514
515 PyTypeObject BL_ActionActuator::Type = {
516         PyVarObject_HEAD_INIT(NULL, 0)
517         "BL_ActionActuator",
518         sizeof(PyObjectPlus_Proxy),
519         0,
520         py_base_dealloc,
521         0,
522         0,
523         0,
524         0,
525         py_base_repr,
526         0,0,0,0,0,0,0,0,0,
527         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
528         0,0,0,0,0,0,0,
529         Methods,
530         0,
531         0,
532         &SCA_IActuator::Type,
533         0,0,0,0,0,0,
534         py_base_new
535 };
536
537 PyMethodDef BL_ActionActuator::Methods[] = {
538         {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_O},
539         KX_PYMETHODTABLE(BL_ActionActuator, setChannel),
540         {NULL,NULL} //Sentinel
541 };
542
543 PyAttributeDef BL_ActionActuator::Attributes[] = {
544         KX_PYATTRIBUTE_FLOAT_RW("frameStart", 0, MAXFRAMEF, BL_ActionActuator, m_startframe),
545         KX_PYATTRIBUTE_FLOAT_RW("frameEnd", 0, MAXFRAMEF, BL_ActionActuator, m_endframe),
546         KX_PYATTRIBUTE_FLOAT_RW("blendIn", 0, MAXFRAMEF, BL_ActionActuator, m_blendin),
547         KX_PYATTRIBUTE_RW_FUNCTION("action", BL_ActionActuator, pyattr_get_action, pyattr_set_action),
548         KX_PYATTRIBUTE_RO_FUNCTION("channelNames", BL_ActionActuator, pyattr_get_channel_names),
549         KX_PYATTRIBUTE_SHORT_RW("priority", 0, 100, false, BL_ActionActuator, m_priority),
550         KX_PYATTRIBUTE_RW_FUNCTION("frame", BL_ActionActuator, pyattr_get_frame, pyattr_set_frame),
551         KX_PYATTRIBUTE_STRING_RW("propName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_propname),
552         KX_PYATTRIBUTE_STRING_RW("framePropName", 0, MAX_PROP_NAME, false, BL_ActionActuator, m_framepropname),
553         KX_PYATTRIBUTE_RW_FUNCTION("useContinue", BL_ActionActuator, pyattr_get_use_continue, pyattr_set_use_continue),
554         KX_PYATTRIBUTE_FLOAT_RW_CHECK("blendTime", 0, MAXFRAMEF, BL_ActionActuator, m_blendframe, CheckBlendTime),
555         KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",0,100,false,BL_ActionActuator,m_playtype,CheckType),
556         { NULL }        //Sentinel
557 };
558
559 PyObject* BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
560 {
561         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
562         return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : "");
563 }
564
565 int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
566 {
567         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
568         
569         if (!PyUnicode_Check(value))
570         {
571                 PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
572                 return PY_SET_ATTR_FAIL;
573         }
574
575         bAction *action= NULL;
576         STR_String val = _PyUnicode_AsString(value);
577         
578         if (val != "")
579         {
580                 action= (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(val);
581                 if (!action)
582                 {
583                         PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
584                         return PY_SET_ATTR_FAIL;
585                 }
586         }
587         
588         self->SetAction(action);
589         return PY_SET_ATTR_SUCCESS;
590
591 }
592
593 PyObject* BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
594 {
595         PyErr_SetString(PyExc_NotImplementedError, "BL_ActionActuator.channelNames no longer works, please use BL_ArmatureObject.channels instead");
596         return NULL;
597
598 #if 0 // XXX To be removed in a later version (first removed in 2.64)
599         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
600         PyObject *ret= PyList_New(0);
601         PyObject *item;
602         
603         if (self->GetParent()->GetGameObjectType() != SCA_IObject::OBJ_ARMATURE)
604         {
605                 PyErr_SetString(PyExc_NotImplementedError, "actuator.channelNames: Only armatures support channels");
606                 return NULL;
607         }
608
609         bPose *pose= ((BL_ArmatureObject*)self->GetParent())->GetOrigPose();
610         
611         if (pose) {
612                 bPoseChannel *pchan;
613                 for (pchan= (bPoseChannel *)pose->chanbase.first; pchan; pchan= (bPoseChannel *)pchan->next) {
614                         item= PyUnicode_FromString(pchan->name);
615                         PyList_Append(ret, item);
616                         Py_DECREF(item);
617                 }
618         }
619         
620         return ret;
621 #endif
622 }
623
624 PyObject* BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
625 {
626         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
627         return PyBool_FromLong(self->m_flag & ACT_FLAG_CONTINUE);
628 }
629
630 int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
631 {
632         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
633         
634         if (PyObject_IsTrue(value))
635                 self->m_flag |= ACT_FLAG_CONTINUE;
636         else
637                 self->m_flag &= ~ACT_FLAG_CONTINUE;
638         
639         return PY_SET_ATTR_SUCCESS;
640 }
641
642 PyObject* BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
643 {
644         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
645         return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer));
646 }
647
648 int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
649 {
650         BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v);
651         
652         ((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value));
653         
654         return PY_SET_ATTR_SUCCESS;
655 }
656
657 #endif // WITH_PYTHON