Revision: 44331
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44331
Author:   mont29
Date:     2012-02-22 15:35:42 +0000 (Wed, 22 Feb 2012)
Log Message:
-----------
Style code cleanup and consistancy (mainly spaces around assignements, C++ 
comments to C, and misc spaces/tabs cleanup). No functional change.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/armature.c

Modified: trunk/blender/source/blender/blenkernel/intern/armature.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/armature.c   2012-02-22 
15:04:22 UTC (rev 44330)
+++ trunk/blender/source/blender/blenkernel/intern/armature.c   2012-02-22 
15:35:42 UTC (rev 44331)
@@ -4,7 +4,7 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -73,84 +73,87 @@
 #include "BIK_api.h"
 #include "BKE_sketch.h"
 
-/*     **************** Generic Functions, data level *************** */
+/* **************** Generic Functions, data level *************** */
 
 bArmature *add_armature(const char *name)
 {
        bArmature *arm;
-       
-       arm= alloc_libblock (&G.main->armature, ID_AR, name);
+
+       arm = alloc_libblock (&G.main->armature, ID_AR, name);
        arm->deformflag = ARM_DEF_VGROUP|ARM_DEF_ENVELOPE;
        arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */
-       arm->layer= 1;
+       arm->layer = 1;
        return arm;
 }
 
 bArmature *get_armature(Object *ob)
 {
-       if(ob->type==OB_ARMATURE)
+       if(ob->type == OB_ARMATURE)
                return (bArmature *)ob->data;
        return NULL;
 }
 
