small merge needed for testing new animsys in 2.5 BGE, mixing own changes with merge...
authorCampbell Barton <ideasman42@gmail.com>
Tue, 16 Jun 2009 19:51:58 +0000 (19:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 16 Jun 2009 19:51:58 +0000 (19:51 +0000)
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20928:20937

1  2 
source/blender/blenkernel/intern/action.c
source/gameengine/Converter/BL_ActionActuator.cpp

@@@ -760,184 -590,6 +760,185 @@@ float get_action_frame_inv(Object *ob, 
  }
  
  
-       for (schan=src->chanbase.first; schan; schan=schan->next, pchan= pchan->next) {
 +
 +
 +/* Calculate the extents of given action */
 +void calc_action_range(const bAction *act, float *start, float *end, int incl_hidden)
 +{
 +      FCurve *fcu;
 +      float min=999999999.0f, max=-999999999.0f;
 +      short foundvert=0;
 +
 +      if (act) {
 +              for (fcu= act->curves.first; fcu; fcu= fcu->next) {
 +                      if (fcu->totvert) {
 +                              float nmin, nmax;
 +                              
 +                              /* get extents for this curve */
 +                              calc_fcurve_range(fcu, &nmin, &nmax);
 +                              
 +                              /* compare to the running tally */
 +                              min= MIN2(min, nmin);
 +                              max= MAX2(max, nmax);
 +                              
 +                              foundvert= 1;
 +                      }
 +              }
 +      }       
 +      
 +      if (foundvert) {
 +              if(min==max) max+= 1.0f;
 +              *start= min;
 +              *end= max;
 +      }
 +      else {
 +              *start= 0.0f;
 +              *end= 1.0f;
 +      }
 +}
 +
 +/* Copy the data from the action-pose (src) into the pose */
 +/* both args are assumed to be valid */
 +/* exported to game engine */
++/* Note! this assumes both poses are aligned, this isnt always true when dealing with user poses */
 +void extract_pose_from_pose(bPose *pose, const bPose *src)
 +{
 +      const bPoseChannel *schan;
 +      bPoseChannel *pchan= pose->chanbase.first;
 +
 +      if (pose==src) {
 +              printf("extract_pose_from_pose source and target are the same\n");
 +              return;
 +      }
 +
++      for (schan=src->chanbase.first; (schan && pchan); schan=schan->next, pchan= pchan->next) {
 +              copy_pose_channel_data(pchan, schan);
 +      }
 +}
 +
 +/* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */
 +void rest_pose(bPose *pose)
 +{
 +      bPoseChannel *pchan;
 +      int i;
 +      
 +      if (!pose)
 +              return;
 +      
 +      memset(pose->stride_offset, 0, sizeof(pose->stride_offset));
 +      memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset));
 +      
 +      for (pchan=pose->chanbase.first; pchan; pchan= pchan->next){
 +              for (i=0; i<3; i++) {
 +                      pchan->loc[i]= 0.0f;
 +                      pchan->quat[i+1]= 0.0f;
 +                      pchan->eul[i]= 0.0f;
 +                      pchan->size[i]= 1.0f;
 +              }
 +              pchan->quat[0]= 1.0f;
 +              
 +              pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE);
 +      }
 +}
 +
 +/* both poses should be in sync */
 +void copy_pose_result(bPose *to, bPose *from)
 +{
 +      bPoseChannel *pchanto, *pchanfrom;
 +      
 +      if(to==NULL || from==NULL) {
 +              printf("pose result copy error\n"); // debug temp
 +              return;
 +      }
 +
 +      if (to==from) {
 +              printf("copy_pose_result source and target are the same\n");
 +              return;
 +      }
 +
 +
 +      for(pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) {
 +              pchanto= get_pose_channel(to, pchanfrom->name);
 +              if(pchanto) {
 +                      Mat4CpyMat4(pchanto->pose_mat, pchanfrom->pose_mat);
 +                      Mat4CpyMat4(pchanto->chan_mat, pchanfrom->chan_mat);
 +                      
 +                      /* used for local constraints */
 +                      VECCOPY(pchanto->loc, pchanfrom->loc);
 +                      QUATCOPY(pchanto->quat, pchanfrom->quat);
 +                      VECCOPY(pchanto->eul, pchanfrom->eul);
 +                      VECCOPY(pchanto->size, pchanfrom->size);
 +                      
 +                      VECCOPY(pchanto->pose_head, pchanfrom->pose_head);
 +                      VECCOPY(pchanto->pose_tail, pchanfrom->pose_tail);
 +                      pchanto->flag= pchanfrom->flag;
 +              }
 +      }
 +}
 +
 +/* For the calculation of the effects of an Action at the given frame on an object 
 + * This is currently only used for the Action Constraint 
 + */
 +void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe)
 +{
 +      bActionGroup *agrp= action_groups_find_named(act, groupname);
 +      
 +      /* clear workob */
 +      clear_workob(workob);
 +      
 +      /* init workob */
 +      Mat4CpyMat4(workob->obmat, ob->obmat);
 +      Mat4CpyMat4(workob->parentinv, ob->parentinv);
 +      Mat4CpyMat4(workob->constinv, ob->constinv);
 +      workob->parent= ob->parent;
 +      workob->track= ob->track;
 +
 +      workob->trackflag= ob->trackflag;
 +      workob->upflag= ob->upflag;
 +      
 +      workob->partype= ob->partype;
 +      workob->par1= ob->par1;
 +      workob->par2= ob->par2;
 +      workob->par3= ob->par3;
 +
 +      workob->constraints.first = ob->constraints.first;
 +      workob->constraints.last = ob->constraints.last;
 +      
 +      workob->pose= pose;     /* need to set pose too, since this is used for both types of Action Constraint */
 +
 +      strcpy(workob->parsubstr, ob->parsubstr);
 +      strcpy(workob->id.name, "OB<ConstrWorkOb>"); /* we don't use real object name, otherwise RNA screws with the real thing */
 +      
 +      /* if we're given a group to use, it's likely to be more efficient (though a bit more dangerous) */
 +      if (agrp) {
 +              /* specifically evaluate this group only */
 +              PointerRNA id_ptr;
 +              
 +              /* get RNA-pointer for the workob's ID */
 +              RNA_id_pointer_create(&workob->id, &id_ptr);
 +              
 +              /* execute action for this group only */
 +              animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe);
 +      }
 +      else {
 +              AnimData adt;
 +              
 +              /* init animdata, and attach to workob */
 +              memset(&adt, 0, sizeof(AnimData));
 +              workob->adt= &adt;
 +              
 +              adt.recalc= ADT_RECALC_ANIM;
 +              adt.action= act;
 +              
 +              /* execute effects of Action on to workob (or it's PoseChannels) */
 +              BKE_animsys_evaluate_animdata(&workob->id, &adt, cframe, ADT_RECALC_ANIM);
 +      }
 +}
 +
 +/* ********** NLA with non-poses works with ipo channels ********** */
 +
 +#if 0 // XXX OLD ANIMATION SYSTEM (TO BE REMOVED)
 +
  /* ************************ Blending with NLA *************** */
  
  static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mode)
@@@ -51,6 -50,8 +51,7 @@@
  #include "BKE_utildefines.h"
  #include "FloatValue.h"
  #include "PyObjectPlus.h"
 -#include "blendef.h"
+ #include "KX_PyMath.h"
  
  #ifdef HAVE_CONFIG_H
  #include <config.h>