Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/ikplugin/intern/iksolver_plugin.c')
-rw-r--r--source/blender/ikplugin/intern/iksolver_plugin.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c
index 7a96edeaf5f..41700b96acc 100644
--- a/source/blender/ikplugin/intern/iksolver_plugin.c
+++ b/source/blender/ikplugin/intern/iksolver_plugin.c
@@ -65,8 +65,8 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
int a, t, segcount= 0, size, newsize, *oldparent, parent;
/* find IK constraint, and validate it */
- for(con= pchan_tip->constraints.first; con; con= con->next) {
- if(con->type==CONSTRAINT_TYPE_KINEMATIC) {
+ for (con= pchan_tip->constraints.first; con; con= con->next) {
+ if (con->type==CONSTRAINT_TYPE_KINEMATIC) {
data=(bKinematicConstraint*)con->data;
if (data->flag & CONSTRAINT_IK_AUTO) break;
if (data->tar==NULL) continue;
@@ -74,36 +74,36 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
if ((con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF))==0 && (con->enforce != 0.0f)) break;
}
}
- if(con==NULL) return;
+ if (con==NULL) return;
/* exclude tip from chain? */
- if(!(data->flag & CONSTRAINT_IK_TIP))
+ if (!(data->flag & CONSTRAINT_IK_TIP))
pchan_tip= pchan_tip->parent;
/* Find the chain's root & count the segments needed */
- for (curchan = pchan_tip; curchan; curchan=curchan->parent){
+ for (curchan = pchan_tip; curchan; curchan=curchan->parent) {
pchan_root = curchan;
curchan->flag |= POSE_CHAIN; // don't forget to clear this
chanlist[segcount]=curchan;
segcount++;
- if(segcount==data->rootbone || segcount>255) break; // 255 is weak
+ if (segcount==data->rootbone || segcount>255) break; // 255 is weak
}
if (!segcount) return;
/* setup the chain data */
/* we make tree-IK, unless all existing targets are in this chain */
- for(tree= pchan_root->iktree.first; tree; tree= tree->next) {
- for(target= tree->targets.first; target; target= target->next) {
+ for (tree= pchan_root->iktree.first; tree; tree= tree->next) {
+ for (target= tree->targets.first; target; target= target->next) {
curchan= tree->pchan[target->tip];
- if(curchan->flag & POSE_CHAIN)
+ if (curchan->flag & POSE_CHAIN)
curchan->flag &= ~POSE_CHAIN;
else
break;
}
- if(target) break;
+ if (target) break;
}
/* create a target */
@@ -111,7 +111,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
target->con= con;
pchan_tip->flag &= ~POSE_CHAIN;
- if(tree==NULL) {
+ if (tree==NULL) {
/* make new tree */
tree= MEM_callocN(sizeof(PoseTree), "posetree");
@@ -123,7 +123,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
tree->pchan= MEM_callocN(segcount*sizeof(void*), "ik tree pchan");
tree->parent= MEM_callocN(segcount*sizeof(int), "ik tree parent");
- for(a=0; a<segcount; a++) {
+ for (a=0; a<segcount; a++) {
tree->pchan[a]= chanlist[segcount-a-1];
tree->parent[a]= a-1;
}
@@ -144,19 +144,19 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
for (;t<tree->totchannel && tree->pchan[t]!=chanlist[segcount-a-1];t++);
if (t>=tree->totchannel)
break;
- for(; a<size && t<tree->totchannel && tree->pchan[t]==chanlist[segcount-a-1]; a++, t++);
+ for (; a<size && t<tree->totchannel && tree->pchan[t]==chanlist[segcount-a-1]; a++, t++);
}
segcount= segcount-a;
target->tip= tree->totchannel + segcount - 1;
if (segcount > 0) {
- for(parent = a - 1; parent < tree->totchannel; parent++)
- if(tree->pchan[parent] == chanlist[segcount-1]->parent)
+ for (parent = a - 1; parent < tree->totchannel; parent++)
+ if (tree->pchan[parent] == chanlist[segcount-1]->parent)
break;
/* shouldn't happen, but could with dependency cycles */
- if(parent == tree->totchannel)
+ if (parent == tree->totchannel)
parent = a - 1;
/* resize array */
@@ -172,7 +172,7 @@ static void initialize_posetree(struct Object *UNUSED(ob), bPoseChannel *pchan_t
MEM_freeN(oldparent);
/* add new pose channels at the end, in reverse order */
- for(a=0; a<segcount; a++) {
+ for (a=0; a<segcount; a++) {
tree->pchan[tree->totchannel+a]= chanlist[segcount-a-1];
tree->parent[tree->totchannel+a]= tree->totchannel+a-1;
}
@@ -256,20 +256,20 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
iktree= MEM_mallocN(sizeof(void*)*tree->totchannel, "ik tree");
- for(a=0; a<tree->totchannel; a++) {
+ for (a=0; a<tree->totchannel; a++) {
pchan= tree->pchan[a];
bone= pchan->bone;
/* set DoF flag */
flag= 0;
- if(!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP))
+ if (!(pchan->ikflag & BONE_IK_NO_XDOF) && !(pchan->ikflag & BONE_IK_NO_XDOF_TEMP))
flag |= IK_XDOF;
- if(!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP))
+ if (!(pchan->ikflag & BONE_IK_NO_YDOF) && !(pchan->ikflag & BONE_IK_NO_YDOF_TEMP))
flag |= IK_YDOF;
- if(!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP))
+ if (!(pchan->ikflag & BONE_IK_NO_ZDOF) && !(pchan->ikflag & BONE_IK_NO_ZDOF_TEMP))
flag |= IK_ZDOF;
- if(tree->stretch && (pchan->ikstretch > 0.0f)) {
+ if (tree->stretch && (pchan->ikstretch > 0.0f)) {
flag |= IK_TRANS_YDOF;
hasstretch = 1;
}
@@ -277,7 +277,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
seg= iktree[a]= IK_CreateSegment(flag);
/* find parent */
- if(a == 0)
+ if (a == 0)
parent= NULL;
else
parent= iktree[tree->parent[a]];
@@ -334,7 +334,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
IK_SetStiffness(seg, IK_Y, pchan->stiffness[1]);
IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]);
- if(tree->stretch && (pchan->ikstretch > 0.0f)) {
+ if (tree->stretch && (pchan->ikstretch > 0.0f)) {
float ikstretch = pchan->ikstretch*pchan->ikstretch;
IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0f-ikstretch, 0.99f));
IK_SetLimit(seg, IK_TRANS_Y, 0.001, 1e10);
@@ -377,10 +377,10 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
copy_m3_m4(goalrot, goal);
/* same for pole vector target */
- if(data->poletar) {
+ if (data->poletar) {
get_constraint_target_matrix(scene, target->con, 1, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
- if(data->flag & CONSTRAINT_IK_SETANGLE) {
+ if (data->flag & CONSTRAINT_IK_SETANGLE) {
/* don't solve IK when we are setting the pole angle */
break;
}
@@ -395,7 +395,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
resultblend= 1;
resultinf= target->con->enforce;
- if(data->flag & CONSTRAINT_IK_GETANGLE) {
+ if (data->flag & CONSTRAINT_IK_GETANGLE) {
poleangledata= data;
data->flag &= ~CONSTRAINT_IK_GETANGLE;
}
@@ -429,14 +429,14 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
iktarget= iktree[target->tip];
- if(data->weight != 0.0f) {
- if(poleconstrain)
+ if (data->weight != 0.0f) {
+ if (poleconstrain)
IK_SolverSetPoleVectorConstraint(solver, iktarget, goalpos,
polepos, data->poleangle, (poleangledata == data));
IK_SolverAddGoal(solver, iktarget, goalpos, data->weight);
}
- if((data->flag & CONSTRAINT_IK_ROT) && (data->orientweight != 0.0f))
- if((data->flag & CONSTRAINT_IK_AUTO)==0)
+ if ((data->flag & CONSTRAINT_IK_ROT) && (data->orientweight != 0.0f))
+ if ((data->flag & CONSTRAINT_IK_AUTO)==0)
IK_SolverAddGoalOrientation(solver, iktarget, goalrot,
data->orientweight);
}
@@ -444,27 +444,27 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
/* solve */
IK_Solve(solver, 0.0f, tree->iterations);
- if(poleangledata)
+ if (poleangledata)
poleangledata->poleangle= IK_SolverGetPoleAngle(solver);
IK_FreeSolver(solver);
/* gather basis changes */
tree->basis_change= MEM_mallocN(sizeof(float[3][3])*tree->totchannel, "ik basis change");
- if(hasstretch)
+ if (hasstretch)
ikstretch= MEM_mallocN(sizeof(float)*tree->totchannel, "ik stretch");
- for(a=0; a<tree->totchannel; a++) {
+ for (a=0; a<tree->totchannel; a++) {
IK_GetBasisChange(iktree[a], tree->basis_change[a]);
- if(hasstretch) {
+ if (hasstretch) {
/* have to compensate for scaling received from parent */
float parentstretch, stretch;
pchan= tree->pchan[a];
parentstretch= (tree->parent[a] >= 0)? ikstretch[tree->parent[a]]: 1.0f;
- if(tree->stretch && (pchan->ikstretch > 0.0f)) {
+ if (tree->stretch && (pchan->ikstretch > 0.0f)) {
float trans[3], length;
IK_GetTranslationChange(iktree[a], trans);
@@ -482,7 +482,7 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
mul_v3_fl(tree->basis_change[a][2], stretch);
}
- if(resultblend && resultinf!=1.0f) {
+ if (resultblend && resultinf!=1.0f) {
unit_m3(identity);
blend_m3_m3m3(tree->basis_change[a], identity,
tree->basis_change[a], resultinf);
@@ -492,15 +492,15 @@ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree)
}
MEM_freeN(iktree);
- if(ikstretch) MEM_freeN(ikstretch);
+ if (ikstretch) MEM_freeN(ikstretch);
}
static void free_posetree(PoseTree *tree)
{
BLI_freelistN(&tree->targets);
- if(tree->pchan) MEM_freeN(tree->pchan);
- if(tree->parent) MEM_freeN(tree->parent);
- if(tree->basis_change) MEM_freeN(tree->basis_change);
+ if (tree->pchan) MEM_freeN(tree->pchan);
+ if (tree->parent) MEM_freeN(tree->parent);
+ if (tree->basis_change) MEM_freeN(tree->basis_change);
MEM_freeN(tree);
}
@@ -511,8 +511,8 @@ void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, fl
{
bPoseChannel *pchan;
- for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- if(pchan->constflag & PCHAN_HAS_IK) // flag is set on editing constraints
+ for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (pchan->constflag & PCHAN_HAS_IK) // flag is set on editing constraints
initialize_posetree(ob, pchan); // will attach it to root!
}
ob->pose->flag &= ~POSE_WAS_REBUILT;
@@ -520,7 +520,7 @@ void iksolver_initialize_tree(struct Scene *UNUSED(scene), struct Object *ob, fl
void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime)
{
- while(pchan->iktree.first) {
+ while (pchan->iktree.first) {
PoseTree *tree= pchan->iktree.first;
int a;
@@ -529,8 +529,8 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose
return;
/* 4. walk over the tree for regular solving */
- for(a=0; a<tree->totchannel; a++) {
- if(!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
+ for (a=0; a<tree->totchannel; a++) {
+ if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag
where_is_pose_bone(scene, ob, tree->pchan[a], ctime, 1);
// tell blender that this channel was controlled by IK, it's cleared on each where_is_pose()
tree->pchan[a]->flag |= POSE_CHAIN;
@@ -540,11 +540,11 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose
/* 6. apply the differences to the channels,
* we need to calculate the original differences first */
- for(a=0; a<tree->totchannel; a++) {
+ for (a=0; a<tree->totchannel; a++) {
make_dmats(tree->pchan[a]);
}
- for(a=0; a<tree->totchannel; a++) {
+ for (a=0; a<tree->totchannel; a++) {
/* sets POSE_DONE */
where_is_ik_bone(tree->pchan[a], tree->basis_change[a]);
}