-void free_bonelist (ListBase *lb)
+void free_bonelist(ListBase *lb)
 {
        Bone *bone;
 
-       for(bone=lb->first; bone; bone=bone->next) {
+       for(bone = lb->first; bone; bone = bone->next) {
                if(bone->prop) {
                        IDP_FreeProperty(bone->prop);
                        MEM_freeN(bone->prop);
                }
                free_bonelist(&bone->childbase);
        }
-       
+
        BLI_freelistN(lb);
 }
 
 void free_armature(bArmature *arm)
 {
-       if (arm) {
+       if(arm) {
                free_bonelist(&arm->bonebase);
-               
+
                /* free editmode data */
-               if (arm->edbo) {
+               if(arm->edbo) {
                        BLI_freelistN(arm->edbo);
-                       
+
                        MEM_freeN(arm->edbo);
-                       arm->edbo= NULL;
+                       arm->edbo = NULL;
                }
 
                /* free sketch */
-               if (arm->sketch) {
+               if(arm->sketch) {
                        freeSketch(arm->sketch);
                        arm->sketch = NULL;
                }
-               
+
                /* free animation data */
-               if (arm->adt) {
+               if(arm->adt) {
                        BKE_free_animdata(&arm->id);
-                       arm->adt= NULL;
+                       arm->adt = NULL;
                }
        }
 }
 
 void make_local_armature(bArmature *arm)
 {
-       Main *bmain= G.main;
-       int is_local= FALSE, is_lib= FALSE;
+       Main *bmain = G.main;
+       int is_local = FALSE, is_lib = FALSE;
        Object *ob;
 
-       if (arm->id.lib==NULL) return;
-       if (arm->id.us==1) {
+       if(arm->id.lib == NULL)
+               return;
+       if(arm->id.us == 1) {
                id_clear_lib_data(bmain, &arm->id);
                return;
        }
 
-       for(ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= 
ob->id.next) {
+       for(ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = 
ob->id.next) {
                if(ob->data == arm) {
-                       if(ob->id.lib) is_lib= TRUE;
-                       else is_local= TRUE;
+                       if(ob->id.lib)
+                               is_lib = TRUE;
+                       else
+                               is_local = TRUE;
                }
        }
 
@@ -158,16 +161,16 @@
                id_clear_lib_data(bmain, &arm->id);
        }
        else if(is_local && is_lib) {
-               bArmature *arm_new= copy_armature(arm);
-               arm_new->id.us= 0;
+               bArmature *arm_new = copy_armature(arm);
+               arm_new->id.us = 0;
 
                /* Remap paths of new ID using old library as base. */
                BKE_id_lib_local_paths(bmain, arm->id.lib, &arm_new->id);
 
-               for(ob= bmain->object.first; ob; ob= ob->id.next) {
+               for(ob = bmain->object.first; ob; ob = ob->id.next) {
                        if(ob->data == arm) {
-                               if(ob->id.lib==NULL) {
-                                       ob->data= arm_new;
+                               if(ob->id.lib == NULL) {
+                                       ob->data = arm_new;
                                        arm_new->id.us++;
                                        arm->id.us--;
                                }
@@ -176,105 +179,104 @@
        }
 }
 
-static void    copy_bonechildren (Bone* newBone, Bone* oldBone, Bone* actBone, 
Bone **newActBone)
+static void copy_bonechildren(Bone* newBone, Bone* oldBone, Bone* actBone, 
Bone **newActBone)
 {
-       Bone    *curBone, *newChildBone;
-       
+       Bone *curBone, *newChildBone;
+
        if(oldBone == actBone)
-               *newActBone= newBone;
+               *newActBone = newBone;
 
        if(oldBone->prop)
-               newBone->prop= IDP_CopyProperty(oldBone->prop);
+               newBone->prop = IDP_CopyProperty(oldBone->prop);
 
-       /*      Copy this bone's list*/
+       /* Copy this bone's list */
        BLI_duplicatelist(&newBone->childbase, &oldBone->childbase);
-       
-       /*      For each child in the list, update it's children*/
-       newChildBone=newBone->childbase.first;
-       for (curBone=oldBone->childbase.first;curBone;curBone=curBone->next){
-               newChildBone->parent=newBone;
+
+       /* For each child in the list, update it's children */
+       newChildBone = newBone->childbase.first;
+       for(curBone = oldBone->childbase.first; curBone; curBone = 
curBone->next){
+               newChildBone->parent = newBone;
                copy_bonechildren(newChildBone, curBone, actBone, newActBone);
-               newChildBone=newChildBone->next;
+               newChildBone = newChildBone->next;
        }
 }
 
 bArmature *copy_armature(bArmature *arm)
 {
        bArmature *newArm;
-       Bone            *oldBone, *newBone;
-       Bone            *newActBone= NULL;
-       
-       newArm= copy_libblock(&arm->id);
+       Bone *oldBone, *newBone;
+       Bone *newActBone= NULL;
+
+       newArm = copy_libblock(&arm->id);
        BLI_duplicatelist(&newArm->bonebase, &arm->bonebase);
-       
-       /*      Duplicate the childrens' lists*/
-       newBone=newArm->bonebase.first;
-       for (oldBone=arm->bonebase.first;oldBone;oldBone=oldBone->next){
-               newBone->parent=NULL;
-               copy_bonechildren (newBone, oldBone, arm->act_bone, 
&newActBone);
-               newBone=newBone->next;
-       };
-       
-       newArm->act_bone= newActBone;
 
-       newArm->edbo= NULL;
-       newArm->act_edbone= NULL;
-       newArm->sketch= NULL;
+       /* Duplicate the childrens' lists*/
+       newBone = newArm->bonebase.first;
+       for(oldBone = arm->bonebase.first; oldBone; oldBone = oldBone->next) {
+               newBone->parent = NULL;
+               copy_bonechildren(newBone, oldBone, arm->act_bone, &newActBone);
+               newBone = newBone->next;
+       }
 
+       newArm->act_bone = newActBone;
+
+       newArm->edbo = NULL;
+       newArm->act_edbone = NULL;
+       newArm->sketch = NULL;
+
        return newArm;
 }
 
-static Bone *get_named_bone_bonechildren (Bone *bone, const char *name)
+static Bone *get_named_bone_bonechildren(Bone *bone, const char *name)
 {
        Bone *curBone, *rbone;
-       
-       if (!strcmp (bone->name, name))
+
+       if(!strcmp(bone->name, name))
                return bone;
-       
-       for (curBone=bone->childbase.first; curBone; curBone=curBone->next){
-               rbone=get_named_bone_bonechildren (curBone, name);
-               if (rbone)
+
+       for(curBone = bone->childbase.first; curBone; curBone = curBone->next) {
+               rbone = get_named_bone_bonechildren(curBone, name);
+               if(rbone)
                        return rbone;
        }
-       
+
        return NULL;
 }
 
 
-Bone *get_named_bone (bArmature *arm, const char *name)
-/*
-       Walk the list until the bone is found
- */
+/* Walk the list until the bone is found */
+Bone *get_named_bone(bArmature *arm, const char *name)
 {
-       Bone *bone=NULL, *curBone;
-       
-       if (!arm) return NULL;
-       
-       for (curBone=arm->bonebase.first; curBone; curBone=curBone->next){
-               bone = get_named_bone_bonechildren (curBone, name);
-               if (bone)
+       Bone *bone = NULL, *curBone;
+
+       if(!arm)
+               return NULL;
+
+       for(curBone = arm->bonebase.first; curBone; curBone = curBone->next) {
+               bone = get_named_bone_bonechildren(curBone, name);
+               if(bone)
                        return bone;
        }
-       
+
        return bone;
 }
 
-/* Finds the best possible extension to the name on a particular axis. (For 
renaming, check for unique names afterwards)
- *     strip_number: removes number extensions  (TODO: not used)
- *     axis: the axis to name on
- *     head/tail: the head/tail co-ordinate of the bone on the specified axis
- */
-int bone_autoside_name (char name[MAXBONENAME], int UNUSED(strip_number), 
short axis, float head, float tail)
+/* Finds the best possible extension to the name on a particular axis. (For 
renaming, check for
+ * unique names afterwards) strip_number: removes number extensions  (TODO: 
not used)
+ * axis: the axis to name on
+ * head/tail: the head/tail co-ordinate of the bone on the specified axis */
+int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short 
axis, float head, float tail)
 {
        unsigned int len;
-       char    basename[MAXBONENAME]= "";
-       char    extension[5]= "";
+       char basename[MAXBONENAME] = "";
+       char extension[5] = "";
 
-       len= strlen(name);
-       if (len == 0) return 0;
+       len = strlen(name);
+       if(len == 0)
+               return 0;
        BLI_strncpy(basename, name, sizeof(basename));
-       
-       /* Figure out extension to append: 
+
+       /* Figure out extension to append:
         *      - The extension to append is based upon the axis that we are 
working on.
         *      - If head happens to be on 0, then we must consider the tail 
position as well to decide
         *        which side the bone is on
@@ -282,31 +284,31 @@
         *              -> Otherwise, extension is added from perspective of 
object based on which side tail goes to
         *      - If head is non-zero, extension is added from perspective of 
object based on side head is on
         */
-       if (axis == 2) {
+       if(axis == 2) {
                /* z-axis - vertical (top/bottom) */
-               if (IS_EQ(head, 0)) {
-                       if (tail < 0)
+               if(IS_EQ(head, 0)) {
+                       if(tail < 0)
                                strcpy(extension, "Bot");
-                       else if (tail > 0)
+                       else if(tail > 0)
                                strcpy(extension, "Top");
                }
                else {
-                       if (head < 0)
+                       if(head < 0)
                                strcpy(extension, "Bot");
                        else
                                strcpy(extension, "Top");
                }
        }
-       else if (axis == 1) {
+       else if(axis == 1) {
                /* y-axis - depth (front/back) */
-               if (IS_EQ(head, 0)) {
-                       if (tail < 0)
+               if(IS_EQ(head, 0)) {
+                       if(tail < 0)
                                strcpy(extension, "Fr");
-                       else if (tail > 0)
+                       else if(tail > 0)
                                strcpy(extension, "Bk");
                }
                else {
-                       if (head < 0)
+                       if(head < 0)
                                strcpy(extension, "Fr");
                        else
                                strcpy(extension, "Bk");
@@ -314,55 +316,58 @@
        }
        else {
                /* x-axis - horizontal (left/right) */
-               if (IS_EQ(head, 0)) {
-                       if (tail < 0)
+               if(IS_EQ(head, 0)) {
+                       if(tail < 0)
                                strcpy(extension, "R");
-                       else if (tail > 0)
+                       else if(tail > 0)
                                strcpy(extension, "L");
                }
                else {
-                       if (head < 0)
+                       if(head < 0)
                                strcpy(extension, "R");
-                       else if (head > 0)
+                       /* XXX Shouldn't this be simple else, as for z and y 
axes? */
+                       else if(head > 0)
                                strcpy(extension, "L");
                }
        }
 
-       /* Simple name truncation 
+       /* Simple name truncation
         *      - truncate if there is an extension and it wouldn't be able to 
fit
         *      - otherwise, just append to end
         */
-       if (extension[0]) {
+       if(extension[0]) {
                int change = 1;
-               
-               while (change) { /* remove extensions */
+
+               while(change) { /* remove extensions */
                        change = 0;
-                       if (len > 2 && basename[len-2]=='.') {

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to