use BLI_strncpy and BLI_snprintf when the size of the string is known.
[blender.git] / source / blender / editors / armature / editarmature_retarget.c
index b750bd5ef1c3f2ab65bbe26356767581d20dc368..9ec27b69835f1a15736eb7905909ba128bdc4985 100644 (file)
@@ -1,6 +1,4 @@
 /*
 /*
- * $Id$
- *
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
@@ -159,14 +157,14 @@ static void getEditBoneRollUpAxis(EditBone *bone, float roll, float up_axis[3])
        sub_v3_v3v3(nor, bone->tail, bone->head);
        
        vec_roll_to_mat3(nor, roll, mat);
        sub_v3_v3v3(nor, bone->tail, bone->head);
        
        vec_roll_to_mat3(nor, roll, mat);
-       VECCOPY(up_axis, mat[2]);
+       copy_v3_v3(up_axis, mat[2]);
 }
 
 static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
 {
        float nor[3], new_up_axis[3], x_axis[3], z_axis[3];
        
 }
 
 static float rollBoneByQuatAligned(EditBone *bone, float old_up_axis[3], float qrot[4], float qroll[4], float aligned_axis[3])
 {
        float nor[3], new_up_axis[3], x_axis[3], z_axis[3];
        
-       VECCOPY(new_up_axis, old_up_axis);
+       copy_v3_v3(new_up_axis, old_up_axis);
        mul_qt_v3(qrot, new_up_axis);
        
        sub_v3_v3v3(nor, bone->tail, bone->head);
        mul_qt_v3(qrot, new_up_axis);
        
        sub_v3_v3v3(nor, bone->tail, bone->head);
@@ -238,7 +236,7 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4]
                
                mul_qt_v3(qroll, normal);
                        
                
                mul_qt_v3(qroll, normal);
                        
-               VECCOPY(new_up_axis, edge->up_axis);
+               copy_v3_v3(new_up_axis, edge->up_axis);
                mul_qt_v3(qrot, new_up_axis);
                
                normalize_v3(new_up_axis);
                mul_qt_v3(qrot, new_up_axis);
                
                normalize_v3(new_up_axis);
@@ -254,7 +252,7 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4])
 {
        float new_up_axis[3];
        
 {
        float new_up_axis[3];
        
-       VECCOPY(new_up_axis, old_up_axis);
+       copy_v3_v3(new_up_axis, old_up_axis);
        mul_qt_v3(qrot, new_up_axis);
        
        return ED_rollBoneToVector(bone, new_up_axis, FALSE);
        mul_qt_v3(qrot, new_up_axis);
        
        return ED_rollBoneToVector(bone, new_up_axis, FALSE);
@@ -369,7 +367,7 @@ static RigNode *newRigNodeHead(RigGraph *rg, RigArc *arc, float p[3])
        node = MEM_callocN(sizeof(RigNode), "rig node");
        BLI_addtail(&rg->nodes, node);
 
        node = MEM_callocN(sizeof(RigNode), "rig node");
        BLI_addtail(&rg->nodes, node);
 
-       VECCOPY(node->p, p);
+       copy_v3_v3(node->p, p);
        node->degree = 1;
        node->arcs = NULL;
        
        node->degree = 1;
        node->arcs = NULL;
        
@@ -391,7 +389,7 @@ static RigNode *newRigNode(RigGraph *rg, float p[3])
        node = MEM_callocN(sizeof(RigNode), "rig node");
        BLI_addtail(&rg->nodes, node);
 
        node = MEM_callocN(sizeof(RigNode), "rig node");
        BLI_addtail(&rg->nodes, node);
 
-       VECCOPY(node->p, p);
+       copy_v3_v3(node->p, p);
        node->degree = 0;
        node->arcs = NULL;
        
        node->degree = 0;
        node->arcs = NULL;
        
@@ -414,12 +412,12 @@ static void RIG_appendEdgeToArc(RigArc *arc, RigEdge *edge)
 
        if (edge->prev == NULL)
        {
 
        if (edge->prev == NULL)
        {
-               VECCOPY(edge->head, arc->head->p);
+               copy_v3_v3(edge->head, arc->head->p);
        }
        else
        {
                RigEdge *last_edge = edge->prev;
        }
        else
        {
                RigEdge *last_edge = edge->prev;
-               VECCOPY(edge->head, last_edge->tail);
+               copy_v3_v3(edge->head, last_edge->tail);
                RIG_calculateEdgeAngles(last_edge, edge);
        }
        
                RIG_calculateEdgeAngles(last_edge, edge);
        }
        
@@ -436,7 +434,7 @@ static void RIG_addEdgeToArc(RigArc *arc, float tail[3], EditBone *bone)
 
        edge = MEM_callocN(sizeof(RigEdge), "rig edge");
 
 
        edge = MEM_callocN(sizeof(RigEdge), "rig edge");
 
-       VECCOPY(edge->tail, tail);
+       copy_v3_v3(edge->tail, tail);
        edge->bone = bone;
        
        if (bone)
        edge->bone = bone;
        
        if (bone)
@@ -452,7 +450,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo
 {
        int i, j;
        
 {
        int i, j;
        
-       for (i = 0, j = 0; template_name[i] != '\0' && i < 31 && j < 31; i++)
+       for (i = 0, j = 0; template_name[i] != '\0' && i < (MAXBONENAME-1) && j < (MAXBONENAME-1); i++)
        {
                if (template_name[i] == '&')
                {
        {
                if (template_name[i] == '&')
                {
@@ -487,14 +485,14 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo
 static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string)
 {
        RigControl *ctrl;
 static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ctrl, GHash *ptr_hash, char *side_string, char *num_string)
 {
        RigControl *ctrl;
-       char name[32];
+       char name[MAXBONENAME];
        
        ctrl = newRigControl(rg);
        
        
        ctrl = newRigControl(rg);
        
-       VECCOPY(ctrl->head, src_ctrl->head);
-       VECCOPY(ctrl->tail, src_ctrl->tail);
-       VECCOPY(ctrl->up_axis, src_ctrl->up_axis);
-       VECCOPY(ctrl->offset, src_ctrl->offset);
+       copy_v3_v3(ctrl->head, src_ctrl->head);
+       copy_v3_v3(ctrl->tail, src_ctrl->tail);
+       copy_v3_v3(ctrl->up_axis, src_ctrl->up_axis);
+       copy_v3_v3(ctrl->offset, src_ctrl->offset);
        
        ctrl->tail_mode = src_ctrl->tail_mode;
        ctrl->flag = src_ctrl->flag;
        
        ctrl->tail_mode = src_ctrl->tail_mode;
        ctrl->flag = src_ctrl->flag;
@@ -533,9 +531,9 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
        
                edge = MEM_callocN(sizeof(RigEdge), "rig edge");
 
        
                edge = MEM_callocN(sizeof(RigEdge), "rig edge");
 
-               VECCOPY(edge->head, src_edge->head);
-               VECCOPY(edge->tail, src_edge->tail);
-               VECCOPY(edge->up_axis, src_edge->up_axis);
+               copy_v3_v3(edge->head, src_edge->head);
+               copy_v3_v3(edge->tail, src_edge->tail);
+               copy_v3_v3(edge->up_axis, src_edge->up_axis);
                
                edge->length = src_edge->length;
                edge->angle = src_edge->angle;
                
                edge->length = src_edge->length;
                edge->angle = src_edge->angle;
@@ -543,7 +541,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash *
                
                if (src_edge->bone != NULL)
                {
                
                if (src_edge->bone != NULL)
                {
-                       char name[32];
+                       char name[MAXBONENAME];
                        renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string);
                        edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob);
                        edge->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
                        renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string);
                        edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob);
                        edge->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
@@ -692,8 +690,8 @@ static void RIG_addControlBone(RigGraph *rg, EditBone *bone)
 {
        RigControl *ctrl = newRigControl(rg);
        ctrl->bone = bone;
 {
        RigControl *ctrl = newRigControl(rg);
        ctrl->bone = bone;
-       VECCOPY(ctrl->head, bone->head);
-       VECCOPY(ctrl->tail, bone->tail);
+       copy_v3_v3(ctrl->head, bone->head);
+       copy_v3_v3(ctrl->tail, bone->tail);
        getEditBoneRollUpAxis(bone, bone->roll, ctrl->up_axis);
        ctrl->tail_mode = TL_NONE;
        
        getEditBoneRollUpAxis(bone, bone->roll, ctrl->up_axis);
        ctrl->tail_mode = TL_NONE;
        
@@ -710,7 +708,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link)
                sub_v3_v3v3(offset, ctrl->bone->head, link->head);
 
                /* if root matches, check for direction too */          
                sub_v3_v3v3(offset, ctrl->bone->head, link->head);
 
                /* if root matches, check for direction too */          
