rename and negate DISABLE_PYTHON --> WITH_PYTHON
[blender.git] / source / gameengine / Converter / BL_ArmatureObject.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 #include "BL_ArmatureObject.h"
31 #include "BL_ActionActuator.h"
32 #include "KX_BlenderSceneConverter.h"
33 #include "MEM_guardedalloc.h"
34 #include "BLI_blenlib.h"
35 #include "BLI_ghash.h"
36 #include "BLI_math.h"
37 #include "BIK_api.h"
38 #include "BKE_action.h"
39 #include "BKE_armature.h"
40 #include "BKE_utildefines.h"
41 #include "BKE_constraint.h"
42 #include "GEN_Map.h"
43 #include "GEN_HashedPtr.h"
44 #include "MEM_guardedalloc.h"
45 #include "DNA_action_types.h"
46 #include "DNA_armature_types.h"
47 #include "DNA_object_types.h"
48 #include "DNA_scene_types.h"
49 #include "DNA_nla_types.h"
50 #include "DNA_constraint_types.h"
51 #include "KX_PythonSeq.h"
52 #include "KX_PythonInit.h"
53 #include "KX_KetsjiEngine.h"
54
55 #include "MT_Matrix4x4.h"
56
57 /** 
58  * Move here pose function for game engine so that we can mix with GE objects
59  * Principle is as follow:
60  * Use Blender structures so that where_is_pose can be used unchanged
61  * Copy the constraint so that they can be enabled/disabled/added/removed at runtime
62  * Don't copy the constraints for the pose used by the Action actuator, it does not need them.
63  * Scan the constraint structures so that the KX equivalent of target objects are identified and 
64  * stored in separate list.
65  * When it is about to evaluate the pose, set the KX object position in the obmat of the corresponding
66  * Blender objects and restore after the evaluation.
67  */
68 void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
69 {
70         bPose *out;
71         bPoseChannel *pchan, *outpchan;
72         GHash *ghash;
73         
74         /* the game engine copies the current armature pose and then swaps
75          * the object pose pointer. this makes it possible to change poses
76          * without affecting the original blender data. */
77
78         if (!src) {
79                 *dst=NULL;
80                 return;
81         }
82         else if (*dst==src) {
83                 printf("copy_pose source and target are the same\n");
84                 *dst=NULL;
85                 return;
86         }
87         
88         out= (bPose*)MEM_dupallocN(src);
89         out->chanhash = NULL;
90         out->agroups.first= out->agroups.last= NULL;
91         out->ikdata = NULL;
92         out->ikparam = MEM_dupallocN(out->ikparam);
93         out->flag |= POSE_GAME_ENGINE;
94         BLI_duplicatelist(&out->chanbase, &src->chanbase);
95
96         /* remap pointers */
97         ghash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "game_copy_pose gh");
98
99         pchan= (bPoseChannel*)src->chanbase.first;
100         outpchan= (bPoseChannel*)out->chanbase.first;
101         for (; pchan; pchan=pchan->next, outpchan=outpchan->next)
102                 BLI_ghash_insert(ghash, pchan, outpchan);
103
104         for (pchan=(bPoseChannel*)out->chanbase.first; pchan; pchan=(bPoseChannel*)pchan->next) {
105                 pchan->parent= (bPoseChannel*)BLI_ghash_lookup(ghash, pchan->parent);
106                 pchan->child= (bPoseChannel*)BLI_ghash_lookup(ghash, pchan->child);
107                 pchan->path= NULL;
108
109                 if (copy_constraint) {
110                         ListBase listb;
111                         // copy all constraint for backward compatibility
112                         copy_constraints(&listb, &pchan->constraints, FALSE);  // copy_constraints NULLs listb, no need to make extern for this operation.
113                         pchan->constraints= listb;
114                 } else {
115                         pchan->constraints.first = NULL;
116                         pchan->constraints.last = NULL;
117                 }
118
119                 // fails to link, props are not used in the BGE yet.
120                 /* if(pchan->prop)
121                         pchan->prop= IDP_CopyProperty(pchan->prop); */
122                 pchan->prop= NULL;
123         }
124
125         BLI_ghash_free(ghash, NULL, NULL);
126         // set acceleration structure for channel lookup
127         make_pose_channels_hash(out);
128         *dst=out;
129 }
130
131
132
133 /* Only allowed for Poses with identical channels */
134 void game_blend_poses(bPose *dst, bPose *src, float srcweight/*, short mode*/)
135 {
136         short mode= ACTSTRIPMODE_BLEND;
137         
138         bPoseChannel *dchan;
139         const bPoseChannel *schan;
140         bConstraint *dcon, *scon;
141         float dstweight;
142         int i;
143
144         switch (mode){
145         case ACTSTRIPMODE_BLEND:
146                 dstweight = 1.0F - srcweight;
147                 break;
148         case ACTSTRIPMODE_ADD:
149                 dstweight = 1.0F;
150                 break;
151         default :
152                 dstweight = 1.0F;
153         }
154         
155         schan= (bPoseChannel*)src->chanbase.first;
156         for (dchan = (bPoseChannel*)dst->chanbase.first; dchan; dchan=(bPoseChannel*)dchan->next, schan= (bPoseChannel*)schan->next){
157                 // always blend on all channels since we don't know which one has been set
158                 /* quat interpolation done separate */
159                 if (schan->rotmode == ROT_MODE_QUAT) {
160                         float dquat[4], squat[4];
161                         
162                         QUATCOPY(dquat, dchan->quat);
163                         QUATCOPY(squat, schan->quat);
164                         if (mode==ACTSTRIPMODE_BLEND)
165                                 interp_qt_qtqt(dchan->quat, dquat, squat, srcweight);
166                         else {
167                                 mul_fac_qt_fl(squat, srcweight);
168                                 mul_qt_qtqt(dchan->quat, dquat, squat);
169                         }
170                         
171                         normalize_qt(dchan->quat);
172                 }
173
174                 for (i=0; i<3; i++) {
175                         /* blending for loc and scale are pretty self-explanatory... */
176                         dchan->loc[i] = (dchan->loc[i]*dstweight) + (schan->loc[i]*srcweight);
177                         dchan->size[i] = 1.0f + ((dchan->size[i]-1.0f)*dstweight) + ((schan->size[i]-1.0f)*srcweight);
178                         
179                         /* euler-rotation interpolation done here instead... */
180                         // FIXME: are these results decent?
181                         if (schan->rotmode)
182                                 dchan->eul[i] = (dchan->eul[i]*dstweight) + (schan->eul[i]*srcweight);
183                 }
184                 for(dcon= (bConstraint*)dchan->constraints.first, scon= (bConstraint*)schan->constraints.first; dcon && scon; dcon= (bConstraint*)dcon->next, scon= (bConstraint*)scon->next) {
185                         /* no 'add' option for constraint blending */
186                         dcon->enforce= dcon->enforce*(1.0f-srcweight) + scon->enforce*srcweight;
187                 }
188         }
189         
190         /* this pose is now in src time */
191         dst->ctime= src->ctime;
192 }
193
194 void game_free_pose(bPose *pose)
195 {
196         if (pose) {
197                 /* free pose-channels and constraints */
198                 free_pose_channels(pose);
199                 
200                 /* free IK solver state */
201                 BIK_clear_data(pose);
202
203                 /* free IK solver param */
204                 if (pose->ikparam)
205                         MEM_freeN(pose->ikparam);
206
207                 MEM_freeN(pose);
208         }
209 }
210
211 BL_ArmatureObject::BL_ArmatureObject(
212                                 void* sgReplicationInfo, 
213                                 SG_Callbacks callbacks, 
214                                 Object *armature,
215                                 Scene *scene)
216
217 :       KX_GameObject(sgReplicationInfo,callbacks),
218         m_controlledConstraints(),
219         m_poseChannels(),
220         m_objArma(armature),
221         m_framePose(NULL),
222         m_scene(scene), // maybe remove later. needed for where_is_pose
223         m_lastframe(0.0),
224         m_timestep(0.040),
225         m_activeAct(NULL),
226         m_activePriority(999),
227         m_constraintNumber(0),
228         m_channelNumber(0),
229         m_lastapplyframe(0.0)
230 {
231         m_armature = (bArmature *)armature->data;
232
233         /* we make a copy of blender object's pose, and then always swap it with
234          * the original pose before calling into blender functions, to deal with
235          * replica's or other objects using the same blender object */
236         m_pose = NULL;
237         game_copy_pose(&m_pose, m_objArma->pose, 1);
238         // store the original armature object matrix
239         memcpy(m_obmat, m_objArma->obmat, sizeof(m_obmat));
240 }
241
242 BL_ArmatureObject::~BL_ArmatureObject()
243 {
244         BL_ArmatureConstraint* constraint;
245         while ((constraint = m_controlledConstraints.Remove()) != NULL) {
246                 delete constraint;
247         }
248         BL_ArmatureChannel* channel;
249         while ((channel = static_cast<BL_ArmatureChannel*>(m_poseChannels.Remove())) != NULL) {
250                 delete channel;
251         }
252         if (m_pose)
253                 game_free_pose(m_pose);
254         if (m_framePose)
255                 game_free_pose(m_framePose);
256 }
257
258
259 void BL_ArmatureObject::LoadConstraints(KX_BlenderSceneConverter* converter)
260 {
261         // first delete any existing constraint (should not have any)
262         while (!m_controlledConstraints.Empty()) {
263                 BL_ArmatureConstraint* constraint = m_controlledConstraints.Remove();
264                 delete constraint;
265         }
266         m_constraintNumber = 0;
267
268         // list all the constraint and convert them to BL_ArmatureConstraint
269         // get the persistent pose structure
270         bPoseChannel* pchan;
271         bConstraint* pcon;
272         bConstraintTypeInfo* cti;
273         Object* blendtarget;
274         KX_GameObject* gametarget;
275         KX_GameObject* gamesubtarget;
276
277         // and locate the constraint
278         for (pchan = (bPoseChannel*)m_pose->chanbase.first; pchan; pchan=(bPoseChannel*)pchan->next) {
279                 for (pcon = (bConstraint*)pchan->constraints.first; pcon; pcon=(bConstraint*)pcon->next) {
280                         if (pcon->flag & CONSTRAINT_DISABLE)
281                                 continue;
282                         // which constraint should we support?
283                         switch (pcon->type) {
284                         case CONSTRAINT_TYPE_TRACKTO:
285                         case CONSTRAINT_TYPE_KINEMATIC:
286                         case CONSTRAINT_TYPE_ROTLIKE:
287                         case CONSTRAINT_TYPE_LOCLIKE:
288                         case CONSTRAINT_TYPE_MINMAX:
289                         case CONSTRAINT_TYPE_SIZELIKE:
290                         case CONSTRAINT_TYPE_LOCKTRACK:
291                         case CONSTRAINT_TYPE_STRETCHTO:
292                         case CONSTRAINT_TYPE_CLAMPTO:
293                         case CONSTRAINT_TYPE_TRANSFORM:
294                         case CONSTRAINT_TYPE_DISTLIMIT:
295                                 cti = constraint_get_typeinfo(pcon);
296                                 gametarget = gamesubtarget = NULL;
297                                 if (cti && cti->get_constraint_targets) {
298                                         ListBase listb = { NULL, NULL };
299                                         cti->get_constraint_targets(pcon, &listb);
300                                         if (listb.first) {
301                                                 bConstraintTarget* target = (bConstraintTarget*)listb.first;
302                                                 if (target->tar && target->tar != m_objArma) {
303                                                         // only remember external objects, self target is handled automatically
304                                                         blendtarget = target->tar;
305                                                         gametarget = converter->FindGameObject(blendtarget);
306                                                 }
307                                                 if (target->next != NULL) {
308                                                         // secondary target
309                                                         target = (bConstraintTarget*)target->next;
310                                                         if (target->tar && target->tar != m_objArma) {
311                                                                 // only track external object
312                                                                 blendtarget = target->tar;
313                                                                 gamesubtarget = converter->FindGameObject(blendtarget);
314                                                         }
315                                                 }
316                                         }
317                                         if (cti->flush_constraint_targets)
318                                                 cti->flush_constraint_targets(pcon, &listb, 1);
319                                 }
320                                 BL_ArmatureConstraint* constraint = new BL_ArmatureConstraint(this, pchan, pcon, gametarget, gamesubtarget);
321                                 m_controlledConstraints.AddBack(constraint);
322                                 m_constraintNumber++;
323                         }
324                 }
325         }
326 }
327
328 BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannel, const char* constraintname)
329 {
330         SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
331         for (cit.begin(); !cit.end(); ++cit) {
332                 BL_ArmatureConstraint* constraint = *cit;
333                 if (constraint->Match(posechannel, constraintname))
334                         return constraint;
335         }
336         return NULL;
337 }
338
339 BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(const char* posechannelconstraint)
340 {
341         // performance: use hash string instead of plain string compare
342         SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
343         for (cit.begin(); !cit.end(); ++cit) {
344                 BL_ArmatureConstraint* constraint = *cit;
345                 if (!strcmp(constraint->GetName(), posechannelconstraint))
346                         return constraint;
347         }
348         return NULL;
349 }
350
351 BL_ArmatureConstraint* BL_ArmatureObject::GetConstraint(int index)
352 {
353         SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
354         for (cit.begin(); !cit.end() && index; ++cit, --index);
355         return (cit.end()) ? NULL : *cit;
356 }
357
358 /* this function is called to populate the m_poseChannels list */
359 void BL_ArmatureObject::LoadChannels()
360 {
361         if (m_poseChannels.Empty()) {
362                 bPoseChannel* pchan;
363                 BL_ArmatureChannel* proxy;
364         
365                 m_channelNumber = 0;
366                 for (pchan = (bPoseChannel*)m_pose->chanbase.first; pchan; pchan=(bPoseChannel*)pchan->next) {
367                         proxy = new BL_ArmatureChannel(this, pchan);
368                         m_poseChannels.AddBack(proxy);
369                         m_channelNumber++;
370                 }
371         }
372 }
373
374 BL_ArmatureChannel* BL_ArmatureObject::GetChannel(bPoseChannel* pchan)
375 {
376         LoadChannels();
377         SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
378         for (cit.begin(); !cit.end(); ++cit) 
379         {
380                 BL_ArmatureChannel* channel = *cit;
381                 if (channel->m_posechannel == pchan)
382                         return channel;
383         }
384         return NULL;
385 }
386
387 BL_ArmatureChannel* BL_ArmatureObject::GetChannel(const char* str)
388 {
389         LoadChannels();
390         SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
391         for (cit.begin(); !cit.end(); ++cit) 
392         {
393                 BL_ArmatureChannel* channel = *cit;
394                 if (!strcmp(channel->m_posechannel->name, str))
395                         return channel;
396         }
397         return NULL;
398 }
399
400 BL_ArmatureChannel* BL_ArmatureObject::GetChannel(int index)
401 {
402         LoadChannels();
403         if (index < 0 || index >= m_channelNumber)
404                 return NULL;
405         SG_DList::iterator<BL_ArmatureChannel> cit(m_poseChannels);
406         for (cit.begin(); !cit.end() && index; ++cit, --index);
407         return (cit.end()) ? NULL : *cit;
408 }
409
410 CValue* BL_ArmatureObject::GetReplica()
411 {
412         BL_ArmatureObject* replica = new BL_ArmatureObject(*this);
413         replica->ProcessReplica();
414         return replica;
415 }
416
417 void BL_ArmatureObject::ProcessReplica()
418 {
419         bPose *pose= m_pose;
420         KX_GameObject::ProcessReplica();
421
422         m_pose = NULL;
423         m_framePose = NULL;
424         game_copy_pose(&m_pose, pose, 1);       
425 }
426
427 void BL_ArmatureObject::ReParentLogic()
428 {
429         SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
430         for (cit.begin(); !cit.end(); ++cit) {
431                 (*cit)->ReParent(this);
432         }
433         KX_GameObject::ReParentLogic();
434 }
435
436 void BL_ArmatureObject::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
437 {
438         SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
439         for (cit.begin(); !cit.end(); ++cit) {
440                 (*cit)->Relink(obj_map);
441         }
442         KX_GameObject::Relink(obj_map);
443 }
444
445 bool BL_ArmatureObject::UnlinkObject(SCA_IObject* clientobj)
446 {
447         // clientobj is being deleted, make sure we don't hold any reference to it
448         bool res = false;
449         SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
450         for (cit.begin(); !cit.end(); ++cit) {
451                 res |= (*cit)->UnlinkObject(clientobj);
452         }
453         return res;
454 }
455
456 void BL_ArmatureObject::ApplyPose()
457 {
458         m_armpose = m_objArma->pose;
459         m_objArma->pose = m_pose;
460         // in the GE, we use ctime to store the timestep
461         m_pose->ctime = (float)m_timestep;
462         //m_scene->r.cfra++;
463         if(m_lastapplyframe != m_lastframe) {
464                 // update the constraint if any, first put them all off so that only the active ones will be updated
465                 SG_DList::iterator<BL_ArmatureConstraint> cit(m_controlledConstraints);
466                 for (cit.begin(); !cit.end(); ++cit) {
467                         (*cit)->UpdateTarget();
468                 }
469                 // update ourself
470                 UpdateBlenderObjectMatrix(m_objArma);
471                 where_is_pose(m_scene, m_objArma); // XXX
472                 // restore ourself
473                 memcpy(m_objArma->obmat, m_obmat, sizeof(m_obmat));
474                 // restore active targets
475                 for (cit.begin(); !cit.end(); ++cit) {
476                         (*cit)->RestoreTarget();
477                 }
478                 m_lastapplyframe = m_lastframe;
479         }
480 }
481
482 void BL_ArmatureObject::RestorePose()
483 {
484         m_objArma->pose = m_armpose;
485         m_armpose = NULL;
486 }
487
488 void BL_ArmatureObject::SetPose(bPose *pose)
489 {
490         extract_pose_from_pose(m_pose, pose);
491         m_lastapplyframe = -1.0;
492 }
493
494 bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, double curtime)
495 {
496         if (curtime != m_lastframe){
497                 m_activePriority = 9999;
498                 // compute the timestep for the underlying IK algorithm
499                 m_timestep = curtime-m_lastframe;
500                 m_lastframe= curtime;
501                 m_activeAct = NULL;
502                 // remember the pose at the start of the frame
503                 GetPose(&m_framePose);
504         }
505
506         if (act) 
507         {
508                 if (priority<=m_activePriority)
509                 {
510                         if (priority<m_activePriority) {
511                                 // this action overwrites the previous ones, start from initial pose to cancel their effects
512                                 SetPose(m_framePose);
513                                 if (m_activeAct && (m_activeAct!=act))
514                                         /* Reset the blend timer since this new action cancels the old one */
515                                         m_activeAct->SetBlendTime(0.0); 
516                         }
517                         m_activeAct = act;
518                         m_activePriority = priority;
519                         m_lastframe = curtime;
520                 
521                         return true;
522                 }
523                 else{
524                         act->SetBlendTime(0.0);
525                         return false;
526                 }
527         }
528         return false;
529 }
530
531 BL_ActionActuator * BL_ArmatureObject::GetActiveAction()
532 {
533         return m_activeAct;
534 }
535
536 void BL_ArmatureObject::GetPose(bPose **pose)
537 {
538         /* If the caller supplies a null pose, create a new one. */
539         /* Otherwise, copy the armature's pose channels into the caller-supplied pose */
540                 
541         if (!*pose) {
542                 /*      probably not to good of an idea to
543                         duplicate everying, but it clears up 
544                         a crash and memory leakage when 
545                         &BL_ActionActuator::m_pose is freed
546                 */
547                 game_copy_pose(pose, m_pose, 0);
548         }
549         else {
550                 if (*pose == m_pose)
551                         // no need to copy if the pointers are the same
552                         return;
553
554                 extract_pose_from_pose(*pose, m_pose);
555         }
556 }
557
558 void BL_ArmatureObject::GetMRDPose(bPose **pose)
559 {
560         /* If the caller supplies a null pose, create a new one. */
561         /* Otherwise, copy the armature's pose channels into the caller-supplied pose */
562
563         if (!*pose)
564                 game_copy_pose(pose, m_pose, 0);
565         else
566                 extract_pose_from_pose(*pose, m_pose);
567 }
568
569 short BL_ArmatureObject::GetActivePriority()
570 {
571         return m_activePriority;
572 }
573
574 double BL_ArmatureObject::GetLastFrame()
575 {
576         return m_lastframe;
577 }
578
579 bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix)
580 {
581         bPoseChannel *pchan;
582
583         ApplyPose();
584         pchan = get_pose_channel(m_objArma->pose, bone->name);
585         if(pchan)
586                 matrix.setValue(&pchan->pose_mat[0][0]);
587         RestorePose();
588
589         return (pchan != NULL);
590 }
591
592 float BL_ArmatureObject::GetBoneLength(Bone* bone) const
593 {
594         return (float)(MT_Point3(bone->head) - MT_Point3(bone->tail)).length();
595 }
596
597 #ifdef WITH_PYTHON
598
599 // PYTHON
600
601 PyTypeObject BL_ArmatureObject::Type = {
602         PyVarObject_HEAD_INIT(NULL, 0)
603         "BL_ArmatureObject",
604         sizeof(PyObjectPlus_Proxy),
605         0,
606         py_base_dealloc,
607         0,
608         0,
609         0,
610         0,
611         py_base_repr,
612         0,
613         &KX_GameObject::Sequence,
614         &KX_GameObject::Mapping,
615         0,0,0,
616         NULL,
617         NULL,
618         0,
619         Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
620         0,0,0,0,0,0,0,
621         Methods,
622         0,
623         0,
624         &KX_GameObject::Type,
625         0,0,0,0,0,0,
626         py_base_new
627 };
628
629 PyMethodDef BL_ArmatureObject::Methods[] = {
630
631         KX_PYMETHODTABLE_NOARGS(BL_ArmatureObject, update),
632         {NULL,NULL} //Sentinel
633 };
634
635 PyAttributeDef BL_ArmatureObject::Attributes[] = {
636
637         KX_PYATTRIBUTE_RO_FUNCTION("constraints",               BL_ArmatureObject, pyattr_get_constraints),
638         KX_PYATTRIBUTE_RO_FUNCTION("channels",          BL_ArmatureObject, pyattr_get_channels),
639         {NULL} //Sentinel
640 };
641
642 PyObject* BL_ArmatureObject::pyattr_get_constraints(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
643 {
644         return KX_PythonSeq_CreatePyObject((static_cast<BL_ArmatureObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_CONSTRAINTS);
645 }
646
647 PyObject* BL_ArmatureObject::pyattr_get_channels(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
648 {
649         BL_ArmatureObject* self = static_cast<BL_ArmatureObject*>(self_v);
650         self->LoadChannels(); // make sure we have the channels
651         return KX_PythonSeq_CreatePyObject((static_cast<BL_ArmatureObject*>(self_v))->m_proxy, KX_PYGENSEQ_OB_TYPE_CHANNELS);
652 }
653
654 KX_PYMETHODDEF_DOC_NOARGS(BL_ArmatureObject, update, 
655                                                   "update()\n"
656                                                   "Make sure that the armature will be updated on next graphic frame.\n"
657                                                   "This is automatically done if a KX_ArmatureActuator with mode run is active\n"
658                                                   "or if an action is playing. This function is usefull in other cases.\n")
659 {
660         SetActiveAction(NULL, 0, KX_GetActiveEngine()->GetFrameTime());
661         Py_RETURN_NONE;
662 }
663
664 #endif // WITH_PYTHON