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