-               if (dot_v3v3(offset, offset) < 0.0001)
+               if (dot_v3v3(offset, offset) < 0.0001f)
                {
                        float vbone[3], vparent[3];
                        
                {
                        float vbone[3], vparent[3];
                        
@@ -728,7 +726,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link)
                                cross_v3_v3v3(nor, vbone, vparent);
                                
                                len = dot_v3v3(nor, nor);
                                cross_v3_v3v3(nor, vbone, vparent);
                                
                                len = dot_v3v3(nor, nor);
-                               if (len < 0.0001)
+                               if (len < 0.0001f)
                                {
                                        flag |= RIG_CTRL_FIT_BONE;
                                }
                                {
                                        flag |= RIG_CTRL_FIT_BONE;
                                }
@@ -767,7 +765,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link)
                ctrl->link = link;
                ctrl->flag = flag;
                
                ctrl->link = link;
                ctrl->flag = flag;
                
-               VECCOPY(ctrl->offset, offset);
+               copy_v3_v3(ctrl->offset, offset);
                
                return 1;
        }
                
                return 1;
        }
@@ -861,8 +859,8 @@ static void RIG_reconnectControlBones(RigGraph *rg)
                                                {
                                                        int fit = 0;
                                                        
                                                {
                                                        int fit = 0;
                                                        
-                                                       fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001;
-                                                       fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001;
+                                                       fit = len_v3v3(ctrl->bone->head, edge->bone->head) < 0.0001f;
+                                                       fit = fit || len_v3v3(ctrl->bone->tail, edge->bone->tail) < 0.0001f;
                                                        
                                                        if (fit)
                                                        {
                                                        
                                                        if (fit)
                                                        {
@@ -1018,13 +1016,13 @@ static void RIG_reconnectControlBones(RigGraph *rg)
                                /* don't link with parent */
                                if (bone->parent != ctrl->bone)
                                {
                                /* don't link with parent */
                                if (bone->parent != ctrl->bone)
                                {
-                                       if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01)
+                                       if (len_v3v3(ctrl->bone->tail, bone->head) < 0.01f)
                                        {
                                                ctrl->tail_mode = TL_HEAD;
                                                ctrl->link_tail = bone;
                                                break;
                                        }
                                        {
                                                ctrl->tail_mode = TL_HEAD;
                                                ctrl->link_tail = bone;
                                                break;
                                        }
-                                       else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01)
+                                       else if (len_v3v3(ctrl->bone->tail, bone->tail) < 0.01f)
                                        {
                                                ctrl->tail_mode = TL_TAIL;
                                                ctrl->link_tail = bone;
                                        {
                                                ctrl->tail_mode = TL_TAIL;
                                                ctrl->link_tail = bone;
@@ -1124,14 +1122,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
                
                if (first_edge->bone == NULL)
                {
                
                if (first_edge->bone == NULL)
                {
-                       if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001)
+                       if (first_edge->bone == NULL && len_v3v3(first_edge->tail, arc->head->p) <= 0.001f)
                        {
                                BLI_remlink(&arc->edges, first_edge);
                                MEM_freeN(first_edge);
                        }
                        else if (arc->head->degree == 1)
                        {
                        {
                                BLI_remlink(&arc->edges, first_edge);
                                MEM_freeN(first_edge);
                        }
                        else if (arc->head->degree == 1)
                        {
-                               RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001);
+                               RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001f);
                                
                                if (new_node)
                                {
                                
                                if (new_node)
                                {
@@ -1148,7 +1146,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
                                                BLI_remlink(&arc->edges, first_edge);
                                                MEM_freeN(first_edge);
                                                
                                                BLI_remlink(&arc->edges, first_edge);
                                                MEM_freeN(first_edge);
                                                
-                                               VECCOPY(arc->head->p, next_edge->head);
+                                               copy_v3_v3(arc->head->p, next_edge->head);
                                        }
                                }
                        }
                                        }
                                }
                        }
@@ -1224,7 +1222,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
                                                        BLI_remlink(&arc->edges, first_edge);
                                                        MEM_freeN(first_edge);
                                                        
                                                        BLI_remlink(&arc->edges, first_edge);
                                                        MEM_freeN(first_edge);
                                                        
-                                                       VECCOPY(arc->head->p, next_edge->head);
+                                                       copy_v3_v3(arc->head->p, next_edge->head);
                                                        
                                                        /* remove null edge in other arcs too */
                                                        for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next)
                                                        
                                                        /* remove null edge in other arcs too */
                                                        for (other_arc = rg->arcs.first; other_arc; other_arc = other_arc->next)
@@ -1254,14 +1252,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
                
                if (last_edge->bone == NULL)
                {
                
                if (last_edge->bone == NULL)
                {
-                       if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001)
+                       if (len_v3v3(last_edge->head, arc->tail->p) <= 0.001f)
                        {
                                BLI_remlink(&arc->edges, last_edge);
                                MEM_freeN(last_edge);
                        }
                        else if (arc->tail->degree == 1)
                        {
                        {
                                BLI_remlink(&arc->edges, last_edge);
                                MEM_freeN(last_edge);
                        }
                        else if (arc->tail->degree == 1)
                        {
-                               RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, last_edge->head, 0.001);
+                               RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, last_edge->head, 0.001f);
                                
                                if (new_node)
                                {
                                
                                if (new_node)
                                {
@@ -1286,7 +1284,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg)
                                                BLI_remlink(&arc->edges, last_edge);
                                                MEM_freeN(last_edge);
                                                
                                                BLI_remlink(&arc->edges, last_edge);
                                                MEM_freeN(last_edge);
                                                
-                                               VECCOPY(arc->tail->p, previous_edge->tail);
+                                               copy_v3_v3(arc->tail->p, previous_edge->tail);
                                                previous_edge->angle = 0;
                                        }
                                }
                                                previous_edge->angle = 0;
                                        }
                                }
