- Fix for action constraints; for Bone targets (target is input bone

actually) only the relative rotation is used.

- Added scale=1.0 initializer in saving files, this fixes a little  bit
  better upward compatibility

- Still there are cases where bones flip 180 degrees when you read it with
  older Blenders... not sure what it is caused by
This commit is contained in:
2005-07-09 13:41:01 +00:00
parent 24c9dc7322
commit c8f195d00c
3 changed files with 36 additions and 21 deletions

View File

@@ -703,33 +703,54 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
if (ownertype == TARGET_BONE) {
extern void chan_calc_mat(bPoseChannel *chan);
bActionConstraint *data = (bActionConstraint*)con->data;
bPose *pose=NULL;
bPose *pose;
bPoseChannel *pchan, *tchan;
float ans[4][4];
float tempmat3[3][3];
float eul[3];
float s,t;
Mat4One(mat);
Mat4One(mat); // return mat
if (data->tar==NULL) return 0;
/* proper check for bone... (todo) */
/* need proper check for bone... */
if(data->subtarget[0]) {
//pchan = get_pose_channel(ob->pose, substring);
//if (pchan) {
//}
pchan = get_pose_channel(data->tar->pose, data->subtarget);
if (pchan) {
float diff_mat[3][3], arm_mat[3][3], pose_mat[3][3], par_mat[3][3], ipar_mat[3][3];
/* we need the local rotation = current rotation - (parent rotation + restpos) */
Mat3CpyMat4(arm_mat, pchan->bone->arm_mat);
if (pchan->parent) {
Mat3CpyMat4(par_mat, pchan->parent->pose_mat);
Mat3MulMat3(diff_mat, par_mat, arm_mat);
Mat3Inv(ipar_mat, diff_mat);
}
else {
Mat3Inv(ipar_mat, arm_mat);
}
Mat3CpyMat4(pose_mat, pchan->pose_mat);
Mat3MulMat3(tempmat3, ipar_mat, pose_mat);
}
else Mat3One(tempmat3);
}
else {
float ans[4][4];
constraint_target_to_mat4(data->tar, data->subtarget, ans, size, ctime);
/* extract rotation, is in global world coordinates */
Mat3CpyMat4(tempmat3, ans);
}
constraint_target_to_mat4(data->tar, data->subtarget, ans, size, ctime);
/* extract rotation */
Mat3CpyMat4(tempmat3, ans);
Mat3ToEul(tempmat3, eul);
eul[0]*=(float)(180.0/M_PI);
eul[1]*=(float)(180.0/M_PI);
eul[2]*=(float)(180.0/M_PI);
/* Target defines the animation */
s = (eul[data->type]-data->min)/(data->max-data->min);
if (s<0)

View File

@@ -4708,13 +4708,6 @@ static void do_versions(FileData *fd, Main *main)
if(ob->pose) {
ob->pose->flag |= POSE_RECALC;
ob->recalc |= OB_RECALC;
/* initialize for IK caching. we check for zero, so new saved files go fine */
pchan= ob->pose->chanbase.first;
if(pchan && pchan->ik_mat[0][0]==0.0 && pchan->ik_mat[0][1]==0.0 && pchan->ik_mat[0][2]==0.0) {
for(; pchan; pchan= pchan->next)
Mat3One(pchan->ik_mat);
}
}
}
}

View File

@@ -1319,11 +1319,12 @@ static void write_bone(WriteData *wd, Bone* bone)
{
Bone* cbone;
// write_constraints(wd, &bone->constraints);
// PATCH for upward compatibility after 2.37+ armature recode
bone->size[0]= bone->size[1]= bone->size[2]= 1.0f;
// Write this bone
writestruct(wd, DATA, "Bone", 1, bone);
// Write Children
cbone= bone->childbase.first;
while(cbone) {