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