@@ -1455,7 +1453,7 @@ static void RIG_printCtrl(RigControl *ctrl, char *indent)
        printf("%sBone: %s\n", indent, ctrl->bone->name);
        printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
        
        printf("%sBone: %s\n", indent, ctrl->bone->name);
        printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
        
-       sprintf(text, "%soffset", indent);
+       BLI_snprintf(text, sizeof(text), "%soffset", indent);
        print_v3(text, ctrl->offset);
        
        printf("%sFlag: %i\n", indent, ctrl->flag);
        print_v3(text, ctrl->offset);
        
        printf("%sFlag: %i\n", indent, ctrl->flag);
@@ -1757,7 +1755,7 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize)
                        sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head);
                        sub_v3_v3v3(v2, tail_vec, ctrl->bone->head);
                        
                        sub_v3_v3v3(v1, ctrl->bone->tail, ctrl->bone->head);
                        sub_v3_v3v3(v2, tail_vec, ctrl->bone->head);
                        
-                       VECCOPY(ctrl->bone->tail, tail_vec);
+                       copy_v3_v3(ctrl->bone->tail, tail_vec);
                        
                        rotation_between_vecs_to_quat(qtail, v1, v2);
                        mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot);
                        
                        rotation_between_vecs_to_quat(qtail, v1, v2);
                        mul_qt_qtqt(ctrl->qrot, qtail, ctrl->qrot);
