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