@@ -1793,7 +1791,7 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f
 {
        float parent_offset[3], tail_offset[3];
        
 {
        float parent_offset[3], tail_offset[3];
        
-       VECCOPY(parent_offset, ctrl->offset);
+       copy_v3_v3(parent_offset, ctrl->offset);
        mul_v3_fl(parent_offset, resize);
        mul_qt_v3(qrot, parent_offset);
        
        mul_v3_fl(parent_offset, resize);
        mul_qt_v3(qrot, parent_offset);
        
@@ -1801,7 +1799,7 @@ static void repositionControl(RigGraph *rigg, RigControl *ctrl, float head[3], f
 
        ctrl->flag |= RIG_CTRL_HEAD_DONE;
 
 
        ctrl->flag |= RIG_CTRL_HEAD_DONE;
 
-       QUATCOPY(ctrl->qrot, qrot); 
+       copy_qt_qt(ctrl->qrot, qrot);
 
        if (ctrl->tail_mode == TL_NONE)
        {
 
        if (ctrl->tail_mode == TL_NONE)
        {
@@ -1838,8 +1836,8 @@ static void repositionBone(bContext *C, RigGraph *rigg, RigEdge *edge, float vec
        
        rotation_between_vecs_to_quat(qrot, v1, v2);
        
        
        rotation_between_vecs_to_quat(qrot, v1, v2);
        
-       VECCOPY(bone->head, vec0);
-       VECCOPY(bone->tail, vec1);
+       copy_v3_v3(bone->head, vec0);
+       copy_v3_v3(bone->tail, vec1);
        
        if (!is_zero_v3(up_axis))
        {
        
        if (!is_zero_v3(up_axis))
        {
@@ -1889,7 +1887,7 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc)
        RigEdge *edge;
        int large_angle = 0;
        float avg_angle = 0;
        RigEdge *edge;
        int large_angle = 0;
        float avg_angle = 0;
-       float avg_length = 0;
+       /* float avg_length = 0; */ /* UNUSED */
        int nb_edges = 0;
        
        
        int nb_edges = 0;
        
        
@@ -1901,7 +1899,7 @@ static RetargetMode detectArcRetargetMode(RigArc *iarc)
        
        avg_angle /= nb_edges - 1; /* -1 because last edge doesn't have an angle */
 
        
        avg_angle /= nb_edges - 1; /* -1 because last edge doesn't have an angle */
 
-       avg_length = iarc->length / nb_edges;
+       /* avg_length = iarc->length / nb_edges; */  /* UNUSED */
        
        
        if (nb_edges > 2)
        
        
        if (nb_edges > 2)
@@ -2015,11 +2013,11 @@ static float costAngle(float original_angle, float vec_first[3], float vec_secon
                {
                        current_angle = saacos(dot_v3v3(vec_first, vec_second));
 
                {
                        current_angle = saacos(dot_v3v3(vec_first, vec_second));
 
-                       return angle_weight * fabs(current_angle - original_angle);
+                       return angle_weight * fabsf(current_angle - original_angle);
                }
                else
                {
                }
                else
                {
-                       return angle_weight * M_PI;
+                       return angle_weight * (float)M_PI;
                }
        }
        else
                }
        }
        else
@@ -2202,7 +2200,9 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
        float angle_weight = 1.0; // GET FROM CONTEXT
        float length_weight = 1.0;
        float distance_weight = 1.0;
        float angle_weight = 1.0; // GET FROM CONTEXT
        float length_weight = 1.0;
        float distance_weight = 1.0;
+#ifndef USE_THREADS
        float min_cost = FLT_MAX;
        float min_cost = FLT_MAX;
+#endif
        float *vec0, *vec1;
        int *best_positions;
        int nb_edges = BLI_countlist(&iarc->edges);
        float *vec0, *vec1;
        int *best_positions;
        int nb_edges = BLI_countlist(&iarc->edges);
@@ -2245,7 +2245,9 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
                int nb_positions = earc->bcount;
                int nb_memo_nodes = nb_positions * nb_positions * (nb_joints + 1);
                MemoNode *table = MEM_callocN(nb_memo_nodes * sizeof(MemoNode), "memoization table");
                int nb_positions = earc->bcount;
                int nb_memo_nodes = nb_positions * nb_positions * (nb_joints + 1);
                MemoNode *table = MEM_callocN(nb_memo_nodes * sizeof(MemoNode), "memoization table");
+#ifndef USE_THREADS
                MemoNode *result;
                MemoNode *result;
+#endif
                float **positions_cache = MEM_callocN(sizeof(float*) * (nb_positions + 2), "positions cache");
                int i;
                
                float **positions_cache = MEM_callocN(sizeof(float*) * (nb_positions + 2), "positions cache");
                int i;
                
@@ -2260,11 +2262,15 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
                        positions_cache[i] = bucket->p;
                }
 
                        positions_cache[i] = bucket->p;
                }
 
+#ifndef USE_THREADS
                result = solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
                result = solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
-               
                min_cost = result->weight;
                min_cost = result->weight;
+#else
+               solveJoints(table, iter, positions_cache, nb_joints, earc->bcount, 0, 0, iarc->edges.first, nb_joints, angle_weight, length_weight, distance_weight);
+#endif
+
                copyMemoPositions(best_positions, table, earc->bcount, nb_joints);
                copyMemoPositions(best_positions, table, earc->bcount, nb_joints);
-               
+
                MEM_freeN(table);
                MEM_freeN(positions_cache);
        }
                MEM_freeN(table);
                MEM_freeN(positions_cache);
        }
@@ -2281,8 +2287,8 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc,
 
        /* set joints to best position */
        for (edge = iarc->edges.first, i = 0;
 
        /* set joints to best position */
        for (edge = iarc->edges.first, i = 0;
-                edge;
-                edge = edge->next, i++)
+            edge;
+            edge = edge->next, i++)
        {
                float *no = NULL;
                if (i < nb_joints)
        {
                float *no = NULL;
                if (i < nb_joints)