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/editors/armature/editarmature.c')
-rw-r--r--source/blender/editors/armature/editarmature.c1942
1 files changed, 971 insertions, 971 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index a2e95622bcf..f698153eb7f 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -102,7 +102,7 @@ void ED_armature_sync_selection(ListBase *edbo)
{
EditBone *ebo;
- for (ebo=edbo->first; ebo; ebo= ebo->next) {
+ for (ebo = edbo->first; ebo; ebo = ebo->next) {
/* if bone is not selectable, we shouldn't alter this setting... */
if ((ebo->flag & BONE_UNSELECTABLE) == 0) {
if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) {
@@ -122,18 +122,18 @@ void ED_armature_sync_selection(ListBase *edbo)
void ED_armature_validate_active(struct bArmature *arm)
{
- EditBone *ebone= arm->act_edbone;
+ EditBone *ebone = arm->act_edbone;
if (ebone) {
if (ebone->flag & BONE_HIDDEN_A)
- arm->act_edbone= NULL;
+ arm->act_edbone = NULL;
}
}
static void bone_free(bArmature *arm, EditBone *bone)
{
- if (arm->act_edbone==bone)
- arm->act_edbone= NULL;
+ if (arm->act_edbone == bone)
+ arm->act_edbone = NULL;
if (bone->prop) {
IDP_FreeProperty(bone->prop);
@@ -148,9 +148,9 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
EditBone *curBone;
/* Find any bones that refer to this bone */
- for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
- if (curBone->parent==exBone) {
- curBone->parent=exBone->parent;
+ for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
+ if (curBone->parent == exBone) {
+ curBone->parent = exBone->parent;
curBone->flag &= ~BONE_CONNECTED;
}
}
@@ -161,7 +161,7 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone)
/* context: editmode armature */
EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
{
- EditBone *eboflip= NULL;
+ EditBone *eboflip = NULL;
char name[MAXBONENAME];
if (ebo == NULL)
@@ -169,9 +169,9 @@ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo)
flip_side_name(name, ebo->name, FALSE);
- for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) {
+ for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) {
if (ebo != eboflip) {
- if (!strcmp (name, eboflip->name))
+ if (!strcmp(name, eboflip->name))
break;
}
}
@@ -187,10 +187,10 @@ static void armature_select_mirrored(bArmature *arm)
if (arm->flag & ARM_MIRROR_EDIT) {
EditBone *curBone, *ebone_mirr;
- for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
if (curBone->flag & BONE_SELECTED) {
- ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
+ ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr)
ebone_mirr->flag |= BONE_SELECTED;
}
@@ -205,16 +205,16 @@ static void armature_tag_select_mirrored(bArmature *arm)
EditBone *curBone;
/* always untag */
- for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
curBone->flag &= ~BONE_DONE;
}
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
- for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (arm->layer & curBone->layer) {
- if (curBone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL)) {
- EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
+ if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) {
+ EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) {
ebone_mirr->flag |= BONE_DONE;
}
@@ -222,10 +222,10 @@ static void armature_tag_select_mirrored(bArmature *arm)
}
}
- for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (curBone->flag & BONE_DONE) {
- EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone);
- curBone->flag |= ebone_mirr->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
+ EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone);
+ curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
}
}
}
@@ -237,9 +237,9 @@ static void armature_tag_unselect(bArmature *arm)
{
EditBone *curBone;
- for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (curBone->flag & BONE_DONE) {
- curBone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL|BONE_DONE);
+ curBone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL | BONE_DONE);
}
}
}
@@ -247,16 +247,16 @@ static void armature_tag_unselect(bArmature *arm)
/* converts Bones to EditBone list, used for tools as well */
EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone *actBone)
{
- EditBone *eBone;
- EditBone *eBoneAct= NULL;
- EditBone *eBoneTest= NULL;
- Bone *curBone;
+ EditBone *eBone;
+ EditBone *eBoneAct = NULL;
+ EditBone *eBoneTest = NULL;
+ Bone *curBone;
- for (curBone=bones->first; curBone; curBone=curBone->next) {
- eBone= MEM_callocN(sizeof(EditBone), "make_editbone");
+ for (curBone = bones->first; curBone; curBone = curBone->next) {
+ eBone = MEM_callocN(sizeof(EditBone), "make_editbone");
/* Copy relevant data from bone to eBone */
- eBone->parent= parent;
+ eBone->parent = parent;
BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name));
eBone->flag = curBone->flag;
@@ -295,32 +295,32 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
eBone->roll = curBone->arm_roll;
/* rest of stuff copy */
- eBone->length= curBone->length;
- eBone->dist= curBone->dist;
- eBone->weight= curBone->weight;
- eBone->xwidth= curBone->xwidth;
- eBone->zwidth= curBone->zwidth;
- eBone->ease1= curBone->ease1;
- eBone->ease2= curBone->ease2;
- eBone->rad_head= curBone->rad_head;
- eBone->rad_tail= curBone->rad_tail;
+ eBone->length = curBone->length;
+ eBone->dist = curBone->dist;
+ eBone->weight = curBone->weight;
+ eBone->xwidth = curBone->xwidth;
+ eBone->zwidth = curBone->zwidth;
+ eBone->ease1 = curBone->ease1;
+ eBone->ease2 = curBone->ease2;
+ eBone->rad_head = curBone->rad_head;
+ eBone->rad_tail = curBone->rad_tail;
eBone->segments = curBone->segments;
eBone->layer = curBone->layer;
if (curBone->prop)
- eBone->prop= IDP_CopyProperty(curBone->prop);
+ eBone->prop = IDP_CopyProperty(curBone->prop);
BLI_addtail(edbo, eBone);
/* Add children if necessary */
if (curBone->childbase.first) {
- eBoneTest= make_boneList(edbo, &curBone->childbase, eBone, actBone);
+ eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone);
if (eBoneTest)
- eBoneAct= eBoneTest;
+ eBoneAct = eBoneTest;
}
- if (curBone==actBone)
- eBoneAct= eBone;
+ if (curBone == actBone)
+ eBoneAct = eBone;
}
return eBoneAct;
@@ -328,7 +328,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone
/* nasty stuff for converting roll in editbones into bones */
/* also sets restposition in armature (arm_mat) */
-static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
+static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist)
{
Bone *curBone;
EditBone *ebone;
@@ -338,13 +338,13 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
float imat[3][3];
float delta[3];
- for (curBone=bonelist->first; curBone; curBone=curBone->next) {
+ for (curBone = bonelist->first; curBone; curBone = curBone->next) {
/* sets local matrix and arm_mat (restpos) */
- where_is_armature_bone(curBone, curBone->parent);
+ BKE_armature_where_is_bone(curBone, curBone->parent);
/* Find the associated editbone */
- for (ebone = editbonelist->first; ebone; ebone=ebone->next)
- if ((Bone*)ebone->temp == curBone)
+ for (ebone = editbonelist->first; ebone; ebone = ebone->next)
+ if ((Bone *)ebone->temp == curBone)
break;
if (ebone) {
@@ -358,16 +358,16 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
invert_m3_m3(imat, premat);
mul_m3_m3m3(difmat, imat, postmat);
#if 0
- printf ("Bone %s\n", curBone->name);
+ printf("Bone %s\n", curBone->name);
print_m4("premat", premat);
print_m4("postmat", postmat);
print_m4("difmat", difmat);
- printf ("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
+ printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2])));
#endif
curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]);
/* and set restposition again */
- where_is_armature_bone(curBone, curBone->parent);
+ BKE_armature_where_is_bone(curBone, curBone->parent);
}
fix_bonelist_roll(&curBone->childbase, editbonelist);
}
@@ -376,25 +376,25 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist)
/* put EditMode back in Object */
void ED_armature_from_edit(Object *obedit)
{
- bArmature *arm= obedit->data;
+ bArmature *arm = obedit->data;
EditBone *eBone, *neBone;
- Bone *newBone;
+ Bone *newBone;
Object *obt;
/* armature bones */
- free_bonelist(&arm->bonebase);
+ BKE_armature_bonelist_free(&arm->bonebase);
/* remove zero sized bones, this gives instable restposes */
- for (eBone=arm->edbo->first; eBone; eBone= neBone) {
- float len= len_v3v3(eBone->head, eBone->tail);
- neBone= eBone->next;
- if (len <= 0.000001f) { /* FLT_EPSILON is too large? */
+ for (eBone = arm->edbo->first; eBone; eBone = neBone) {
+ float len = len_v3v3(eBone->head, eBone->tail);
+ neBone = eBone->next;
+ if (len <= 0.000001f) { /* FLT_EPSILON is too large? */
EditBone *fBone;
/* Find any bones that refer to this bone */
- for (fBone=arm->edbo->first; fBone; fBone= fBone->next) {
- if (fBone->parent==eBone)
- fBone->parent= eBone->parent;
+ for (fBone = arm->edbo->first; fBone; fBone = fBone->next) {
+ if (fBone->parent == eBone)
+ fBone->parent = eBone->parent;
}
if (G.debug & G_DEBUG)
printf("Warning: removed zero sized bone: %s\n", eBone->name);
@@ -403,23 +403,23 @@ void ED_armature_from_edit(Object *obedit)
}
/* Copy the bones from the editData into the armature */
- for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
- newBone= MEM_callocN(sizeof(Bone), "bone");
- eBone->temp= newBone; /* Associate the real Bones with the EditBones */
+ for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
+ newBone = MEM_callocN(sizeof(Bone), "bone");
+ eBone->temp = newBone; /* Associate the real Bones with the EditBones */
BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name));
copy_v3_v3(newBone->arm_head, eBone->head);
copy_v3_v3(newBone->arm_tail, eBone->tail);
newBone->arm_roll = eBone->roll;
- newBone->flag= eBone->flag;
+ newBone->flag = eBone->flag;
if (eBone == arm->act_edbone) {
/* don't change active selection, this messes up separate which uses
* editmode toggle and can separate active bone which is de-selected originally */
/* newBone->flag |= BONE_SELECTED; */ /* important, editbones can be active with only 1 point selected */
- arm->act_edbone= NULL;
- arm->act_bone= newBone;
+ arm->act_edbone = NULL;
+ arm->act_bone = newBone;
}
newBone->roll = 0.0f;
@@ -428,29 +428,29 @@ void ED_armature_from_edit(Object *obedit)
newBone->xwidth = eBone->xwidth;
newBone->zwidth = eBone->zwidth;
- newBone->ease1= eBone->ease1;
- newBone->ease2= eBone->ease2;
- newBone->rad_head= eBone->rad_head;
- newBone->rad_tail= eBone->rad_tail;
- newBone->segments= eBone->segments;
+ newBone->ease1 = eBone->ease1;
+ newBone->ease2 = eBone->ease2;
+ newBone->rad_head = eBone->rad_head;
+ newBone->rad_tail = eBone->rad_tail;
+ newBone->segments = eBone->segments;
newBone->layer = eBone->layer;
if (eBone->prop)
- newBone->prop= IDP_CopyProperty(eBone->prop);
+ newBone->prop = IDP_CopyProperty(eBone->prop);
}
/* Fix parenting in a separate pass to ensure ebone->bone connections
* are valid at this point */
- for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
- newBone= (Bone *)eBone->temp;
+ for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
+ newBone = (Bone *)eBone->temp;
if (eBone->parent) {
- newBone->parent= (Bone *)eBone->parent->temp;
+ newBone->parent = (Bone *)eBone->parent->temp;
BLI_addtail(&newBone->parent->childbase, newBone);
{
float M_parentRest[3][3];
float iM_parentRest[3][3];
- float delta[3];
+ float delta[3];
/* Get the parent's matrix (rotation only) */
sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head);
@@ -476,13 +476,13 @@ void ED_armature_from_edit(Object *obedit)
}
/* Make a pass through the new armature to fix rolling */
- /* also builds restposition again (like where_is_armature) */
+ /* also builds restposition again (like BKE_armature_where_is) */
fix_bonelist_roll(&arm->bonebase, arm->edbo);
/* so all users of this armature should get rebuilt */
- for (obt= G.main->object.first; obt; obt= obt->id.next) {
- if (obt->data==arm)
- armature_rebuild_pose(obt, arm);
+ for (obt = G.main->object.first; obt; obt = obt->id.next) {
+ if (obt->data == arm)
+ BKE_pose_rebuild(obt, arm);
}
DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
@@ -491,8 +491,8 @@ void ED_armature_from_edit(Object *obedit)
void ED_armature_apply_transform(Object *ob, float mat[4][4])
{
EditBone *ebone;
- bArmature *arm= ob->data;
- float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
+ bArmature *arm = ob->data;
+ float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
float mat3[3][3];
copy_m3_m4(mat3, mat);
@@ -502,8 +502,8 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
ED_armature_to_edit(ob);
/* Do the rotations */
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
- float delta[3], tmat[3][3];
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ float delta[3], tmat[3][3];
/* find the current bone's roll matrix */
sub_v3_v3v3(delta, ebone->tail, ebone->head);
@@ -519,13 +519,13 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
/* apply the transfiormed roll back */
mat3_to_vec_roll(tmat, NULL, &ebone->roll);
- ebone->rad_head *= scale;
- ebone->rad_tail *= scale;
- ebone->dist *= scale;
+ ebone->rad_head *= scale;
+ ebone->rad_tail *= scale;
+ ebone->dist *= scale;
/* we could be smarter and scale by the matrix along the x & z axis */
- ebone->xwidth *= scale;
- ebone->zwidth *= scale;
+ ebone->xwidth *= scale;
+ ebone->zwidth *= scale;
}
/* Turn the list into an armature */
@@ -537,15 +537,15 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
/* 0 == do center, 1 == center new, 2 == center cursor */
void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode, int around)
{
- Object *obedit= scene->obedit; // XXX get from context
+ Object *obedit = scene->obedit; // XXX get from context
EditBone *ebone;
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
float cent[3];
/* Put the armature into editmode */
if (ob != obedit) {
ED_armature_to_edit(ob);
- obedit= NULL; /* we cant use this so behave as if there is no obedit */
+ obedit = NULL; /* we cant use this so behave as if there is no obedit */
}
/* Find the centerpoint */
@@ -555,20 +555,20 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode
mul_m4_v3(ob->imat, cent);
}
else {
- if (around==V3D_CENTROID) {
- int total= 0;
+ if (around == V3D_CENTROID) {
+ int total = 0;
zero_v3(cent);
- for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
- total+=2;
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ total += 2;
add_v3_v3(cent, ebone->head);
add_v3_v3(cent, ebone->tail);
}
- mul_v3_fl(cent, 1.0f/(float)total);
+ mul_v3_fl(cent, 1.0f / (float)total);
}
else {
float min[3], max[3];
INIT_MINMAX(min, max);
- for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
DO_MINMAX(ebone->head, min, max);
DO_MINMAX(ebone->tail, min, max);
}
@@ -577,19 +577,19 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode
}
/* Do the adjustments */
- for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
sub_v3_v3(ebone->head, cent);
sub_v3_v3(ebone->tail, cent);
}
/* Turn the list into an armature */
- if (obedit==NULL) {
+ if (obedit == NULL) {
ED_armature_from_edit(ob);
ED_armature_edit_free(ob);
}
/* Adjust object location for new centerpoint */
- if (centermode && obedit==NULL) {
+ if (centermode && obedit == NULL) {
mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */
add_v3_v3(ob->loc, cent);
}
@@ -598,7 +598,7 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode
/* ---------------------- */
/* checks if an EditBone with a matching name already, returning the matching bone if it exists */
-static EditBone *editbone_name_exists (ListBase *edbo, const char *name)
+static EditBone *editbone_name_exists(ListBase *edbo, const char *name)
{
return BLI_findstring(edbo, name, offsetof(EditBone, name));
}
@@ -606,54 +606,54 @@ static EditBone *editbone_name_exists (ListBase *edbo, const char *name)
/* note: there's a unique_bone_name() too! */
static int editbone_unique_check(void *arg, const char *name)
{
- struct {ListBase *lb;void *bone;} *data= arg;
- EditBone *dupli= editbone_name_exists(data->lb, name);
+ struct {ListBase *lb; void *bone; } *data = arg;
+ EditBone *dupli = editbone_name_exists(data->lb, name);
return dupli && dupli != data->bone;
}
void unique_editbone_name(ListBase *edbo, char *name, EditBone *bone)
{
- struct {ListBase *lb; void *bone;} data;
- data.lb= edbo;
- data.bone= bone;
+ struct {ListBase *lb; void *bone; } data;
+ data.lb = edbo;
+ data.bone = bone;
BLI_uniquename_cb(editbone_unique_check, &data, "Bone", '.', name, sizeof(bone->name));
}
/* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */
-static void applyarmature_fix_boneparents (Scene *scene, Object *armob)
+static void applyarmature_fix_boneparents(Scene *scene, Object *armob)
{
Object workob, *ob;
/* go through all objects in database */
- for (ob= G.main->object.first; ob; ob= ob->id.next) {
+ for (ob = G.main->object.first; ob; ob = ob->id.next) {
/* if parent is bone in this armature, apply corrections */
if ((ob->parent == armob) && (ob->partype == PARBONE)) {
/* apply current transform from parent (not yet destroyed),
* then calculate new parent inverse matrix
*/
- object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
+ BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE);
- what_does_parent(scene, ob, &workob);
+ BKE_object_workob_calc_parent(scene, ob, &workob);
invert_m4_m4(ob->parentinv, workob.obmat);
}
}
}
/* set the current pose as the restpose */
-static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
+static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
{
- Scene *scene= CTX_data_scene(C);
- Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
- bArmature *arm= get_armature(ob);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
+ bArmature *arm = BKE_armature_from_object(ob);
bPose *pose;
bPoseChannel *pchan;
EditBone *curbone;
/* don't check if editmode (should be done by caller) */
- if (ob->type!=OB_ARMATURE)
+ if (ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
- if (object_data_is_libdata(ob)) {
+ if (BKE_object_obdata_is_libdata(ob)) {
BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata();
return OPERATOR_CANCELLED;
}
@@ -667,10 +667,10 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
ED_armature_to_edit(ob);
/* get pose of active object and move it out of posemode */
- pose= ob->pose;
+ pose = ob->pose;
- for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) {
- curbone= editbone_name_exists(arm->edbo, pchan->name);
+ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) {
+ curbone = editbone_name_exists(arm->edbo, pchan->name);
/* simply copy the head/tail values from pchan over to curbone */
copy_v3_v3(curbone->head, pchan->pose_head);
@@ -697,7 +697,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
mat3_to_eul(eul, tmat);
/* just use this euler-y as new roll value */
- curbone->roll= eul[1];
+ curbone->roll = eul[1];
}
/* clear transform values for pchan */
@@ -705,7 +705,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
zero_v3(pchan->eul);
unit_qt(pchan->quat);
unit_axis_angle(pchan->rotAxis, &pchan->rotAngle);
- pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f;
+ pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f;
/* set anim lock */
curbone->flag |= BONE_UNKEYED;
@@ -716,13 +716,13 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op)
ED_armature_edit_free(ob);
/* flush positions of posebones */
- where_is_pose(scene, ob);
+ BKE_pose_where_is(scene, ob);
/* fix parenting of objects which are bone-parented */
applyarmature_fix_boneparents(scene, ob);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
return OPERATOR_FINISHED;
}
@@ -739,17 +739,17 @@ void POSE_OT_armature_apply(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* set the current pose as the restpose */
-static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op))
+static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object
/* don't check if editmode (should be done by caller) */
- if (ob->type!=OB_ARMATURE)
+ if (ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
/* loop over all selected pchans
@@ -766,14 +766,14 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op)
* change, thus changing the result we may be trying to record.
*/
copy_m4_m4(delta_mat, pchan->chan_mat);
- pchan_apply_mat4(pchan, delta_mat, TRUE);
+ BKE_pchan_apply_mat4(pchan, delta_mat, TRUE);
}
CTX_DATA_END;
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
return OPERATOR_FINISHED;
}
@@ -790,7 +790,7 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ---------------------- */
@@ -804,13 +804,13 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
bConstraint *con;
/* let's go through all objects in database */
- for (ob= G.main->object.first; ob; ob= ob->id.next) {
+ for (ob = G.main->object.first; ob; ob = ob->id.next) {
/* do some object-type specific things */
if (ob->type == OB_ARMATURE) {
- pose= ob->pose;
- for (pchant= pose->chanbase.first; pchant; pchant= pchant->next) {
- for (con= pchant->constraints.first; con; con= con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ pose = ob->pose;
+ for (pchant = pose->chanbase.first; pchant; pchant = pchant->next) {
+ for (con = pchant->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -818,12 +818,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == srcArm) {
if (ct->subtarget[0] == '\0') {
ct->tar = tarArm;
}
- else if (strcmp(ct->subtarget, pchan->name)==0) {
+ else if (strcmp(ct->subtarget, pchan->name) == 0) {
ct->tar = tarArm;
BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget));
}
@@ -836,15 +836,15 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
/* action constraint? */
if (con->type == CONSTRAINT_TYPE_ACTION) {
- bActionConstraint *data= con->data; // XXX old animation system
+ bActionConstraint *data = con->data; // XXX old animation system
bAction *act;
bActionChannel *achan;
if (data->act) {
- act= data->act;
+ act = data->act;
- for (achan= act->chanbase.first; achan; achan= achan->next) {
- if (strcmp(achan->name, pchan->name)==0)
+ for (achan = act->chanbase.first; achan; achan = achan->next) {
+ if (strcmp(achan->name, pchan->name) == 0)
BLI_strncpy(achan->name, curbone->name, sizeof(achan->name));
}
}
@@ -856,8 +856,8 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
/* fix object-level constraints */
if (ob != srcArm) {
- for (con= ob->constraints.first; con; con= con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ for (con = ob->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -865,12 +865,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == srcArm) {
if (ct->subtarget[0] == '\0') {
ct->tar = tarArm;
}
- else if (strcmp(ct->subtarget, pchan->name)==0) {
+ else if (strcmp(ct->subtarget, pchan->name) == 0) {
ct->tar = tarArm;
BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget));
}
@@ -886,7 +886,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent == srcArm)) {
/* Is object parented to a bone of this src armature? */
- if (ob->partype==PARBONE) {
+ if (ob->partype == PARBONE) {
/* bone name in object */
if (!strcmp(ob->parsubstr, pchan->name))
BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr));
@@ -901,17 +901,17 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann
/* join armature exec is exported for use in object->join objects operator... */
int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *ob= CTX_data_active_object(C);
- bArmature *arm= (ob)? ob->data: NULL;
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = CTX_data_active_object(C);
+ bArmature *arm = (ob) ? ob->data : NULL;
bPose *pose, *opose;
bPoseChannel *pchan, *pchann;
EditBone *curbone;
- float mat[4][4], oimat[4][4];
+ float mat[4][4], oimat[4][4];
/* Ensure we're not in editmode and that the active object is an armature*/
- if (!ob || ob->type!=OB_ARMATURE)
+ if (!ob || ob->type != OB_ARMATURE)
return OPERATOR_CANCELLED;
if (!arm || arm->edbo)
return OPERATOR_CANCELLED;
@@ -920,19 +920,19 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
ED_armature_to_edit(ob);
/* get pose of active object and move it out of posemode */
- pose= ob->pose;
+ pose = ob->pose;
ob->mode &= ~OB_MODE_POSE;
- CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases)
+ CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases)
{
- if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) {
- bArmature *curarm= base->object->data;
+ if ((base->object->type == OB_ARMATURE) && (base->object != ob)) {
+ bArmature *curarm = base->object->data;
/* Make a list of editbones in current armature */
ED_armature_to_edit(base->object);
/* Get Pose of current armature */
- opose= base->object->pose;
+ opose = base->object->pose;
base->object->mode &= ~OB_MODE_POSE;
//BASACT->flag &= ~OB_MODE_POSE;
@@ -941,9 +941,9 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
mult_m4_m4m4(mat, oimat, base->object->obmat);
/* Copy bones and posechannels from the object to the edit armature */
- for (pchan=opose->chanbase.first; pchan; pchan=pchann) {
- pchann= pchan->next;
- curbone= editbone_name_exists(curarm->edbo, pchan->name);
+ for (pchan = opose->chanbase.first; pchan; pchan = pchann) {
+ pchann = pchan->next;
+ curbone = editbone_name_exists(curarm->edbo, pchan->name);
/* Get new name */
unique_editbone_name(arm->edbo, curbone->name, NULL);
@@ -991,8 +991,8 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
BLI_remlink(&opose->chanbase, pchan);
BLI_addtail(&pose->chanbase, pchan);
- free_pose_channels_hash(opose);
- free_pose_channels_hash(pose);
+ BKE_pose_channels_hash_free(opose);
+ BKE_pose_channels_hash_free(pose);
}
ED_base_object_free_and_unlink(bmain, scene, base);
@@ -1000,12 +1000,12 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op))
}
CTX_DATA_END;
- DAG_scene_sort(bmain, scene); // because we removed object(s)
+ DAG_scene_sort(bmain, scene); /* because we removed object(s) */
ED_armature_from_edit(ob);
ED_armature_edit_free(ob);
- WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
+ WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
return OPERATOR_FINISHED;
}
@@ -1021,16 +1021,16 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
ListBase *opchans, *npchans;
/* get reference to list of bones in original and new armatures */
- opchans= &origArm->pose->chanbase;
- npchans= &newArm->pose->chanbase;
+ opchans = &origArm->pose->chanbase;
+ npchans = &newArm->pose->chanbase;
/* let's go through all objects in database */
- for (ob= G.main->object.first; ob; ob= ob->id.next) {
+ for (ob = G.main->object.first; ob; ob = ob->id.next) {
/* do some object-type specific things */
if (ob->type == OB_ARMATURE) {
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
- for (con= pchan->constraints.first; con; con= con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
+ for (con = pchan->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1038,7 +1038,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
/* any targets which point to original armature are redirected to the new one only if:
* - the target isn't origArm/newArm itself
* - the target is one that can be found in newArm/origArm
@@ -1046,12 +1046,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
if (ct->subtarget[0] != 0) {
if (ct->tar == origArm) {
if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
- ct->tar= newArm;
+ ct->tar = newArm;
}
}
else if (ct->tar == newArm) {
if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
- ct->tar= origArm;
+ ct->tar = origArm;
}
}
}
@@ -1067,8 +1067,8 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
/* fix object-level constraints */
if (ob != origArm) {
- for (con= ob->constraints.first; con; con= con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ for (con = ob->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
@@ -1076,7 +1076,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
/* any targets which point to original armature are redirected to the new one only if:
* - the target isn't origArm/newArm itself
* - the target is one that can be found in newArm/origArm
@@ -1084,12 +1084,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
if (ct->subtarget[0] != '\0') {
if (ct->tar == origArm) {
if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) {
- ct->tar= newArm;
+ ct->tar = newArm;
}
}
else if (ct->tar == newArm) {
if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) {
- ct->tar= origArm;
+ ct->tar = origArm;
}
}
}
@@ -1107,7 +1107,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
/* Is object parented to a bone of this src armature? */
if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) {
if (BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) {
- ob->parent= newArm;
+ ob->parent = newArm;
}
}
}
@@ -1120,7 +1120,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm)
*/
static void separate_armature_bones(Object *ob, short sel)
{
- bArmature *arm= (bArmature *)ob->data;
+ bArmature *arm = (bArmature *)ob->data;
bPoseChannel *pchan, *pchann;
EditBone *curbone;
@@ -1128,35 +1128,35 @@ static void separate_armature_bones(Object *ob, short sel)
ED_armature_to_edit(ob);
/* go through pose-channels, checking if a bone should be removed */
- for (pchan=ob->pose->chanbase.first; pchan; pchan=pchann) {
- pchann= pchan->next;
- curbone= editbone_name_exists(arm->edbo, pchan->name);
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) {
+ pchann = pchan->next;
+ curbone = editbone_name_exists(arm->edbo, pchan->name);
/* check if bone needs to be removed */
if ( (sel && (curbone->flag & BONE_SELECTED)) ||
- (!sel && !(curbone->flag & BONE_SELECTED)) )
+ (!sel && !(curbone->flag & BONE_SELECTED)) )
{
EditBone *ebo;
bPoseChannel *pchn;
/* clear the bone->parent var of any bone that had this as its parent */
- for (ebo= arm->edbo->first; ebo; ebo= ebo->next) {
+ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
if (ebo->parent == curbone) {
- ebo->parent= NULL;
- ebo->temp= NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */
+ ebo->parent = NULL;
+ ebo->temp = NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */
ebo->flag &= ~BONE_CONNECTED;
}
}
/* clear the pchan->parent var of any pchan that had this as its parent */
- for (pchn= ob->pose->chanbase.first; pchn; pchn=pchn->next) {
+ for (pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) {
if (pchn->parent == pchan)
- pchn->parent= NULL;
+ pchn->parent = NULL;
}
/* free any of the extra-data this pchan might have */
- free_pose_channel(pchan);
- free_pose_channels_hash(ob->pose);
+ BKE_pose_channel_free(pchan);
+ BKE_pose_channels_hash_free(ob->pose);
/* get rid of unneeded bone */
bone_free(arm, curbone);
@@ -1170,11 +1170,11 @@ static void separate_armature_bones(Object *ob, short sel)
}
/* separate selected bones into their armature */
-static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
+static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op))
{
- Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
- Object *obedit= CTX_data_edit_object(C);
+ Main *bmain = CTX_data_main(C);
+ Scene *scene = CTX_data_scene(C);
+ Object *obedit = CTX_data_edit_object(C);
Object *oldob, *newob;
Base *oldbase, *newbase;
@@ -1197,14 +1197,14 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
// TODO: use context iterators for this?
CTX_DATA_BEGIN (C, Base *, base, visible_bases)
{
- if (base->object==obedit) base->flag |= 1;
+ if (base->object == obedit) base->flag |= 1;
else base->flag &= ~1;
}
CTX_DATA_END;
/* 1) store starting settings and exit editmode */
- oldob= obedit;
- oldbase= BASACT;
+ oldob = obedit;
+ oldbase = BASACT;
oldob->mode &= ~OB_MODE_POSE;
//oldbase->flag &= ~OB_POSEMODE;
@@ -1212,8 +1212,8 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
ED_armature_edit_free(obedit);
/* 2) duplicate base */
- newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
- newob= newbase->object;
+ newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
+ newob = newbase->object;
newbase->flag &= ~SELECT;
@@ -1225,17 +1225,17 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op))
/* 4) fix links before depsgraph flushes */ // err... or after?
separated_armature_fix_links(oldob, newob);
- DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
- DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
+ DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */
+ DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */
/* 5) restore original conditions */
- obedit= oldob;
+ obedit = oldob;
ED_armature_to_edit(obedit);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
/* recalc/redraw + cleanup */
WM_cursor_wait(0);
@@ -1256,20 +1256,20 @@ void ARMATURE_OT_separate(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* **************** END tools on Editmode Armature **************** */
/* **************** PoseMode & EditMode *************************** */
/* only for opengl selection indices */
-Bone *get_indexed_bone (Object *ob, int index)
+Bone *get_indexed_bone(Object *ob, int index)
{
bPoseChannel *pchan;
- if (ob->pose==NULL) return NULL;
- index>>=16; // bone selection codes use left 2 bytes
+ if (ob->pose == NULL) return NULL;
+ index >>= 16; // bone selection codes use left 2 bytes
- pchan= BLI_findlink(&ob->pose->chanbase, index);
+ pchan = BLI_findlink(&ob->pose->chanbase, index);
return pchan ? pchan->bone : NULL;
}
@@ -1277,22 +1277,22 @@ Bone *get_indexed_bone (Object *ob, int index)
/* only bones from base are checked on */
static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short findunsel)
{
- Object *obedit= scene->obedit; // XXX get from context
+ Object *obedit = scene->obedit; // XXX get from context
Bone *bone;
EditBone *ebone;
- void *firstunSel=NULL, *firstSel=NULL, *data;
+ void *firstunSel = NULL, *firstSel = NULL, *data;
unsigned int hitresult;
- short i, takeNext=0, sel;
+ short i, takeNext = 0, sel;
- for (i=0; i< hits; i++) {
- hitresult = buffer[3+(i*4)];
+ for (i = 0; i < hits; i++) {
+ hitresult = buffer[3 + (i * 4)];
- if (!(hitresult & BONESEL_NOSEL)) { // -1
- if (hitresult & BONESEL_ANY) { // to avoid including objects in selection
+ if (!(hitresult & BONESEL_NOSEL)) { // -1
+ if (hitresult & BONESEL_ANY) { // to avoid including objects in selection
hitresult &= ~(BONESEL_ANY);
/* Determine what the current bone is */
- if (obedit==NULL || base->object!=obedit) {
+ if (obedit == NULL || base->object != obedit) {
/* no singular posemode, so check for correct object */
if (base->selcol == (hitresult & 0xFFFF)) {
bone = get_indexed_bone(base->object, hitresult);
@@ -1305,12 +1305,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *
data = bone;
}
else {
- data= NULL;
- sel= 0;
+ data = NULL;
+ sel = 0;
}
}
else {
- bArmature *arm= obedit->data;
+ bArmature *arm = obedit->data;
ebone = BLI_findlink(arm->edbo, hitresult);
if (findunsel)
@@ -1323,12 +1323,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *
if (data) {
if (sel) {
- if (!firstSel) firstSel= data;
- takeNext=1;
+ if (!firstSel) firstSel = data;
+ takeNext = 1;
}
else {
if (!firstunSel)
- firstunSel=data;
+ firstunSel = data;
if (takeNext)
return data;
}
@@ -1348,7 +1348,7 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *
/* used by posemode as well editmode */
/* only checks scene->basact! */
/* x and y are mouse coords (area space) */
-static void *get_nearest_bone (bContext *C, short findunsel, int x, int y)
+static void *get_nearest_bone(bContext *C, short findunsel, int x, int y)
{
ViewContext vc;
rcti rect;
@@ -1362,9 +1362,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y)
rect.ymin = rect.ymax = y;
glInitNames();
- hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
+ hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
- if (hits>0)
+ if (hits > 0)
return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel);
return NULL;
@@ -1373,9 +1373,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y)
/* Get the first available child of an editbone */
static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_visibility)
{
- EditBone *curbone, *chbone=NULL;
+ EditBone *curbone, *chbone = NULL;
- for (curbone= arm->edbo->first; curbone; curbone= curbone->next) {
+ for (curbone = arm->edbo->first; curbone; curbone = curbone->next) {
if (curbone->parent == pabone) {
if (use_visibility) {
if ((arm->layer & curbone->layer) && !(pabone->flag & BONE_HIDDEN_A)) {
@@ -1394,7 +1394,7 @@ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_
/* **************** Posemode stuff ********************** */
-static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend)
+static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend)
{
Bone *curBone;
@@ -1402,7 +1402,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend
if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE))
return;
- // XXX old cruft! use notifiers instead
+ // XXX old cruft! use notifiers instead
//select_actionchannel_by_name (ob->action, bone->name, !(shift));
if (extend)
@@ -1410,7 +1410,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend
else
bone->flag |= BONE_SELECTED;
- for (curBone=bone->childbase.first; curBone; curBone=curBone->next)
+ for (curBone = bone->childbase.first; curBone; curBone = curBone->next)
selectconnected_posebonechildren(ob, curBone, extend);
}
@@ -1418,25 +1418,25 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend
/* previously known as "selectconnected_posearmature" */
static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
- Object *ob= CTX_data_edit_object(C);
- Bone *bone, *curBone, *next= NULL;
- int extend= RNA_boolean_get(op->ptr, "extend");
+ Object *ob = CTX_data_edit_object(C);
+ Bone *bone, *curBone, *next = NULL;
+ int extend = RNA_boolean_get(op->ptr, "extend");
view3d_operator_needs_opengl(C);
if (extend)
- bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
+ bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
else
- bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
+ bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
if (!bone)
return OPERATOR_CANCELLED;
/* Select parents */
- for (curBone=bone; curBone; curBone=next) {
+ for (curBone = bone; curBone; curBone = next) {
/* ignore bone if cannot be selected */
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
- // XXX old cruft! use notifiers instead
+ // XXX old cruft! use notifiers instead
//select_actionchannel_by_name (ob->action, curBone->name, !(shift));
if (extend)
@@ -1445,26 +1445,26 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev
curBone->flag |= BONE_SELECTED;
if (curBone->flag & BONE_CONNECTED)
- next=curBone->parent;
+ next = curBone->parent;
else
- next=NULL;
+ next = NULL;
}
else
- next= NULL;
+ next = NULL;
}
/* Select children */
- for (curBone=bone->childbase.first; curBone; curBone=next)
+ for (curBone = bone->childbase.first; curBone; curBone = next)
selectconnected_posebonechildren(ob, curBone, extend);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
static int pose_select_linked_poll(bContext *C)
{
- return ( ED_operator_view3d_active(C) && ED_operator_posemode(C) );
+ return (ED_operator_view3d_active(C) && ED_operator_posemode(C) );
}
void POSE_OT_select_linked(wmOperatorType *ot)
@@ -1480,7 +1480,7 @@ void POSE_OT_select_linked(wmOperatorType *ot)
ot->poll = pose_select_linked_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
@@ -1495,70 +1495,70 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e
{
bArmature *arm;
EditBone *bone, *curBone, *next;
- int extend= RNA_boolean_get(op->ptr, "extend");
- Object *obedit= CTX_data_edit_object(C);
- arm= obedit->data;
+ int extend = RNA_boolean_get(op->ptr, "extend");
+ Object *obedit = CTX_data_edit_object(C);
+ arm = obedit->data;
view3d_operator_needs_opengl(C);
if (extend)
- bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
+ bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]);
else
- bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
+ bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]);
if (!bone)
return OPERATOR_CANCELLED;
/* Select parents */
- for (curBone=bone; curBone; curBone=next) {
+ for (curBone = bone; curBone; curBone = next) {
if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
if (extend) {
- curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
else {
- curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
if (curBone->flag & BONE_CONNECTED)
- next=curBone->parent;
+ next = curBone->parent;
else
- next=NULL;
+ next = NULL;
}
/* Select children */
while (bone) {
- for (curBone=arm->edbo->first; curBone; curBone=next) {
+ for (curBone = arm->edbo->first; curBone; curBone = next) {
next = curBone->next;
- if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE)==0) {
+ if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE) == 0) {
if (curBone->flag & BONE_CONNECTED) {
if (extend)
- curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
else
- curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- bone=curBone;
+ curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ bone = curBone;
break;
}
else {
- bone=NULL;
+ bone = NULL;
break;
}
}
}
if (!curBone)
- bone=NULL;
+ bone = NULL;
}
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
static int armature_select_linked_poll(bContext *C)
{
- return ( ED_operator_view3d_active(C) && ED_operator_editarmature(C) );
+ return (ED_operator_view3d_active(C) && ED_operator_editarmature(C) );
}
void ARMATURE_OT_select_linked(wmOperatorType *ot)
@@ -1574,7 +1574,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
ot->poll = armature_select_linked_poll;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties s*/
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
@@ -1582,71 +1582,71 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
/* does bones and points */
/* note that BONE ROOT only gets drawn for root bones (or without IK) */
-static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask)
+static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask)
{
EditBone *ebone;
rcti rect;
unsigned int buffer[MAXPICKBUF];
- unsigned int hitresult, besthitresult=BONESEL_NOSEL;
- int i, mindep= 4;
+ unsigned int hitresult, besthitresult = BONESEL_NOSEL;
+ int i, mindep = 4;
short hits;
glInitNames();
- rect.xmin = mval[0]-5;
- rect.xmax = mval[0]+5;
- rect.ymin = mval[1]-5;
- rect.ymax = mval[1]+5;
-
- hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
- if (hits==0) {
- rect.xmin = mval[0]-12;
- rect.xmax = mval[0]+12;
- rect.ymin = mval[1]-12;
- rect.ymax = mval[1]+12;
- hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
+ rect.xmin = mval[0] - 5;
+ rect.xmax = mval[0] + 5;
+ rect.ymin = mval[1] - 5;
+ rect.ymax = mval[1] + 5;
+
+ hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
+ if (hits == 0) {
+ rect.xmin = mval[0] - 12;
+ rect.xmax = mval[0] + 12;
+ rect.ymin = mval[1] - 12;
+ rect.ymax = mval[1] + 12;
+ hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect);
}
/* See if there are any selected bones in this group */
- if (hits>0) {
+ if (hits > 0) {
- if (hits==1) {
+ if (hits == 1) {
if (!(buffer[3] & BONESEL_NOSEL))
- besthitresult= buffer[3];
+ besthitresult = buffer[3];
}
else {
- for (i=0; i< hits; i++) {
- hitresult= buffer[3+(i*4)];
+ for (i = 0; i < hits; i++) {
+ hitresult = buffer[3 + (i * 4)];
if (!(hitresult & BONESEL_NOSEL)) {
int dep;
ebone = BLI_findlink(edbo, hitresult & ~BONESEL_ANY);
/* clicks on bone points get advantage */
- if ( hitresult & (BONESEL_ROOT|BONESEL_TIP)) {
+ if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) {
/* but also the unselected one */
if (findunsel) {
- if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL)==0)
- dep= 1;
- else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL)==0)
- dep= 1;
+ if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0)
+ dep = 1;
+ else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0)
+ dep = 1;
else
- dep= 2;
+ dep = 2;
}
- else dep= 2;
+ else dep = 2;
}
else {
/* bone found */
if (findunsel) {
- if ((ebone->flag & BONE_SELECTED)==0)
- dep= 2;
+ if ((ebone->flag & BONE_SELECTED) == 0)
+ dep = 2;
else
- dep= 3;
+ dep = 3;
}
- else dep= 3;
+ else dep = 3;
}
if (dep < mindep) {
- mindep= dep;
- besthitresult= hitresult;
+ mindep = dep;
+ besthitresult = hitresult;
}
}
}
@@ -1654,7 +1654,7 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2],
if (!(besthitresult & BONESEL_NOSEL)) {
- ebone= BLI_findlink(edbo, besthitresult & ~BONESEL_ANY);
+ ebone = BLI_findlink(edbo, besthitresult & ~BONESEL_ANY);
*selmask = 0;
if (besthitresult & BONESEL_ROOT)
@@ -1675,9 +1675,9 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2],
static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
bArmature *arm;
- EditBone *curBone, *ebone_next;
+ EditBone *curBone, *ebone_next;
bConstraint *con;
- Object *obedit= CTX_data_edit_object(C); // XXX get from context
+ Object *obedit = CTX_data_edit_object(C); // XXX get from context
arm = obedit->data;
/* cancel if nothing selected */
@@ -1689,31 +1689,31 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
/* First erase any associated pose channel */
if (obedit->pose) {
bPoseChannel *pchan, *pchan_next;
- for (pchan=obedit->pose->chanbase.first; pchan; pchan= pchan_next) {
- pchan_next= pchan->next;
+ for (pchan = obedit->pose->chanbase.first; pchan; pchan = pchan_next) {
+ pchan_next = pchan->next;
curBone = editbone_name_exists(arm->edbo, pchan->name);
if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
- free_pose_channel(pchan);
- free_pose_channels_hash(obedit->pose);
- BLI_freelinkN (&obedit->pose->chanbase, pchan);
+ BKE_pose_channel_free(pchan);
+ BKE_pose_channels_hash_free(obedit->pose);
+ BLI_freelinkN(&obedit->pose->chanbase, pchan);
}
else {
- for (con= pchan->constraints.first; con; con= con->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
+ for (con = pchan->constraints.first; con; con = con->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == obedit) {
if (ct->subtarget[0]) {
curBone = editbone_name_exists(arm->edbo, ct->subtarget);
if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) {
con->flag |= CONSTRAINT_DISABLE;
- ct->subtarget[0]= 0;
+ ct->subtarget[0] = 0;
}
}
}
@@ -1728,11 +1728,11 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
}
- for (curBone=arm->edbo->first; curBone; curBone= ebone_next) {
- ebone_next= curBone->next;
+ for (curBone = arm->edbo->first; curBone; curBone = ebone_next) {
+ ebone_next = curBone->next;
if (arm->layer & curBone->layer) {
if (curBone->flag & BONE_SELECTED) {
- if (curBone==arm->act_edbone) arm->act_edbone= NULL;
+ if (curBone == arm->act_edbone) arm->act_edbone = NULL;
ED_armature_edit_bone_remove(arm, curBone);
}
}
@@ -1741,7 +1741,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -1759,7 +1759,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* toggle==0: deselect
@@ -1768,35 +1768,35 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
*/
void ED_armature_deselect_all(Object *obedit, int toggle)
{
- bArmature *arm= obedit->data;
- EditBone *eBone;
- int sel=1;
+ bArmature *arm = obedit->data;
+ EditBone *eBone;
+ int sel = 1;
- if (toggle==1) {
+ if (toggle == 1) {
/* Determine if there are any selected bones
* and therefore whether we are selecting or deselecting */
- for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
+ for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
// if (arm->layer & eBone->layer) {
if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) {
- sel=0;
+ sel = 0;
break;
}
// }
}
}
- else sel= toggle;
+ else sel = toggle;
/* Set the flags */
- for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
- if (sel==2) {
+ for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
+ if (sel == 2) {
/* invert selection of bone */
if (EBONE_VISIBLE(arm, eBone)) {
eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- if (arm->act_edbone==eBone)
- arm->act_edbone= NULL;
+ if (arm->act_edbone == eBone)
+ arm->act_edbone = NULL;
}
}
- else if (sel==1) {
+ else if (sel == 1) {
/* select bone */
if (EBONE_VISIBLE(arm, eBone)) {
eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
@@ -1807,8 +1807,8 @@ void ED_armature_deselect_all(Object *obedit, int toggle)
else {
/* deselect bone */
eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- if (arm->act_edbone==eBone)
- arm->act_edbone= NULL;
+ if (arm->act_edbone == eBone)
+ arm->act_edbone = NULL;
}
}
@@ -1817,12 +1817,12 @@ void ED_armature_deselect_all(Object *obedit, int toggle)
void ED_armature_deselect_all_visible(Object *obedit)
{
- bArmature *arm= obedit->data;
- EditBone *ebone;
+ bArmature *arm = obedit->data;
+ EditBone *ebone;
- for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
/* first and foremost, bone must be visible and selected */
- if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE)==0) {
+ if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
@@ -1834,27 +1834,27 @@ void ED_armature_deselect_all_visible(Object *obedit)
static int ebone_select_flag(EditBone *ebone)
{
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
- return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED|BONE_TIPSEL));
+ return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED | BONE_TIPSEL));
}
else {
- return ebone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
+ return ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
}
}
/* context: editmode armature in view3d */
int mouse_armature(bContext *C, const int mval[2], int extend)
{
- Object *obedit= CTX_data_edit_object(C);
- bArmature *arm= obedit->data;
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = obedit->data;
ViewContext vc;
EditBone *nearBone = NULL;
- int selmask;
+ int selmask;
view3d_set_viewcontext(C, &vc);
BIF_sk_selectStroke(C, mval, extend);
- nearBone= get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
+ nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
if (nearBone) {
if (!extend)
@@ -1870,7 +1870,7 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
/* hold shift inverts this bone's selection */
if (nearBone->flag & BONE_SELECTED) {
/* deselect this bone */
- nearBone->flag &= ~(BONE_TIPSEL|BONE_SELECTED);
+ nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
/* only deselect parent tip if it is not selected */
if (!(nearBone->parent->flag & BONE_SELECTED))
nearBone->parent->flag &= ~BONE_TIPSEL;
@@ -1891,11 +1891,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
if (extend) {
/* hold shift inverts this bone's selection */
if (nearBone->flag & BONE_SELECTED)
- nearBone->flag &= ~(BONE_TIPSEL|BONE_ROOTSEL);
+ nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
else
- nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL);
+ nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
}
- else nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL);
+ else nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
}
}
else {
@@ -1910,11 +1910,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
if (nearBone) {
/* then now check for active status */
if (ebone_select_flag(nearBone)) {
- arm->act_edbone= nearBone;
+ arm->act_edbone = nearBone;
}
}
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit);
return 1;
}
@@ -1923,13 +1923,13 @@ int mouse_armature(bContext *C, const int mval[2], int extend)
void ED_armature_edit_free(struct Object *ob)
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
EditBone *eBone;
/* Clear the editbones list */
if (arm->edbo) {
if (arm->edbo->first) {
- for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
+ for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
if (eBone->prop) {
IDP_FreeProperty(eBone->prop);
MEM_freeN(eBone->prop);
@@ -1939,19 +1939,19 @@ void ED_armature_edit_free(struct Object *ob)
BLI_freelistN(arm->edbo);
}
MEM_freeN(arm->edbo);
- arm->edbo= NULL;
+ arm->edbo = NULL;
}
}
/* Put armature in EditMode */
void ED_armature_to_edit(Object *ob)
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
ED_armature_edit_free(ob);
- arm->edbo= MEM_callocN(sizeof(ListBase), "edbo armature");
- arm->act_edbone= make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone);
- arm->act_bone= NULL;
+ arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature");
+ arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone);
+ arm->act_bone = NULL;
// BIF_freeTemplates(); /* force template update when entering editmode */
}
@@ -1977,7 +1977,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short
sub_v3_v3v3(align_axis_proj, align_axis, vec);
if (axis_only) {
- if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) {
+ if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI / 2.0)) {
negate_v3(align_axis_proj);
}
}
@@ -2010,44 +2010,44 @@ static EnumPropertyItem prop_calc_roll_types[] = {
static int armature_calc_roll_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_edit_object(C);
- const short type= RNA_enum_get(op->ptr, "type");
- const short axis_only= RNA_boolean_get(op->ptr, "axis_only");
- const short axis_flip= RNA_boolean_get(op->ptr, "axis_flip");
+ Object *ob = CTX_data_edit_object(C);
+ const short type = RNA_enum_get(op->ptr, "type");
+ const short axis_only = RNA_boolean_get(op->ptr, "axis_only");
+ const short axis_flip = RNA_boolean_get(op->ptr, "axis_flip");
float imat[3][3];
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
EditBone *ebone;
copy_m3_m4(imat, ob->obmat);
invert_m3(imat);
- if (type==7) { /* Cursor */
- Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C); /* can be NULL */
+ if (type == 7) { /* Cursor */
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C); /* can be NULL */
float cursor_local[3];
- float *cursor= give_cursor(scene, v3d);
+ float *cursor = give_cursor(scene, v3d);
copy_v3_v3(cursor_local, cursor);
mul_m3_v3(imat, cursor_local);
/* cursor */
- for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
float cursor_rel[3];
sub_v3_v3v3(cursor_rel, cursor_local, ebone->head);
if (axis_flip) negate_v3(cursor_rel);
- ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only);
+ ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, axis_only);
}
}
}
else {
- float vec[3]= {0.0f, 0.0f, 0.0f};
- if (type==6) { /* View */
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
- if (rv3d==NULL) {
+ float vec[3] = {0.0f, 0.0f, 0.0f};
+ if (type == 6) { /* View */
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ if (rv3d == NULL) {
BKE_report(op->reports, RPT_ERROR, "No region view3d available");
return OPERATOR_CANCELLED;
}
@@ -2055,10 +2055,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
copy_v3_v3(vec, rv3d->viewinv[2]);
mul_m3_v3(imat, vec);
}
- else if (type==5) {
+ else if (type == 5) {
float mat[3][3], nor[3];
- ebone= (EditBone *)arm->act_edbone;
- if (ebone==NULL) {
+ ebone = (EditBone *)arm->act_edbone;
+ if (ebone == NULL) {
BKE_report(op->reports, RPT_ERROR, "No active bone set");
return OPERATOR_CANCELLED;
}
@@ -2069,34 +2069,34 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op)
}
else { /* Axis */
assert(type >= 0 && type <= 5);
- if (type<3) vec[type]= 1.0f;
- else vec[type-2]= -1.0f;
+ if (type < 3) vec[type] = 1.0f;
+ else vec[type - 2] = -1.0f;
mul_m3_v3(imat, vec);
}
if (axis_flip) negate_v3(vec);
- for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) {
/* roll func is a callback which assumes that all is well */
- ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only);
+ ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only);
}
}
}
if (arm->flag & ARM_MIRROR_EDIT) {
- for (ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) {
- EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone);
if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) {
- ebone->roll= -ebone_mirr->roll;
+ ebone->roll = -ebone_mirr->roll;
}
}
}
}
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
return OPERATOR_FINISHED;
}
@@ -2114,7 +2114,7 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", "");
@@ -2131,61 +2131,61 @@ typedef struct UndoArmature {
static void undoBones_to_editBones(void *uarmv, void *armv, void *UNUSED(data))
{
- UndoArmature *uarm= uarmv;
- bArmature *arm= armv;
+ UndoArmature *uarm = uarmv;
+ bArmature *arm = armv;
EditBone *ebo, *newebo;
BLI_freelistN(arm->edbo);
/* copy */
- for (ebo= uarm->lb.first; ebo; ebo= ebo->next) {
- newebo= MEM_dupallocN(ebo);
- ebo->temp= newebo;
+ for (ebo = uarm->lb.first; ebo; ebo = ebo->next) {
+ newebo = MEM_dupallocN(ebo);
+ ebo->temp = newebo;
BLI_addtail(arm->edbo, newebo);
}
/* active bone */
if (uarm->act_edbone) {
- ebo= uarm->act_edbone;
- arm->act_edbone= ebo->temp;
+ ebo = uarm->act_edbone;
+ arm->act_edbone = ebo->temp;
}
else
- arm->act_edbone= NULL;
+ arm->act_edbone = NULL;
/* set pointers */
- for (newebo= arm->edbo->first; newebo; newebo= newebo->next) {
- if (newebo->parent) newebo->parent= newebo->parent->temp;
+ for (newebo = arm->edbo->first; newebo; newebo = newebo->next) {
+ if (newebo->parent) newebo->parent = newebo->parent->temp;
}
/* be sure they don't hang ever */
- for (newebo= arm->edbo->first; newebo; newebo= newebo->next) {
- newebo->temp= NULL;
+ for (newebo = arm->edbo->first; newebo; newebo = newebo->next) {
+ newebo->temp = NULL;
}
}
static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata))
{
- bArmature *arm= armv;
+ bArmature *arm = armv;
UndoArmature *uarm;
EditBone *ebo, *newebo;
- uarm= MEM_callocN(sizeof(UndoArmature), "listbase undo");
+ uarm = MEM_callocN(sizeof(UndoArmature), "listbase undo");
/* copy */
- for (ebo= arm->edbo->first; ebo; ebo= ebo->next) {
- newebo= MEM_dupallocN(ebo);
- ebo->temp= newebo;
+ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
+ newebo = MEM_dupallocN(ebo);
+ ebo->temp = newebo;
BLI_addtail(&uarm->lb, newebo);
}
/* active bone */
if (arm->act_edbone) {
- ebo= arm->act_edbone;
- uarm->act_edbone= ebo->temp;
+ ebo = arm->act_edbone;
+ uarm->act_edbone = ebo->temp;
}
/* set pointers */
- for (newebo= uarm->lb.first; newebo; newebo= newebo->next) {
- if (newebo->parent) newebo->parent= newebo->parent->temp;
+ for (newebo = uarm->lb.first; newebo; newebo = newebo->next) {
+ if (newebo->parent) newebo->parent = newebo->parent->temp;
}
return uarm;
@@ -2193,7 +2193,7 @@ static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata))
static void free_undoBones(void *uarmv)
{
- UndoArmature *uarm= uarmv;
+ UndoArmature *uarm = uarmv;
BLI_freelistN(&uarm->lb);
MEM_freeN(uarm);
@@ -2201,8 +2201,8 @@ static void free_undoBones(void *uarmv)
static void *get_armature_edit(bContext *C)
{
- Object *obedit= CTX_data_edit_object(C);
- if (obedit && obedit->type==OB_ARMATURE) {
+ Object *obedit = CTX_data_edit_object(C);
+ if (obedit && obedit->type == OB_ARMATURE) {
return obedit->data;
}
return NULL;
@@ -2223,7 +2223,7 @@ void undo_push_armature(bContext *C, const char *name)
/* default bone add, returns it selected, but without tail set */
EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
{
- EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone");
+ EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone");
BLI_strncpy(bone->name, name, sizeof(bone->name));
unique_editbone_name(arm->edbo, bone->name, NULL);
@@ -2231,16 +2231,16 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
BLI_addtail(arm->edbo, bone);
bone->flag |= BONE_TIPSEL;
- bone->weight= 1.0f;
- bone->dist= 0.25f;
- bone->xwidth= 0.1f;
- bone->zwidth= 0.1f;
- bone->ease1= 1.0f;
- bone->ease2= 1.0f;
- bone->rad_head= 0.10f;
- bone->rad_tail= 0.05f;
- bone->segments= 1;
- bone->layer= arm->layer;
+ bone->weight = 1.0f;
+ bone->dist = 0.25f;
+ bone->xwidth = 0.1f;
+ bone->zwidth = 0.1f;
+ bone->ease1 = 1.0f;
+ bone->ease2 = 1.0f;
+ bone->rad_head = 0.10f;
+ bone->rad_tail = 0.05f;
+ bone->segments = 1;
+ bone->layer = arm->layer;
return bone;
}
@@ -2248,10 +2248,10 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name)
/* v3d and rv3d are allowed to be NULL */
void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
{
- Object *obedit= scene->obedit; // XXX get from context
- bArmature *arm= obedit->data;
- float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
- EditBone *bone;
+ Object *obedit = scene->obedit; // XXX get from context
+ bArmature *arm = obedit->data;
+ float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
+ EditBone *bone;
/* Get inverse point for head and orientation for tail */
invert_m4_m4(obedit->imat, obedit->obmat);
@@ -2268,16 +2268,16 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
ED_armature_deselect_all(obedit, 0);
/* Create a bone */
- bone= ED_armature_edit_bone_add(arm, "Bone");
+ bone = ED_armature_edit_bone_add(arm, "Bone");
- arm->act_edbone= bone;
+ arm->act_edbone = bone;
copy_v3_v3(bone->head, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
- add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
+ add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
else
- add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
+ add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
}
@@ -2290,25 +2290,25 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
bArmature *arm;
EditBone *ebone, *newbone, *flipbone;
float *curs, mat[3][3], imat[3][3];
- int a, to_root= 0;
+ int a, to_root = 0;
Object *obedit;
Scene *scene;
scene = CTX_data_scene(C);
- v3d= CTX_wm_view3d(C);
- obedit= CTX_data_edit_object(C);
- arm= obedit->data;
+ v3d = CTX_wm_view3d(C);
+ obedit = CTX_data_edit_object(C);
+ arm = obedit->data;
/* find the active or selected bone */
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone)
break;
}
}
- if (ebone==NULL) {
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ if (ebone == NULL) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone)
break;
@@ -2317,60 +2317,60 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
if (ebone == NULL)
return OPERATOR_CANCELLED;
- to_root= 1;
+ to_root = 1;
}
ED_armature_deselect_all(obedit, 0);
/* we re-use code for mirror editing... */
- flipbone= NULL;
+ flipbone = NULL;
if (arm->flag & ARM_MIRROR_EDIT)
- flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
- for (a=0; a<2; a++) {
- if (a==1) {
- if (flipbone==NULL)
+ for (a = 0; a < 2; a++) {
+ if (a == 1) {
+ if (flipbone == NULL)
break;
else {
SWAP(EditBone *, flipbone, ebone);
}
}
- newbone= ED_armature_edit_bone_add(arm, ebone->name);
- arm->act_edbone= newbone;
+ newbone = ED_armature_edit_bone_add(arm, ebone->name);
+ arm->act_edbone = newbone;
if (to_root) {
copy_v3_v3(newbone->head, ebone->head);
- newbone->rad_head= ebone->rad_tail;
- newbone->parent= ebone->parent;
+ newbone->rad_head = ebone->rad_tail;
+ newbone->parent = ebone->parent;
}
else {
copy_v3_v3(newbone->head, ebone->tail);
- newbone->rad_head= ebone->rad_tail;
- newbone->parent= ebone;
+ newbone->rad_head = ebone->rad_tail;
+ newbone->parent = ebone;
newbone->flag |= BONE_CONNECTED;
}
- curs= give_cursor(scene, v3d);
+ curs = give_cursor(scene, v3d);
copy_v3_v3(newbone->tail, curs);
sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]);
- if (a==1)
- newbone->tail[0]= -newbone->tail[0];
+ if (a == 1)
+ newbone->tail[0] = -newbone->tail[0];
copy_m3_m4(mat, obedit->obmat);
invert_m3_m3(imat, mat);
mul_m3_v3(imat, newbone->tail);
- newbone->length= len_v3v3(newbone->head, newbone->tail);
- newbone->rad_tail= newbone->length*0.05f;
- newbone->dist= newbone->length*0.25f;
+ newbone->length = len_v3v3(newbone->head, newbone->tail);
+ newbone->rad_tail = newbone->length * 0.05f;
+ newbone->dist = newbone->length * 0.25f;
}
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -2387,11 +2387,11 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
float *fp = NULL, tvec[3], oldcurs[3], mval_f[2];
int retv;
- scene= CTX_data_scene(C);
- ar= CTX_wm_region(C);
+ scene = CTX_data_scene(C);
+ ar = CTX_wm_region(C);
v3d = CTX_wm_view3d(C);
- fp= give_cursor(scene, v3d);
+ fp = give_cursor(scene, v3d);
copy_v3_v3(oldcurs, fp);
@@ -2400,7 +2400,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e
copy_v3_v3(fp, tvec);
/* extrude to the where new cursor is and store the operation result */
- retv= armature_click_extrude_exec(C, op);
+ retv = armature_click_extrude_exec(C, op);
/* restore previous 3d cursor position */
copy_v3_v3(fp, oldcurs);
@@ -2421,17 +2421,17 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
}
/* adds an EditBone between the nominated locations (should be in the right space) */
-static EditBone *add_points_bone (Object *obedit, float head[], float tail[])
+static EditBone *add_points_bone(Object *obedit, float head[], float tail[])
{
EditBone *ebo;
- ebo= ED_armature_edit_bone_add(obedit->data, "Bone");
+ ebo = ED_armature_edit_bone_add(obedit->data, "Bone");
copy_v3_v3(ebo->head, head);
copy_v3_v3(ebo->tail, tail);
@@ -2445,7 +2445,7 @@ static EditBone *get_named_editbone(ListBase *edbo, char *name)
EditBone *eBone;
if (name) {
- for (eBone=edbo->first; eBone; eBone=eBone->next) {
+ for (eBone = edbo->first; eBone; eBone = eBone->next) {
if (!strcmp(name, eBone->name))
return eBone;
}
@@ -2481,20 +2481,20 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj
bConstraint *curcon;
ListBase *conlist;
- if ( (pchan = verify_pose_channel(dst_ob->pose, dupBone->name)) ) {
+ if ( (pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name)) ) {
if ( (conlist = &pchan->constraints) ) {
- for (curcon = conlist->first; curcon; curcon=curcon->next) {
+ for (curcon = conlist->first; curcon; curcon = curcon->next) {
/* does this constraint have a subtarget in
* this armature?
*/
- bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon);
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon);
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(curcon, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if ((ct->tar == src_ob) && (ct->subtarget[0])) {
ct->tar = dst_ob; /* update target */
oldtarget = get_named_editbone(editbones, ct->subtarget);
@@ -2544,7 +2544,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
/* copy the ID property */
if (curBone->prop)
- eBone->prop= IDP_CopyProperty(curBone->prop);
+ eBone->prop = IDP_CopyProperty(curBone->prop);
/* Lets duplicate the list of constraints that the
* current bone has.
@@ -2552,15 +2552,15 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase
if (src_ob->pose) {
bPoseChannel *chanold, *channew;
- chanold = verify_pose_channel(src_ob->pose, curBone->name);
+ chanold = BKE_pose_channel_verify(src_ob->pose, curBone->name);
if (chanold) {
/* WARNING: this creates a new posechannel, but there will not be an attached bone
* yet as the new bones created here are still 'EditBones' not 'Bones'.
*/
- channew= verify_pose_channel(dst_ob->pose, eBone->name);
+ channew = BKE_pose_channel_verify(dst_ob->pose, eBone->name);
if (channew) {
- duplicate_pose_channel_data(channew, chanold);
+ BKE_pose_channel_copy_data(channew, chanold);
}
}
}
@@ -2577,12 +2577,12 @@ EditBone *duplicateEditBone(EditBone *curBone, const char *name, ListBase *editb
static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
bArmature *arm;
- EditBone *eBone = NULL;
- EditBone *curBone;
- EditBone *firstDup=NULL; /* The beginning of the duplicated bones in the edbo list */
+ EditBone *eBone = NULL;
+ EditBone *curBone;
+ EditBone *firstDup = NULL; /* The beginning of the duplicated bones in the edbo list */
- Object *obedit= CTX_data_edit_object(C);
- arm= obedit->data;
+ Object *obedit = CTX_data_edit_object(C);
+ arm = obedit->data;
/* cancel if nothing selected */
if (CTX_DATA_COUNT(C, selected_bones) == 0)
@@ -2594,7 +2594,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
/* Select mirrored bones */
if (arm->flag & ARM_MIRROR_EDIT) {
- for (curBone=arm->edbo->first; curBone; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone; curBone = curBone->next) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
eBone = ED_armature_bone_get_mirrored(arm->edbo, curBone);
@@ -2607,24 +2607,24 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
/* Find the selected bones and duplicate them as needed */
- for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
- eBone= duplicateEditBone(curBone, curBone->name, arm->edbo, obedit);
+ eBone = duplicateEditBone(curBone, curBone->name, arm->edbo, obedit);
if (!firstDup)
- firstDup=eBone;
+ firstDup = eBone;
}
}
}
/* Run though the list and fix the pointers */
- for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) {
if (EBONE_VISIBLE(arm, curBone)) {
if (curBone->flag & BONE_SELECTED) {
- eBone=(EditBone*) curBone->temp;
+ eBone = (EditBone *) curBone->temp;
if (!curBone->parent) {
/* If this bone has no parent,
@@ -2636,13 +2636,13 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
/* If this bone has a parent that was duplicated,
* Set the duplicate->parent to the curBone->parent->temp
*/
- eBone->parent= (EditBone *)curBone->parent->temp;
+ eBone->parent = (EditBone *)curBone->parent->temp;
}
else {
/* If this bone has a parent that IS not selected,
* Set the duplicate->parent to the curBone->parent
*/
- eBone->parent=(EditBone*) curBone->parent;
+ eBone->parent = (EditBone *) curBone->parent;
eBone->flag &= ~BONE_CONNECTED;
}
@@ -2656,20 +2656,20 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op))
/* correct the active bone */
if (arm->act_edbone) {
- eBone= arm->act_edbone;
+ eBone = arm->act_edbone;
if (eBone->temp)
- arm->act_edbone= eBone->temp;
+ arm->act_edbone = eBone->temp;
}
/* Deselect the old bones and select the new ones */
- for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) {
+ for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) {
if (EBONE_VISIBLE(arm, curBone))
curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
ED_armature_validate_active(arm);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -2687,7 +2687,7 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2698,27 +2698,27 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot)
typedef struct EditBonePoint {
struct EditBonePoint *next, *prev;
- EditBone *head_owner; /* EditBone which uses this point as a 'head' point */
- EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */
+ EditBone *head_owner; /* EditBone which uses this point as a 'head' point */
+ EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */
- float vec[3]; /* the actual location of the point in local/EditMode space */
+ float vec[3]; /* the actual location of the point in local/EditMode space */
} EditBonePoint;
/* find chain-tips (i.e. bones without children) */
-static void chains_find_tips (ListBase *edbo, ListBase *list)
+static void chains_find_tips(ListBase *edbo, ListBase *list)
{
EditBone *curBone, *ebo;
LinkData *ld;
/* note: this is potentially very slow ... there's got to be a better way */
- for (curBone= edbo->first; curBone; curBone= curBone->next) {
- short stop= 0;
+ for (curBone = edbo->first; curBone; curBone = curBone->next) {
+ short stop = 0;
/* is this bone contained within any existing chain? (skip if so) */
- for (ld= list->first; ld; ld= ld->next) {
- for (ebo= ld->data; ebo; ebo= ebo->parent) {
+ for (ld = list->first; ld; ld = ld->next) {
+ for (ebo = ld->data; ebo; ebo = ebo->parent) {
if (ebo == curBone) {
- stop= 1;
+ stop = 1;
break;
}
}
@@ -2729,12 +2729,12 @@ static void chains_find_tips (ListBase *edbo, ListBase *list)
if (stop) continue;
/* is any existing chain part of the chain formed by this bone? */
- stop= 0;
- for (ebo= curBone->parent; ebo; ebo= ebo->parent) {
- for (ld= list->first; ld; ld= ld->next) {
+ stop = 0;
+ for (ebo = curBone->parent; ebo; ebo = ebo->parent) {
+ for (ld = list->first; ld; ld = ld->next) {
if (ld->data == ebo) {
- ld->data= curBone;
- stop= 1;
+ ld->data = curBone;
+ stop = 1;
break;
}
}
@@ -2745,19 +2745,19 @@ static void chains_find_tips (ListBase *edbo, ListBase *list)
if (stop) continue;
/* add current bone to a new chain */
- ld= MEM_callocN(sizeof(LinkData), "BoneChain");
- ld->data= curBone;
+ ld = MEM_callocN(sizeof(LinkData), "BoneChain");
+ ld->data = curBone;
BLI_addtail(list, ld);
}
}
/* --------------------- */
-static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
+static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points)
{
EditBonePoint *ebp;
float vec[3];
- short found= 0;
+ short found = 0;
if (eb_tail) {
copy_v3_v3(vec, ebo->tail);
@@ -2766,20 +2766,20 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
copy_v3_v3(vec, ebo->head);
}
- for (ebp= points->first; ebp; ebp= ebp->next) {
+ for (ebp = points->first; ebp; ebp = ebp->next) {
if (equals_v3v3(ebp->vec, vec)) {
if (eb_tail) {
if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) {
/* so this bone's tail owner is this bone */
- ebp->tail_owner= ebo;
- found= 1;
+ ebp->tail_owner = ebo;
+ found = 1;
break;
}
}
else {
if ((ebp->tail_owner) && (ebo->parent == ebp->tail_owner)) {
/* so this bone's head owner is this bone */
- ebp->head_owner= ebo;
+ ebp->head_owner = ebo;
found = 1;
break;
}
@@ -2789,15 +2789,15 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
/* allocate a new point if no existing point was related */
if (found == 0) {
- ebp= MEM_callocN(sizeof(EditBonePoint), "EditBonePoint");
+ ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint");
if (eb_tail) {
copy_v3_v3(ebp->vec, ebo->tail);
- ebp->tail_owner= ebo;
+ ebp->tail_owner = ebo;
}
else {
copy_v3_v3(ebp->vec, ebo->head);
- ebp->head_owner= ebo;
+ ebp->head_owner = ebo;
}
BLI_addtail(points, ebp);
@@ -2805,12 +2805,12 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points)
}
/* bone adding between selected joints */
-static int armature_fill_bones_exec (bContext *C, wmOperator *op)
+static int armature_fill_bones_exec(bContext *C, wmOperator *op)
{
- Object *obedit= CTX_data_edit_object(C);
- bArmature *arm= (obedit) ? obedit->data : NULL;
- Scene *scene= CTX_data_scene(C);
- View3D *v3d= CTX_wm_view3d(C);
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = (obedit) ? obedit->data : NULL;
+ Scene *scene = CTX_data_scene(C);
+ View3D *v3d = CTX_wm_view3d(C);
ListBase points = {NULL, NULL};
int count;
@@ -2829,11 +2829,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
CTX_DATA_END;
/* the number of joints determines how we fill:
- * 1) between joint and cursor (joint=head, cursor=tail)
- * 2) between the two joints (order is dependent on active-bone/hierachy)
- * 3+) error (a smarter method involving finding chains needs to be worked out
+ * 1) between joint and cursor (joint=head, cursor=tail)
+ * 2) between the two joints (order is dependent on active-bone/hierachy)
+ * 3+) error (a smarter method involving finding chains needs to be worked out
*/
- count= BLI_countlist(&points);
+ count = BLI_countlist(&points);
if (count == 0) {
BKE_report(op->reports, RPT_ERROR, "No joints selected");
@@ -2844,7 +2844,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
float curs[3];
/* Get Points - selected joint */
- ebp= (EditBonePoint *)points.first;
+ ebp = (EditBonePoint *)points.first;
/* Get points - cursor (tail) */
invert_m4_m4(obedit->imat, obedit->obmat);
@@ -2859,15 +2859,15 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
short headtail = 0;
/* check that the points don't belong to the same bone */
- ebp= (EditBonePoint *)points.first;
- ebp2= ebp->next;
+ ebp = (EditBonePoint *)points.first;
+ ebp2 = ebp->next;
- if ((ebp->head_owner==ebp2->tail_owner) && (ebp->head_owner!=NULL)) {
+ if ((ebp->head_owner == ebp2->tail_owner) && (ebp->head_owner != NULL)) {
BKE_report(op->reports, RPT_ERROR, "Same bone selected...");
BLI_freelistN(&points);
return OPERATOR_CANCELLED;
}
- if ((ebp->tail_owner==ebp2->head_owner) && (ebp->tail_owner!=NULL)) {
+ if ((ebp->tail_owner == ebp2->head_owner) && (ebp->tail_owner != NULL)) {
BKE_report(op->reports, RPT_ERROR, "Same bone selected...");
BLI_freelistN(&points);
return OPERATOR_CANCELLED;
@@ -2887,11 +2887,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
/* get distances */
sub_v3_v3v3(vecA, ebp->vec, curs);
sub_v3_v3v3(vecB, ebp2->vec, curs);
- distA= len_v3(vecA);
- distB= len_v3(vecB);
+ distA = len_v3(vecA);
+ distB = len_v3(vecB);
/* compare distances - closer one therefore acts as direction for bone to go */
- headtail= (distA < distB) ? 2 : 1;
+ headtail = (distA < distB) ? 2 : 1;
}
else if (ebp->head_owner) {
headtail = 1;
@@ -2912,22 +2912,22 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
/* add new bone and parent it to the appropriate end */
if (headtail) {
- EditBone *newbone= add_points_bone(obedit, head, tail);
+ EditBone *newbone = add_points_bone(obedit, head, tail);
/* do parenting (will need to set connected flag too) */
if (headtail == 2) {
/* ebp tail or head - tail gets priority */
if (ebp->tail_owner)
- newbone->parent= ebp->tail_owner;
+ newbone->parent = ebp->tail_owner;
else
- newbone->parent= ebp->head_owner;
+ newbone->parent = ebp->head_owner;
}
else {
/* ebp2 tail or head - tail gets priority */
if (ebp2->tail_owner)
- newbone->parent= ebp2->tail_owner;
+ newbone->parent = ebp2->tail_owner;
else
- newbone->parent= ebp2->head_owner;
+ newbone->parent = ebp2->head_owner;
}
newbone->flag |= BONE_CONNECTED;
@@ -2941,7 +2941,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op)
}
/* updates */
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
/* free points */
BLI_freelistN(&points);
@@ -2961,7 +2961,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* --------------------- */
@@ -2971,7 +2971,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot)
*/
static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone *endchild, ListBase *chains)
{
- bArmature *arm= obedit->data;
+ bArmature *arm = obedit->data;
EditBone *ebo, *ebone, *newbone;
LinkData *chain;
float head[3], tail[3];
@@ -2989,23 +2989,23 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
* - tail = head/tail of end (default tail)
* - parent = parent of start
*/
- if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED)==0) {
+ if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED) == 0) {
copy_v3_v3(head, start->tail);
}
else {
copy_v3_v3(head, start->head);
}
- if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED)==0) {
+ if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED) == 0) {
copy_v3_v3(tail, end->head);
}
else {
copy_v3_v3(tail, end->tail);
}
- newbone= add_points_bone(obedit, head, tail);
+ newbone = add_points_bone(obedit, head, tail);
newbone->parent = start->parent;
/* TODO, copy more things to the new bone */
- newbone->flag= start->flag & (BONE_HINGE|BONE_NO_DEFORM|BONE_NO_SCALE|BONE_NO_CYCLICOFFSET|BONE_NO_LOCAL_LOCATION|BONE_DONE);
+ newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE);
/* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge
* - potentially several tips for side chains leading to some tree exist...
@@ -3037,24 +3037,24 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
/* step 2b: parent child of end to newbone (child from this chain) */
if (endchild)
- endchild->parent= newbone;
+ endchild->parent = newbone;
/* step 3: delete all bones between and including start and end */
- for (ebo= end; ebo; ebo= ebone) {
- ebone= (ebo == start) ? (NULL) : (ebo->parent);
+ for (ebo = end; ebo; ebo = ebone) {
+ ebone = (ebo == start) ? (NULL) : (ebo->parent);
bone_free(arm, ebo);
}
- newbone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
+ newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
ED_armature_sync_selection(arm->edbo);
}
-static int armature_merge_exec (bContext *C, wmOperator *op)
+static int armature_merge_exec(bContext *C, wmOperator *op)
{
- Object *obedit= CTX_data_edit_object(C);
- bArmature *arm= (obedit) ? obedit->data : NULL;
- short type= RNA_enum_get(op->ptr, "type");
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = (obedit) ? obedit->data : NULL;
+ short type = RNA_enum_get(op->ptr, "type");
/* sanity checks */
if (ELEM(NULL, obedit, arm))
@@ -3074,28 +3074,28 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
if (chains.first == NULL) return OPERATOR_CANCELLED;
/* each 'chain' is the last bone in the chain (with no children) */
- for (chain= chains.first; chain; chain= nchain) {
- EditBone *bstart= NULL, *bend= NULL;
- EditBone *bchild= NULL, *child=NULL;
+ for (chain = chains.first; chain; chain = nchain) {
+ EditBone *bstart = NULL, *bend = NULL;
+ EditBone *bchild = NULL, *child = NULL;
/* temporarily remove chain from list of chains */
- nchain= chain->next;
+ nchain = chain->next;
BLI_remlink(&chains, chain);
/* only consider bones that are visible and selected */
- for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) {
+ for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) {
/* check if visible + selected */
- if ( EBONE_VISIBLE(arm, ebo) &&
- ((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) &&
- (ebo->flag & BONE_SELECTED) )
+ if (EBONE_VISIBLE(arm, ebo) &&
+ ((ebo->flag & BONE_CONNECTED) || (ebo->parent == NULL)) &&
+ (ebo->flag & BONE_SELECTED) )
{
/* set either end or start (end gets priority, unless it is already set) */
if (bend == NULL) {
- bend= ebo;
- bchild= child;
+ bend = ebo;
+ bchild = child;
}
else
- bstart= ebo;
+ bstart = ebo;
}
else {
/* chain is broken... merge any continous segments then clear */
@@ -3123,7 +3123,7 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
/* updates */
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit);
return OPERATOR_FINISHED;
}
@@ -3146,7 +3146,7 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", "");
@@ -3157,19 +3157,19 @@ void ARMATURE_OT_merge(wmOperatorType *ot)
static int armature_hide_exec(bContext *C, wmOperator *op)
{
- Object *obedit= CTX_data_edit_object(C);
- bArmature *arm= obedit->data;
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = obedit->data;
EditBone *ebone;
- const int invert= RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0;
+ const int invert = RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0;
/* cancel if nothing selected */
if (CTX_DATA_COUNT(C, selected_bones) == 0)
return OPERATOR_CANCELLED;
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
if ((ebone->flag & BONE_SELECTED) != invert) {
- ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
+ ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
ebone->flag |= BONE_HIDDEN_A;
}
}
@@ -3177,7 +3177,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op)
ED_armature_validate_active(arm);
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -3194,7 +3194,7 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected");
@@ -3202,14 +3202,14 @@ void ARMATURE_OT_hide(wmOperatorType *ot)
static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *obedit= CTX_data_edit_object(C);
- bArmature *arm= obedit->data;
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = obedit->data;
EditBone *ebone;
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_HIDDEN_A) {
- ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
+ ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
ebone->flag &= ~BONE_HIDDEN_A;
}
}
@@ -3217,7 +3217,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op))
ED_armature_validate_active(arm);
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -3234,20 +3234,20 @@ void ARMATURE_OT_reveal(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
#if 0 // remove this?
static void hide_selected_armature_bones(Scene *scene)
{
- Object *obedit= scene->obedit; // XXX get from context
- bArmature *arm= obedit->data;
+ Object *obedit = scene->obedit; // XXX get from context
+ bArmature *arm = obedit->data;
EditBone *ebone;
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_SELECTED) {
- ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
+ ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
ebone->flag |= BONE_HIDDEN_A;
}
}
@@ -3258,14 +3258,14 @@ static void hide_selected_armature_bones(Scene *scene)
static void hide_unselected_armature_bones(Scene *scene)
{
- Object *obedit= scene->obedit; // XXX get from context
- bArmature *arm= obedit->data;
+ Object *obedit = scene->obedit; // XXX get from context
+ bArmature *arm = obedit->data;
EditBone *ebone;
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
- bArmature *arm= obedit->data;
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+ bArmature *arm = obedit->data;
if (EBONE_VISIBLE(arm, ebone)) {
- if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL));
+ if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) ;
else {
ebone->flag |= BONE_HIDDEN_A;
}
@@ -3278,14 +3278,14 @@ static void hide_unselected_armature_bones(Scene *scene)
void show_all_armature_bones(Scene *scene)
{
- Object *obedit= scene->obedit; // XXX get from context
- bArmature *arm= obedit->data;
+ Object *obedit = scene->obedit; // XXX get from context
+ bArmature *arm = obedit->data;
EditBone *ebone;
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_HIDDEN_A) {
- ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
+ ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
ebone->flag &= ~BONE_HIDDEN_A;
}
}
@@ -3302,15 +3302,15 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
{
Object *obedit;
bArmature *arm;
- EditBone *newbone, *ebone, *flipbone, *first=NULL;
- int a, totbone= 0, do_extrude;
+ EditBone *newbone, *ebone, *flipbone, *first = NULL;
+ int a, totbone = 0, do_extrude;
int forked = RNA_boolean_get(op->ptr, "forked");
- obedit= CTX_data_edit_object(C);
- arm= obedit->data;
+ obedit = CTX_data_edit_object(C);
+ arm = obedit->data;
/* since we allow root extrude too, we have to make sure selection is OK */
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
if (ebone->flag & BONE_ROOTSEL) {
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
@@ -3322,36 +3322,36 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
}
/* Duplicate the necessary bones */
- for (ebone = arm->edbo->first; ((ebone) && (ebone!=first)); ebone=ebone->next) {
+ for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone)) {
/* we extrude per definition the tip */
- do_extrude= 0;
- if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED))
- do_extrude= 1;
+ do_extrude = 0;
+ if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED))
+ do_extrude = 1;
else if (ebone->flag & BONE_ROOTSEL) {
/* but, a bone with parent deselected we do the root... */
- if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL));
- else do_extrude= 2;
+ if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) ;
+ else do_extrude = 2;
}
if (do_extrude) {
/* we re-use code for mirror editing... */
- flipbone= NULL;
+ flipbone = NULL;
if (arm->flag & ARM_MIRROR_EDIT) {
- flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone);
+ flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone);
if (flipbone) {
- forked= 0; // we extrude 2 different bones
- if (flipbone->flag & (BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED))
+ forked = 0; // we extrude 2 different bones
+ if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED))
/* don't want this bone to be selected... */
- flipbone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
+ flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
}
- if ((flipbone==NULL) && (forked))
- flipbone= ebone;
+ if ((flipbone == NULL) && (forked))
+ flipbone = ebone;
}
- for (a=0; a<2; a++) {
- if (a==1) {
- if (flipbone==NULL)
+ for (a = 0; a < 2; a++) {
+ if (a == 1) {
+ if (flipbone == NULL)
break;
else {
SWAP(EditBone *, flipbone, ebone);
@@ -3361,43 +3361,43 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
totbone++;
newbone = MEM_callocN(sizeof(EditBone), "extrudebone");
- if (do_extrude==1) {
+ if (do_extrude == 1) {
copy_v3_v3(newbone->head, ebone->tail);
copy_v3_v3(newbone->tail, newbone->head);
newbone->parent = ebone;
- newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone
+ newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone
if (newbone->parent) newbone->flag |= BONE_CONNECTED;
}
else {
copy_v3_v3(newbone->head, ebone->head);
copy_v3_v3(newbone->tail, ebone->head);
- newbone->parent= ebone->parent;
+ newbone->parent = ebone->parent;
- newbone->flag= BONE_TIPSEL;
+ newbone->flag = BONE_TIPSEL;
if (newbone->parent && (ebone->flag & BONE_CONNECTED)) {
newbone->flag |= BONE_CONNECTED;
}
}
- newbone->weight= ebone->weight;
- newbone->dist= ebone->dist;
- newbone->xwidth= ebone->xwidth;
- newbone->zwidth= ebone->zwidth;
- newbone->ease1= ebone->ease1;
- newbone->ease2= ebone->ease2;
- newbone->rad_head= ebone->rad_tail; // don't copy entire bone...
- newbone->rad_tail= ebone->rad_tail;
- newbone->segments= 1;
- newbone->layer= ebone->layer;
-
- BLI_strncpy (newbone->name, ebone->name, sizeof(newbone->name));
-
- if (flipbone && forked) { // only set if mirror edit
- if (strlen(newbone->name)<30) {
- if (a==0) strcat(newbone->name, "_L");
+ newbone->weight = ebone->weight;
+ newbone->dist = ebone->dist;
+ newbone->xwidth = ebone->xwidth;
+ newbone->zwidth = ebone->zwidth;
+ newbone->ease1 = ebone->ease1;
+ newbone->ease2 = ebone->ease2;
+ newbone->rad_head = ebone->rad_tail; // don't copy entire bone...
+ newbone->rad_tail = ebone->rad_tail;
+ newbone->segments = 1;
+ newbone->layer = ebone->layer;
+
+ BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name));
+
+ if (flipbone && forked) { // only set if mirror edit
+ if (strlen(newbone->name) < 30) {
+ if (a == 0) strcat(newbone->name, "_L");
else strcat(newbone->name, "_R");
}
}
@@ -3409,24 +3409,24 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
first = newbone;
/* restore ebone if we were flipping */
- if (a==1 && flipbone)
+ if (a == 1 && flipbone)
SWAP(EditBone *, flipbone, ebone);
}
}
/* Deselect the old bone */
- ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL);
+ ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL);
}
}
/* if only one bone, make this one active */
- if (totbone==1 && first) arm->act_edbone= first;
+ if (totbone == 1 && first) arm->act_edbone = first;
- if (totbone==0) return OPERATOR_CANCELLED;
+ if (totbone == 0) return OPERATOR_CANCELLED;
/* Transform the endpoints */
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -3443,7 +3443,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_boolean(ot->srna, "forked", 0, "Forked", "");
@@ -3454,7 +3454,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot)
static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
{
- RegionView3D *rv3d= CTX_wm_region_view3d(C);
+ RegionView3D *rv3d = CTX_wm_region_view3d(C);
Object *obedit = CTX_data_edit_object(C);
EditBone *bone;
float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3];
@@ -3479,17 +3479,17 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
ED_armature_deselect_all(obedit, 0);
/* Create a bone */
- bone= ED_armature_edit_bone_add(obedit->data, name);
+ bone = ED_armature_edit_bone_add(obedit->data, name);
copy_v3_v3(bone->head, curs);
if (rv3d && (U.flag & USER_ADD_VIEWALIGNED))
- add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
+ add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1
else
- add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
+ add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -3506,7 +3506,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone");
@@ -3523,28 +3523,28 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
static int armature_subdivide_exec(bContext *C, wmOperator *op)
{
- Object *obedit= CTX_data_edit_object(C);
- bArmature *arm= obedit->data;
+ Object *obedit = CTX_data_edit_object(C);
+ bArmature *arm = obedit->data;
EditBone *newbone, *tbone;
int numcuts, i;
/* there may not be a number_cuts property defined (for 'simple' subdivide) */
- numcuts= RNA_int_get(op->ptr, "number_cuts");
+ numcuts = RNA_int_get(op->ptr, "number_cuts");
/* loop over all editable bones */
// XXX the old code did this in reverse order though!
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
{
- for (i=numcuts+1; i>1; i--) {
+ for (i = numcuts + 1; i > 1; i--) {
/* compute cut ratio first */
- float cutratio= 1.0f / (float)i;
- float cutratioI= 1.0f - cutratio;
+ float cutratio = 1.0f / (float)i;
+ float cutratioI = 1.0f - cutratio;
float val1[3];
float val2[3];
float val3[3];
- newbone= MEM_mallocN(sizeof(EditBone), "ebone subdiv");
+ newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv");
*newbone = *ebone;
BLI_addtail(arm->edbo, newbone);
@@ -3553,33 +3553,33 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op)
copy_v3_v3(val2, ebone->tail);
copy_v3_v3(val3, newbone->head);
- val3[0]= val1[0]*cutratio + val2[0]*cutratioI;
- val3[1]= val1[1]*cutratio + val2[1]*cutratioI;
- val3[2]= val1[2]*cutratio + val2[2]*cutratioI;
+ val3[0] = val1[0] * cutratio + val2[0] * cutratioI;
+ val3[1] = val1[1] * cutratio + val2[1] * cutratioI;
+ val3[2] = val1[2] * cutratio + val2[2] * cutratioI;
copy_v3_v3(newbone->head, val3);
copy_v3_v3(newbone->tail, ebone->tail);
copy_v3_v3(ebone->tail, newbone->head);
- newbone->rad_head= 0.5f * (ebone->rad_head + ebone->rad_tail);
- ebone->rad_tail= newbone->rad_head;
+ newbone->rad_head = 0.5f * (ebone->rad_head + ebone->rad_tail);
+ ebone->rad_tail = newbone->rad_head;
newbone->flag |= BONE_CONNECTED;
unique_editbone_name(arm->edbo, newbone->name, NULL);
/* correct parent bones */
- for (tbone = arm->edbo->first; tbone; tbone=tbone->next) {
- if (tbone->parent==ebone)
- tbone->parent= newbone;
+ for (tbone = arm->edbo->first; tbone; tbone = tbone->next) {
+ if (tbone->parent == ebone)
+ tbone->parent = newbone;
}
- newbone->parent= ebone;
+ newbone->parent = ebone;
}
}
CTX_DATA_END;
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -3598,7 +3598,7 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* Properties */
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10);
@@ -3616,8 +3616,8 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot)
static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= CTX_data_edit_object(C);
- bArmature *arm= (bArmature *)ob->data;
+ Object *ob = CTX_data_edit_object(C);
+ bArmature *arm = (bArmature *)ob->data;
ListBase chains = {NULL, NULL};
LinkData *chain;
@@ -3628,16 +3628,16 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
armature_tag_select_mirrored(arm);
/* loop over chains, only considering selected and visible bones */
- for (chain= chains.first; chain; chain= chain->next) {
- EditBone *ebo, *child=NULL, *parent=NULL;
+ for (chain = chains.first; chain; chain = chain->next) {
+ EditBone *ebo, *child = NULL, *parent = NULL;
/* loop over bones in chain */
- for (ebo= chain->data; ebo; ebo= parent) {
+ for (ebo = chain->data; ebo; ebo = parent) {
/* parent is this bone's original parent
* - we store this, as the next bone that is checked is this one
* but the value of ebo->parent may change here...
*/
- parent= ebo->parent;
+ parent = ebo->parent;
/* only if selected and editable */
if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) {
@@ -3650,7 +3650,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
* - use 'child' as new parent
* - connected flag is only set if points are coincidental
*/
- ebo->parent= child;
+ ebo->parent = child;
if ((child) && equals_v3v3(ebo->head, child->tail))
ebo->flag |= BONE_CONNECTED;
else
@@ -3659,14 +3659,14 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
/* get next bones
* - child will become the new parent of next bone
*/
- child= ebo;
+ child = ebo;
}
else {
/* not swapping this bone, however, if its 'parent' got swapped, unparent us from it
* as it will be facing in opposite direction
*/
if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) {
- ebo->parent= NULL;
+ ebo->parent = NULL;
ebo->flag &= ~BONE_CONNECTED;
}
@@ -3674,7 +3674,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
* - child will become new parent of next bone (not swapping occurred,
* so set to NULL to prevent infinite-loop)
*/
- child= NULL;
+ child = NULL;
}
}
}
@@ -3685,7 +3685,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op))
armature_tag_unselect(arm);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
@@ -3702,13 +3702,13 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ***************** Parenting *********************** */
/* armature parenting options */
#define ARM_PAR_CONNECT 1
-#define ARM_PAR_OFFSET 2
+#define ARM_PAR_OFFSET 2
/* check for null, before calling! */
static void bone_connect_to_existing_parent(EditBone *bone)
@@ -3727,12 +3727,12 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
selbone->parent->flag &= ~(BONE_TIPSEL);
/* make actbone the parent of selbone */
- selbone->parent= actbone;
+ selbone->parent = actbone;
/* in actbone tree we cannot have a loop */
- for (ebone= actbone->parent; ebone; ebone= ebone->parent) {
- if (ebone->parent==selbone) {
- ebone->parent= NULL;
+ for (ebone = actbone->parent; ebone; ebone = ebone->parent) {
+ if (ebone->parent == selbone) {
+ ebone->parent = NULL;
ebone->flag &= ~BONE_CONNECTED;
}
}
@@ -3743,16 +3743,16 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo
sub_v3_v3v3(offset, actbone->tail, selbone->head);
copy_v3_v3(selbone->head, actbone->tail);
- selbone->rad_head= actbone->rad_tail;
+ selbone->rad_head = actbone->rad_tail;
add_v3_v3(selbone->tail, offset);
/* offset for all its children */
- for (ebone = edbo->first; ebone; ebone=ebone->next) {
+ for (ebone = edbo->first; ebone; ebone = ebone->next) {
EditBone *par;
- for (par= ebone->parent; par; par= par->parent) {
- if (par==selbone) {
+ for (par = ebone->parent; par; par = par->parent) {
+ if (par == selbone) {
add_v3_v3(ebone->head, offset);
add_v3_v3(ebone->tail, offset);
break;
@@ -3774,8 +3774,8 @@ static EnumPropertyItem prop_editarm_make_parent_types[] = {
static int armature_parent_set_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_edit_object(C);
- bArmature *arm= (bArmature *)ob->data;
+ Object *ob = CTX_data_edit_object(C);
+ bArmature *arm = (bArmature *)ob->data;
EditBone *actbone = CTX_data_active_bone(C);
EditBone *actmirb = NULL;
short val = RNA_enum_get(op->ptr, "type");
@@ -3793,9 +3793,9 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
- actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone);
+ actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone);
if (actmirb == NULL)
- actmirb= actbone;
+ actmirb = actbone;
}
/* if there is only 1 selected bone, we assume that that is the active bone,
@@ -3817,7 +3817,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
* - the context iterator contains both selected bones and their mirrored copies,
* so we assume that unselected bones are mirrored copies of some selected bone
* - since the active one (and/or its mirror) will also be selected, we also need
- * to check that we are not trying to operate on them, since such an operation
+ * to check that we are not trying to operate on them, since such an operation
* would cause errors
*/
@@ -3836,7 +3836,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
@@ -3844,14 +3844,14 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op)
static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event))
{
EditBone *actbone = CTX_data_active_bone(C);
- uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", ICON_NONE);
- uiLayout *layout= uiPupMenuLayout(pup);
+ uiPopupMenu *pup = uiPupMenuBegin(C, "Make Parent ", ICON_NONE);
+ uiLayout *layout = uiPupMenuLayout(pup);
int allchildbones = 0;
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
{
if (ebone != actbone) {
- if (ebone->parent != actbone) allchildbones= 1;
+ if (ebone->parent != actbone) allchildbones = 1;
}
}
CTX_DATA_END;
@@ -3880,7 +3880,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", prop_editarm_make_parent_types, 0, "ParentType", "Type of parenting");
}
@@ -3898,14 +3898,14 @@ static void editbone_clear_parent(EditBone *ebone, int mode)
ebone->parent->flag &= ~(BONE_TIPSEL);
}
- if (mode==1) ebone->parent= NULL;
+ if (mode == 1) ebone->parent = NULL;
ebone->flag &= ~BONE_CONNECTED;
}
static int armature_parent_clear_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_edit_object(C);
- bArmature *arm= (bArmature *)ob->data;
+ Object *ob = CTX_data_edit_object(C);
+ bArmature *arm = (bArmature *)ob->data;
int val = RNA_enum_get(op->ptr, "type");
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
@@ -3917,7 +3917,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op)
ED_armature_sync_selection(arm->edbo);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
@@ -3935,7 +3935,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting");
}
@@ -3955,7 +3955,7 @@ static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op))
}
CTX_DATA_END;
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -3972,7 +3972,7 @@ void ARMATURE_OT_select_inverse(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int armature_de_select_all_exec(bContext *C, wmOperator *op)
@@ -3993,30 +3993,30 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op)
/* ignore bone if selection can't change */
if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
switch (action) {
- case SEL_SELECT:
- ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- if (ebone->parent)
- ebone->parent->flag |= (BONE_TIPSEL);
- break;
- case SEL_DESELECT:
- ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- break;
- case SEL_INVERT:
- if (ebone->flag & BONE_SELECTED) {
- ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- }
- else {
+ case SEL_SELECT:
ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
if (ebone->parent)
ebone->parent->flag |= (BONE_TIPSEL);
- }
- break;
+ break;
+ case SEL_DESELECT:
+ ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ break;
+ case SEL_INVERT:
+ if (ebone->flag & BONE_SELECTED) {
+ ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else {
+ ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ if (ebone->parent)
+ ebone->parent->flag |= (BONE_TIPSEL);
+ }
+ break;
}
}
}
CTX_DATA_END;
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
return OPERATOR_FINISHED;
}
@@ -4033,7 +4033,7 @@ void ARMATURE_OT_select_all(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
@@ -4077,7 +4077,7 @@ static void select_similar_length(bArmature *arm, EditBone *ebone_act, const flo
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
if ((ebone->length >= len_min) &&
- (ebone->length <= len_max))
+ (ebone->length <= len_max))
{
ED_armature_edit_bone_select(ebone);
}
@@ -4227,30 +4227,30 @@ void ARMATURE_OT_select_similar(wmOperatorType *ot) {
static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
{
- Object *obedit= CTX_data_edit_object(C);
+ Object *obedit = CTX_data_edit_object(C);
Object *ob;
bArmature *arm;
EditBone *curbone, *pabone, *chbone;
int direction = RNA_enum_get(op->ptr, "direction");
int add_to_sel = RNA_boolean_get(op->ptr, "extend");
- ob= obedit;
- arm= (bArmature *)ob->data;
+ ob = obedit;
+ arm = (bArmature *)ob->data;
- for (curbone= arm->edbo->first; curbone; curbone= curbone->next) {
+ for (curbone = arm->edbo->first; curbone; curbone = curbone->next) {
/* only work on bone if it is visible and its selection can change */
- if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE)==0) {
+ if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE) == 0) {
if (curbone == arm->act_edbone) {
if (direction == BONE_SELECT_PARENT) {
if (curbone->parent == NULL) continue;
else pabone = curbone->parent;
if (EBONE_VISIBLE(arm, pabone)) {
- pabone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- arm->act_edbone= pabone;
- if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
+ pabone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ arm->act_edbone = pabone;
+ if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL;
- if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
break;
}
@@ -4259,12 +4259,12 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
chbone = editbone_get_child(arm, curbone, 1);
if (chbone == NULL) continue;
- if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE)==0) {
- chbone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- arm->act_edbone= chbone;
+ if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE) == 0) {
+ chbone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ arm->act_edbone = chbone;
if (!add_to_sel) {
- curbone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL);
+ curbone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL);
if (curbone->parent) curbone->parent->flag &= ~BONE_TIPSEL;
}
break;
@@ -4276,17 +4276,17 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
ED_armature_sync_selection(arm->edbo);
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
{
- static EnumPropertyItem direction_items[]= {
- {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
- {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
- {0, NULL, 0, NULL, NULL}
+ static EnumPropertyItem direction_items[] = {
+ {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
+ {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
+ {0, NULL, 0, NULL, NULL}
};
/* identifiers */
@@ -4299,7 +4299,7 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_enum(ot->srna, "direction", direction_items,
@@ -4329,7 +4329,7 @@ static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone)
{
EditBone *selbone;
- for (selbone = edbo->first; selbone; selbone=selbone->next) {
+ for (selbone = edbo->first; selbone; selbone = selbone->next) {
if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) {
fix_connected_bone(selbone);
fix_editbone_connected_children(edbo, selbone);
@@ -4361,10 +4361,10 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb
static int armature_align_bones_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_edit_object(C);
- bArmature *arm= (bArmature *)ob->data;
- EditBone *actbone= CTX_data_active_bone(C);
- EditBone *actmirb= NULL;
+ Object *ob = CTX_data_edit_object(C);
+ bArmature *arm = (bArmature *)ob->data;
+ EditBone *actbone = CTX_data_active_bone(C);
+ EditBone *actmirb = NULL;
/* there must be an active bone */
if (actbone == NULL) {
@@ -4379,9 +4379,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
* - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent")
* then just use actbone. Useful when doing upper arm to spine.
*/
- actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone);
+ actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone);
if (actmirb == NULL)
- actmirb= actbone;
+ actmirb = actbone;
}
/* if there is only 1 selected bone, we assume that that is the active bone,
@@ -4422,7 +4422,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op)
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
return OPERATOR_FINISHED;
}
@@ -4440,14 +4440,14 @@ void ARMATURE_OT_align(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ***************** Pose tools ********************* */
// XXX bone_looper is only to be used when we want to access settings (i.e. editability/visibility/selected) that context doesn't offer
static int bone_looper(Object *ob, Bone *bone, void *data,
- int (*bone_func)(Object *, Bone *, void *))
+ int (*bone_func)(Object *, Bone *, void *))
{
/* We want to apply the function bone_func to every bone
* in an armature -- feed bone_looper the first bone and
@@ -4477,49 +4477,49 @@ static int bone_looper(Object *ob, Bone *bone, void *data,
/* assumes scene obact and basact is still on old situation */
int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend)
{
- Object *ob= base->object;
+ Object *ob = base->object;
Bone *nearBone;
if (!ob || !ob->pose) return 0;
- nearBone= get_bone_from_selectbuffer(scene, base, buffer, hits, 1);
+ nearBone = get_bone_from_selectbuffer(scene, base, buffer, hits, 1);
/* if the bone cannot be affected, don't do anything */
if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) {
- Object *ob_act= OBACT;
- bArmature *arm= ob->data;
+ Object *ob_act = OBACT;
+ bArmature *arm = ob->data;
/* since we do unified select, we don't shift+select a bone if the
* armature object was not active yet.
* note, special exception for armature mode so we can do multi-select
* we could check for multi-select explicitly but think its fine to
* always give predictable behavior in weight paint mode - campbell */
- if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT)==0))) {
+ if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) {
ED_pose_deselectall(ob, 0);
- nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- arm->act_bone= nearBone;
+ nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ arm->act_bone = nearBone;
- // XXX old cruft! use notifiers instead
+ // XXX old cruft! use notifiers instead
//select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
else {
if (nearBone->flag & BONE_SELECTED) {
/* if not active, we make it active */
if (nearBone != arm->act_bone) {
- arm->act_bone= nearBone;
+ arm->act_bone = nearBone;
}
else {
- nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- // XXX old cruft! use notifiers instead
+ // XXX old cruft! use notifiers instead
//select_actionchannel_by_name(ob->action, nearBone->name, 0);
}
}
else {
- nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- arm->act_bone= nearBone;
+ nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ arm->act_bone = nearBone;
- // XXX old cruft! use notifiers instead
+ // XXX old cruft! use notifiers instead
//select_actionchannel_by_name(ob->action, nearBone->name, 1);
}
}
@@ -4534,7 +4534,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
}
- return nearBone!=NULL;
+ return nearBone != NULL;
}
/* test==0: deselect all
@@ -4544,16 +4544,16 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
*/
void ED_pose_deselectall(Object *ob, int test)
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
bPoseChannel *pchan;
- int selectmode= 0;
+ int selectmode = 0;
/* we call this from outliner too */
if (ELEM(NULL, ob, ob->pose)) return;
/* Determine if we're selecting or deselecting */
- if (test==1) {
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ if (test == 1) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (PBONE_VISIBLE(arm, pchan->bone)) {
if (pchan->bone->flag & BONE_SELECTED)
break;
@@ -4561,21 +4561,21 @@ void ED_pose_deselectall(Object *ob, int test)
}
if (pchan == NULL)
- selectmode= 1;
+ selectmode = 1;
}
else if (test == 2)
- selectmode= 2;
+ selectmode = 2;
/* Set the flags accordingly */
- for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
+ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
/* ignore the pchan if it isn't visible or if its selection cannot be changed */
- if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) {
- if (test==3) {
- pchan->bone->flag ^= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+ if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) {
+ if (test == 3) {
+ pchan->bone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
else {
- if (selectmode==0) pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- else if (selectmode==1) pchan->bone->flag |= BONE_SELECTED;
+ if (selectmode == 0) pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ else if (selectmode == 1) pchan->bone->flag |= BONE_SELECTED;
}
}
}
@@ -4611,7 +4611,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) {
if (!(bone->flag & BONE_NO_DEFORM)) {
- if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name))
+ if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name))
segments = bone->segments;
else
segments = 1;
@@ -4619,7 +4619,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
if (data->list != NULL) {
hbone = (Bone ***) &data->list;
- for (a=0; a<segments; a++) {
+ for (a = 0; a < segments; a++) {
**hbone = bone;
++*hbone;
}
@@ -4670,15 +4670,15 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
* pointers to bDeformGroups, all with names
* of skinnable bones.
*/
- bDeformGroup ***hgroup, *defgroup= NULL;
+ bDeformGroup ***hgroup, *defgroup = NULL;
int a, segments;
- struct { Object *armob; void *list; int heat; } *data= datap;
+ struct { Object *armob; void *list; int heat; } *data = datap;
int wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT);
- bArmature *arm= data->armob->data;
+ bArmature *arm = data->armob->data;
if (!wpmode || !(bone->flag & BONE_HIDDEN_P)) {
- if (!(bone->flag & BONE_NO_DEFORM)) {
- if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name))
+ if (!(bone->flag & BONE_NO_DEFORM)) {
+ if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name))
segments = bone->segments;
else
segments = 1;
@@ -4690,7 +4690,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap)
if (data->list != NULL) {
hgroup = (bDeformGroup ***) &data->list;
- for (a=0; a<segments; a++) {
+ for (a = 0; a < segments; a++) {
**hgroup = defgroup;
++*hgroup;
}
@@ -4720,11 +4720,11 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
int i, iflip, j;
/* for each vertex in the mesh */
- for (i=0; i < mesh->totvert; i++) {
- iflip = (dgroupflip)? mesh_get_x_mirror_vert(ob, i): 0;
+ for (i = 0; i < mesh->totvert; i++) {
+ iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, i) : 0;
/* for each skinnable bone */
- for (j=0; j < numbones; ++j) {
+ for (j = 0; j < numbones; ++j) {
if (!selected[j])
continue;
@@ -4732,22 +4732,22 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
dgroup = dgrouplist[j];
/* store the distance-factor from the vertex to the bone */
- distance = distfactor_to_bone (verts[i], root[j], tip[j],
- bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
+ distance = distfactor_to_bone(verts[i], root[j], tip[j],
+ bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale);
/* add the vert to the deform group if weight!=0.0 */
if (distance != 0.0f)
- ED_vgroup_vert_add (ob, dgroup, i, distance, WEIGHT_REPLACE);
+ ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE);
else
- ED_vgroup_vert_remove (ob, dgroup, i);
+ ED_vgroup_vert_remove(ob, dgroup, i);
/* do same for mirror */
if (dgroupflip && dgroupflip[j] && iflip >= 0) {
if (distance != 0.0f)
- ED_vgroup_vert_add (ob, dgroupflip[j], iflip, distance,
- WEIGHT_REPLACE);
+ ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance,
+ WEIGHT_REPLACE);
else
- ED_vgroup_vert_remove (ob, dgroupflip[j], iflip);
+ ED_vgroup_vert_remove(ob, dgroupflip[j], iflip);
}
}
}
@@ -4767,7 +4767,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
* when parenting, or simply the original mesh coords.
*/
- bArmature *arm= par->data;
+ bArmature *arm = par->data;
Bone **bonelist, *bone;
bDeformGroup **dgrouplist, **dgroupflip;
bDeformGroup *dgroup;
@@ -4781,8 +4781,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
struct { Object *armob; void *list; int heat; } looper_data;
looper_data.armob = par;
- looper_data.heat= heat;
- looper_data.list= NULL;
+ looper_data.heat = heat;
+ looper_data.list = NULL;
/* count the number of skinnable bones */
numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
@@ -4792,26 +4792,26 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
/* create an array of pointer to bones that are skinnable
* and fill it with all of the skinnable bones */
- bonelist = MEM_callocN(numbones*sizeof(Bone *), "bonelist");
- looper_data.list= bonelist;
+ bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist");
+ looper_data.list = bonelist;
bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb);
/* create an array of pointers to the deform groups that
* coorespond to the skinnable bones (creating them
* as necessary. */
- dgrouplist = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgrouplist");
- dgroupflip = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgroupflip");
+ dgrouplist = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist");
+ dgroupflip = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgroupflip");
- looper_data.list= dgrouplist;
+ looper_data.list = dgrouplist;
bone_looper(ob, arm->bonebase.first, &looper_data, dgroup_skinnable_cb);
/* create an array of root and tip positions transformed into
* global coords */
- root = MEM_callocN(numbones*sizeof(float)*3, "root");
- tip = MEM_callocN(numbones*sizeof(float)*3, "tip");
- selected = MEM_callocN(numbones*sizeof(int), "selected");
+ root = MEM_callocN(numbones * sizeof(float) * 3, "root");
+ tip = MEM_callocN(numbones * sizeof(float) * 3, "tip");
+ selected = MEM_callocN(numbones * sizeof(int), "selected");
- for (j=0; j < numbones; ++j) {
+ for (j = 0; j < numbones; ++j) {
bone = bonelist[j];
dgroup = dgrouplist[j];
@@ -4821,7 +4821,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
segments = 1;
bbone = NULL;
- if ((par->pose) && (pchan=get_pose_channel(par->pose, bone->name))) {
+ if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) {
if (bone->segments > 1) {
segments = bone->segments;
bbone = b_bone_spline_setup(pchan, 1);
@@ -4835,8 +4835,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
/* compute root and tip */
if (bbone) {
mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]);
- if ((segments+1) < bone->segments) {
- mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments+1].mat[3]);
+ if ((segments + 1) < bone->segments) {
+ mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments + 1].mat[3]);
}
else {
copy_v3_v3(tip[j], bone->arm_tail);
@@ -4869,15 +4869,15 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
}
/* create verts */
- mesh = (Mesh*)ob->data;
- verts = MEM_callocN(mesh->totvert*sizeof(*verts), "closestboneverts");
+ mesh = (Mesh *)ob->data;
+ verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts");
if (wpmode) {
/* if in weight paint mode, use final verts from derivedmesh */
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
if (dm->foreachMappedVert) {
- dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void*)verts);
+ dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void *)verts);
vertsfilled = 1;
}
@@ -4892,7 +4892,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
}
/* transform verts to global space */
- for (i=0; i < mesh->totvert; i++) {
+ for (i = 0; i < mesh->totvert; i++) {
if (!vertsfilled)
copy_v3_v3(verts[i], mesh->mvert[i].co);
mul_m4_v3(ob->obmat, verts[i]);
@@ -4900,9 +4900,9 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
/* compute the weights based on gathered vertices and bones */
if (heat) {
- const char *error= NULL;
+ const char *error = NULL;
heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip,
- root, tip, selected, &error);
+ root, tip, selected, &error);
if (error) {
BKE_report(reports, RPT_WARNING, error);
@@ -4910,7 +4910,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
}
else {
envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist,
- dgroupflip, root, tip, selected, mat4_to_scale(par->obmat));
+ dgroupflip, root, tip, selected, mat4_to_scale(par->obmat));
}
/* only generated in some cases but can call anyway */
@@ -4931,7 +4931,7 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob,
/* Lets try to create some vertex groups
* based on the bones of the parent armature.
*/
- bArmature *arm= par->data;
+ bArmature *arm = par->data;
if (mode == ARM_GROUPS_NAME) {
/* Traverse the bone list, trying to create empty vertex
@@ -4955,41 +4955,41 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob,
/* clear scale of pose-channel */
static void pchan_clear_scale(bPoseChannel *pchan)
{
- if ((pchan->protectflag & OB_LOCK_SCALEX)==0)
- pchan->size[0]= 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEY)==0)
- pchan->size[1]= 1.0f;
- if ((pchan->protectflag & OB_LOCK_SCALEZ)==0)
- pchan->size[2]= 1.0f;
+ if ((pchan->protectflag & OB_LOCK_SCALEX) == 0)
+ pchan->size[0] = 1.0f;
+ if ((pchan->protectflag & OB_LOCK_SCALEY) == 0)
+ pchan->size[1] = 1.0f;
+ if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0)
+ pchan->size[2] = 1.0f;
}
/* clear location of pose-channel */
static void pchan_clear_loc(bPoseChannel *pchan)
{
- if ((pchan->protectflag & OB_LOCK_LOCX)==0)
- pchan->loc[0]= 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCY)==0)
- pchan->loc[1]= 0.0f;
- if ((pchan->protectflag & OB_LOCK_LOCZ)==0)
- pchan->loc[2]= 0.0f;
+ if ((pchan->protectflag & OB_LOCK_LOCX) == 0)
+ pchan->loc[0] = 0.0f;
+ if ((pchan->protectflag & OB_LOCK_LOCY) == 0)
+ pchan->loc[1] = 0.0f;
+ if ((pchan->protectflag & OB_LOCK_LOCZ) == 0)
+ pchan->loc[2] = 0.0f;
}
/* clear rotation of pose-channel */
static void pchan_clear_rot(bPoseChannel *pchan)
{
- if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) {
+ if (pchan->protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) {
/* check if convert to eulers for locking... */
if (pchan->protectflag & OB_LOCK_ROT4D) {
/* perform clamping on a component by component basis */
if (pchan->rotmode == ROT_MODE_AXISANGLE) {
if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
- pchan->rotAngle= 0.0f;
+ pchan->rotAngle = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
- pchan->rotAxis[0]= 0.0f;
+ pchan->rotAxis[0] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
- pchan->rotAxis[1]= 0.0f;
+ pchan->rotAxis[1] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
- pchan->rotAxis[2]= 0.0f;
+ pchan->rotAxis[2] = 0.0f;
/* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */
if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2]))
@@ -4997,22 +4997,22 @@ static void pchan_clear_rot(bPoseChannel *pchan)
}
else if (pchan->rotmode == ROT_MODE_QUAT) {
if ((pchan->protectflag & OB_LOCK_ROTW) == 0)
- pchan->quat[0]= 1.0f;
+ pchan->quat[0] = 1.0f;
if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
- pchan->quat[1]= 0.0f;
+ pchan->quat[1] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
- pchan->quat[2]= 0.0f;
+ pchan->quat[2] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
- pchan->quat[3]= 0.0f;
+ pchan->quat[3] = 0.0f;
}
else {
/* the flag may have been set for the other modes, so just ignore the extra flag... */
if ((pchan->protectflag & OB_LOCK_ROTX) == 0)
- pchan->eul[0]= 0.0f;
+ pchan->eul[0] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTY) == 0)
- pchan->eul[1]= 0.0f;
+ pchan->eul[1] = 0.0f;
if ((pchan->protectflag & OB_LOCK_ROTZ) == 0)
- pchan->eul[2]= 0.0f;
+ pchan->eul[2] = 0.0f;
}
}
else {
@@ -5021,7 +5021,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
float qlen = 0.0f;
if (pchan->rotmode == ROT_MODE_QUAT) {
- qlen= normalize_qt_qt(quat1, pchan->quat);
+ qlen = normalize_qt_qt(quat1, pchan->quat);
quat_to_eul(oldeul, quat1);
}
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
@@ -5031,14 +5031,14 @@ static void pchan_clear_rot(bPoseChannel *pchan)
copy_v3_v3(oldeul, pchan->eul);
}
- eul[0]= eul[1]= eul[2]= 0.0f;
+ eul[0] = eul[1] = eul[2] = 0.0f;
if (pchan->protectflag & OB_LOCK_ROTX)
- eul[0]= oldeul[0];
+ eul[0] = oldeul[0];
if (pchan->protectflag & OB_LOCK_ROTY)
- eul[1]= oldeul[1];
+ eul[1] = oldeul[1];
if (pchan->protectflag & OB_LOCK_ROTZ)
- eul[2]= oldeul[2];
+ eul[2] = oldeul[2];
if (pchan->rotmode == ROT_MODE_QUAT) {
eul_to_quat(pchan->quat, eul);
@@ -5047,7 +5047,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
mul_qt_fl(pchan->quat, qlen);
/* quaternions flip w sign to accumulate rotations correctly */
- if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) {
+ if ((quat1[0] < 0.0f && pchan->quat[0] > 0.0f) || (quat1[0] > 0.0f && pchan->quat[0] < 0.0f)) {
mul_qt_fl(pchan->quat, -1.0f);
}
}
@@ -5058,7 +5058,7 @@ static void pchan_clear_rot(bPoseChannel *pchan)
copy_v3_v3(pchan->eul, eul);
}
}
- } // Duplicated in source/blender/editors/object/object_transform.c
+ } /* Duplicated in source/blender/editors/object/object_transform.c */
else {
if (pchan->rotmode == ROT_MODE_QUAT) {
unit_qt(pchan->quat);
@@ -5085,10 +5085,10 @@ static void pchan_clear_transforms(bPoseChannel *pchan)
/* generic exec for clear-pose operators */
static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
- void (*clear_func)(bPoseChannel*), const char default_ksName[])
+ void (*clear_func)(bPoseChannel *), const char default_ksName[])
{
- Scene *scene= CTX_data_scene(C);
- Object *ob= object_pose_armature_get(CTX_data_active_object(C));
+ Scene *scene = CTX_data_scene(C);
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
short autokey = 0;
/* sanity checks */
@@ -5098,7 +5098,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
}
/* only clear relevant transforms for selected bones */
- CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones)
+ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones)
{
/* run provided clearing function */
clear_func(pchan);
@@ -5136,7 +5136,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op,
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob);
return OPERATOR_FINISHED;
}
@@ -5160,7 +5160,7 @@ void POSE_OT_scale_clear(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5181,7 +5181,7 @@ void POSE_OT_rot_clear(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5202,7 +5202,7 @@ void POSE_OT_loc_clear(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5223,7 +5223,7 @@ void POSE_OT_transforms_clear(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ***************** selections ********************** */
@@ -5232,11 +5232,11 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
{
int action = RNA_enum_get(op->ptr, "action");
- Scene *scene= CTX_data_scene(C);
+ Scene *scene = CTX_data_scene(C);
int multipaint = scene->toolsettings->multipaint;
if (action == SEL_TOGGLE) {
- action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
+ action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
}
/* Set the flags */
@@ -5244,26 +5244,26 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
{
/* select pchan only if selectable, but deselect works always */
switch (action) {
- case SEL_SELECT:
- if ((pchan->bone->flag & BONE_UNSELECTABLE)==0)
- pchan->bone->flag |= BONE_SELECTED;
- break;
- case SEL_DESELECT:
- pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- break;
- case SEL_INVERT:
- if (pchan->bone->flag & BONE_SELECTED) {
- pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
- }
- else if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+ case SEL_SELECT:
+ if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0)
pchan->bone->flag |= BONE_SELECTED;
- }
- break;
+ break;
+ case SEL_DESELECT:
+ pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ break;
+ case SEL_INVERT:
+ if (pchan->bone->flag & BONE_SELECTED) {
+ pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ }
+ else if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) {
+ pchan->bone->flag |= BONE_SELECTED;
+ }
+ break;
}
}
CTX_DATA_END;
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL);
if (multipaint) {
Object *ob = ED_object_context(C);
@@ -5285,24 +5285,24 @@ void POSE_OT_select_all(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= object_pose_armature_get(CTX_data_active_object(C));
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
bPoseChannel *pchan, *parent;
/* Determine if there is an active bone */
- pchan=CTX_data_active_pose_bone(C);
+ pchan = CTX_data_active_pose_bone(C);
if (pchan) {
- bArmature *arm= ob->data;
- parent=pchan->parent;
- if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) {
+ bArmature *arm = ob->data;
+ parent = pchan->parent;
+ if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) {
parent->bone->flag |= BONE_SELECTED;
- arm->act_bone= parent->bone;
+ arm->act_bone = parent->bone;
}
else {
return OPERATOR_CANCELLED;
@@ -5312,7 +5312,7 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
@@ -5329,7 +5329,7 @@ void POSE_OT_select_parent(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -5337,14 +5337,14 @@ void POSE_OT_select_parent(wmOperatorType *ot)
static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
if (arm->layer & bone->layer) {
if (bone->flag & BONE_SELECTED) {
bone->flag |= BONE_HIDDEN_P;
bone->flag &= ~BONE_SELECTED;
- if (arm->act_bone==bone)
- arm->act_bone= NULL;
+ if (arm->act_bone == bone)
+ arm->act_bone = NULL;
}
}
return 0;
@@ -5352,14 +5352,14 @@ static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
if (arm->layer & bone->layer) {
// hrm... typo here?
- if ((bone->flag & BONE_SELECTED)==0) {
+ if ((bone->flag & BONE_SELECTED) == 0) {
bone->flag |= BONE_HIDDEN_P;
- if (arm->act_bone==bone)
- arm->act_bone= NULL;
+ if (arm->act_bone == bone)
+ arm->act_bone = NULL;
}
}
return 0;
@@ -5368,8 +5368,8 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr
/* active object is armature in posemode, poll checked */
static int pose_hide_exec(bContext *C, wmOperator *op)
{
- Object *ob= object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm= ob->data;
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ bArmature *arm = ob->data;
if (RNA_boolean_get(op->ptr, "unselected"))
bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb);
@@ -5377,7 +5377,7 @@ static int pose_hide_exec(bContext *C, wmOperator *op)
bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
@@ -5394,7 +5394,7 @@ void POSE_OT_hide(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "");
@@ -5402,7 +5402,7 @@ void POSE_OT_hide(wmOperatorType *ot)
static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
{
- bArmature *arm= ob->data;
+ bArmature *arm = ob->data;
if (arm->layer & bone->layer) {
if (bone->flag & BONE_HIDDEN_P) {
@@ -5417,13 +5417,13 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr))
/* active object is armature in posemode, poll checked */
static int pose_reveal_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= object_pose_armature_get(CTX_data_active_object(C));
- bArmature *arm= ob->data;
+ Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C));
+ bArmature *arm = ob->data;
bone_looper(ob, arm->bonebase.first, NULL, show_pose_bone_cb);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob);
return OPERATOR_FINISHED;
}
@@ -5440,14 +5440,14 @@ void POSE_OT_reveal(wmOperatorType *ot)
ot->poll = ED_operator_posemode;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ************* RENAMING DISASTERS ************ */
static int bone_unique_check(void *arg, const char *name)
{
- return get_named_bone((bArmature *)arg, name) != NULL;
+ return BKE_armature_find_bone_name((bArmature *)arg, name) != NULL;
}
static void unique_bone_name(bArmature *arm, char *name)
@@ -5461,14 +5461,14 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam
bConstraint *curcon;
bConstraintTarget *ct;
- for (curcon = conlist->first; curcon; curcon=curcon->next) {
- bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon);
+ for (curcon = conlist->first; curcon; curcon = curcon->next) {
+ bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon);
ListBase targets = {NULL, NULL};
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(curcon, &targets);
- for (ct= targets.first; ct; ct= ct->next) {
+ for (ct = targets.first; ct; ct = ct->next) {
if (ct->tar == ob) {
if (!strcmp(ct->subtarget, oldname) )
BLI_strncpy(ct->subtarget, newname, MAXBONENAME);
@@ -5500,7 +5500,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
/* now check if we're in editmode, we need to find the unique name */
if (arm->edbo) {
- EditBone *eBone= editbone_name_exists(arm->edbo, oldname);
+ EditBone *eBone = editbone_name_exists(arm->edbo, oldname);
if (eBone) {
unique_editbone_name(arm->edbo, newname, NULL);
@@ -5509,7 +5509,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
else return;
}
else {
- Bone *bone= get_named_bone(arm, oldname);
+ Bone *bone = BKE_armature_find_bone_name(arm, oldname);
if (bone) {
unique_bone_name(arm, newname);
@@ -5519,16 +5519,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
/* do entire dbase - objects */
- for (ob= G.main->object.first; ob; ob= ob->id.next) {
+ for (ob = G.main->object.first; ob; ob = ob->id.next) {
ModifierData *md;
/* we have the object using the armature */
- if (arm==ob->data) {
+ if (arm == ob->data) {
Object *cob;
/* Rename the pose channel, if it exists */
if (ob->pose) {
- bPoseChannel *pchan = get_pose_channel(ob->pose, oldname);
+ bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname);
if (pchan) {
BLI_strncpy(pchan->name, newname, MAXBONENAME);
@@ -5543,12 +5543,12 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
/* Update any object constraints to use the new bone name */
- for (cob= G.main->object.first; cob; cob= cob->id.next) {
+ for (cob = G.main->object.first; cob; cob = cob->id.next) {
if (cob->constraints.first)
constraint_bone_name_fix(ob, &cob->constraints, oldname, newname);
if (cob->pose) {
bPoseChannel *pchan;
- for (pchan = cob->pose->chanbase.first; pchan; pchan=pchan->next) {
+ for (pchan = cob->pose->chanbase.first; pchan; pchan = pchan->next) {
constraint_bone_name_fix(ob, &pchan->constraints, oldname, newname);
}
}
@@ -5557,7 +5557,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
/* See if an object is parented to this armature */
if (ob->parent && (ob->parent->data == arm)) {
- if (ob->partype==PARBONE) {
+ if (ob->partype == PARBONE) {
/* bone name in object */
if (!strcmp(ob->parsubstr, oldname))
BLI_strncpy(ob->parsubstr, newname, MAXBONENAME);
@@ -5565,14 +5565,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
if (modifiers_usesArmature(ob, arm)) {
- bDeformGroup *dg= defgroup_find_name(ob, oldname);
+ bDeformGroup *dg = defgroup_find_name(ob, oldname);
if (dg) {
BLI_strncpy(dg->name, newname, MAXBONENAME);
}
}
/* fix modifiers that might be using this name */
- for (md= ob->modifiers.first; md; md= md->next) {
+ for (md = ob->modifiers.first; md; md = md->next) {
if (md->type == eModifierType_Hook) {
HookModifierData *hmd = (HookModifierData *)md;
@@ -5596,14 +5596,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
/* correct view locking */
{
bScreen *screen;
- for (screen= G.main->screen.first; screen; screen= screen->id.next) {
+ for (screen = G.main->screen.first; screen; screen = screen->id.next) {
ScrArea *sa;
/* add regions */
- for (sa= screen->areabase.first; sa; sa= sa->next) {
+ for (sa = screen->areabase.first; sa; sa = sa->next) {
SpaceLink *sl;
- for (sl= sa->spacedata.first; sl; sl= sl->next) {
- if (sl->spacetype==SPACE_VIEW3D) {
- View3D *v3d= (View3D *)sl;
+ for (sl = sa->spacedata.first; sl; sl = sl->next) {
+ if (sl->spacetype == SPACE_VIEW3D) {
+ View3D *v3d = (View3D *)sl;
if (v3d->ob_centre && v3d->ob_centre->data == arm) {
if (!strcmp(v3d->ob_centre_bone, oldname)) {
BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME);
@@ -5618,16 +5618,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n
}
-static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
+static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op))
{
- Object *ob= CTX_data_edit_object(C);
+ Object *ob = CTX_data_edit_object(C);
bArmature *arm;
char newname[MAXBONENAME];
/* paranoia checks */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
- arm= ob->data;
+ arm = ob->data;
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
@@ -5641,7 +5641,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op))
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
return OPERATOR_FINISHED;
}
@@ -5658,21 +5658,21 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int armature_autoside_names_exec (bContext *C, wmOperator *op)
+static int armature_autoside_names_exec(bContext *C, wmOperator *op)
{
- Object *ob= CTX_data_edit_object(C);
+ Object *ob = CTX_data_edit_object(C);
bArmature *arm;
char newname[MAXBONENAME];
- short axis= RNA_enum_get(op->ptr, "type");
+ short axis = RNA_enum_get(op->ptr, "type");
/* paranoia checks */
if (ELEM(NULL, ob, ob->pose))
return OPERATOR_CANCELLED;
- arm= ob->data;
+ arm = ob->data;
/* loop through selected bones, auto-naming them */
CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones)
@@ -5687,15 +5687,15 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op)
DAG_id_tag_update(&ob->id, OB_RECALC_DATA);
/* note, notifier might evolve */
- WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob);
+ WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob);
return OPERATOR_FINISHED;
}
void ARMATURE_OT_autoside_names(wmOperatorType *ot)
{
- static EnumPropertyItem axis_items[]= {
- {0, "XAXIS", 0, "X-Axis", "Left/Right"},
+ static EnumPropertyItem axis_items[] = {
+ {0, "XAXIS", 0, "X-Axis", "Left/Right"},
{1, "YAXIS", 0, "Y-Axis", "Front/Back"},
{2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"},
{0, NULL, 0, NULL, NULL}};
@@ -5711,7 +5711,7 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
ot->poll = ED_operator_editarmature;
/* flags */
- ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* settings */
ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with");
@@ -5723,27 +5723,27 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot)
/* context; editmode armature, with mirror editing enabled */
void transform_armature_mirror_update(Object *obedit)
{
- bArmature *arm= obedit->data;
+ bArmature *arm = obedit->data;
EditBone *ebo, *eboflip;
- for (ebo= arm->edbo->first; ebo; ebo=ebo->next) {
+ for (ebo = arm->edbo->first; ebo; ebo = ebo->next) {
/* no layer check, correct mirror is more important */
- if (ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) {
- eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebo);
+ if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) {
+ eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo);
if (eboflip) {
/* we assume X-axis flipping for now */
if (ebo->flag & BONE_TIPSEL) {
EditBone *children;
- eboflip->tail[0]= -ebo->tail[0];
- eboflip->tail[1]= ebo->tail[1];
- eboflip->tail[2]= ebo->tail[2];
- eboflip->rad_tail= ebo->rad_tail;
- eboflip->roll= -ebo->roll;
+ eboflip->tail[0] = -ebo->tail[0];
+ eboflip->tail[1] = ebo->tail[1];
+ eboflip->tail[2] = ebo->tail[2];
+ eboflip->rad_tail = ebo->rad_tail;
+ eboflip->roll = -ebo->roll;
/* Also move connected children, in case children's name aren't mirrored properly */
- for (children=arm->edbo->first; children; children=children->next) {
+ for (children = arm->edbo->first; children; children = children->next) {
if (children->parent == eboflip && children->flag & BONE_CONNECTED) {
copy_v3_v3(children->head, eboflip->tail);
children->rad_head = ebo->rad_tail;
@@ -5751,11 +5751,11 @@ void transform_armature_mirror_update(Object *obedit)
}
}
if (ebo->flag & BONE_ROOTSEL) {
- eboflip->head[0]= -ebo->head[0];
- eboflip->head[1]= ebo->head[1];
- eboflip->head[2]= ebo->head[2];
- eboflip->rad_head= ebo->rad_head;
- eboflip->roll= -ebo->roll;
+ eboflip->head[0] = -ebo->head[0];
+ eboflip->head[1] = ebo->head[1];
+ eboflip->head[2] = ebo->head[2];
+ eboflip->rad_head = ebo->rad_head;
+ eboflip->roll = -ebo->roll;
/* Also move connected parent, in case parent's name isn't mirrored properly */
if (eboflip->parent && eboflip->flag & BONE_CONNECTED) {
@@ -5765,10 +5765,10 @@ void transform_armature_mirror_update(Object *obedit)
}
}
if (ebo->flag & BONE_SELECTED) {
- eboflip->dist= ebo->dist;
- eboflip->roll= -ebo->roll;
- eboflip->xwidth= ebo->xwidth;
- eboflip->zwidth= ebo->zwidth;
+ eboflip->dist = ebo->dist;
+ eboflip->roll = -ebo->roll;
+ eboflip->xwidth = ebo->xwidth;
+ eboflip->zwidth = ebo->zwidth;
}
}
}
@@ -5784,14 +5784,14 @@ void transform_armature_mirror_update(Object *obedit)
/**************************************** SUBDIVISION ALGOS ******************************************/
-EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
+EditBone *subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
{
- bArmature *arm= obedit->data;
+ bArmature *arm = obedit->data;
EditBone *lastBone = NULL;
if (scene->toolsettings->skgen_options & SKGEN_CUT_ANGLE) {
ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator*)&arc_iter;
+ BArcIterator *iter = (BArcIterator *)&arc_iter;
float *previous = NULL, *current = NULL;
EditBone *child = NULL;
EditBone *parent = NULL;
@@ -5799,7 +5799,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
float angleLimit = (float)cos(scene->toolsettings->skgen_angle_limit * M_PI / 180.0f);
parent = ED_armature_edit_bone_add(arm, "Bone");
- parent->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
+ parent->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
copy_v3_v3(parent->head, head->p);
root = parent;
@@ -5809,8 +5809,8 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
previous = iter->p;
for (IT_next(iter);
- IT_stopped(iter) == 0;
- previous = iter->p, IT_next(iter))
+ IT_stopped(iter) == 0;
+ previous = iter->p, IT_next(iter))
{
float vec1[3], vec2[3];
float len1, len2;
@@ -5829,7 +5829,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
child = ED_armature_edit_bone_add(arm, "Bone");
copy_v3_v3(child->head, parent->tail);
child->parent = parent;
- child->flag |= BONE_CONNECTED|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
+ child->flag |= BONE_CONNECTED | BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
parent = child; /* new child is next parent */
}
@@ -5840,7 +5840,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
* to let subsequent subdivision methods do their thing.
* */
if (parent == root) {
- if (parent==arm->act_edbone) arm->act_edbone= NULL;
+ if (parent == arm->act_edbone) arm->act_edbone = NULL;
ED_armature_edit_bone_remove(arm, parent);
parent = NULL;
}
@@ -5851,16 +5851,16 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode
return lastBone;
}
-EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
+EditBone *test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
{
EditBone *lastBone = NULL;
if (scene->toolsettings->skgen_options & SKGEN_CUT_CORRELATION) {
- float invmat[4][4]= MAT4_UNITY;
- float tmat[3][3]= MAT3_UNITY;
+ float invmat[4][4] = MAT4_UNITY;
+ float tmat[3][3] = MAT3_UNITY;
ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator*)&arc_iter;
- bArmature *arm= obedit->data;
+ BArcIterator *iter = (BArcIterator *)&arc_iter;
+ bArmature *arm = obedit->data;
initArcIterator(iter, arc, head);
@@ -5894,17 +5894,17 @@ float arcLengthRatio(ReebArc *arc)
return embedLength / arcLength;
}
-EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
+EditBone *test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail)
{
EditBone *lastBone = NULL;
if ((scene->toolsettings->skgen_options & SKGEN_CUT_LENGTH) &&
- arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio)
+ arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio)
{
- float invmat[4][4]= MAT4_UNITY;
- float tmat[3][3]= MAT3_UNITY;
+ float invmat[4][4] = MAT4_UNITY;
+ float tmat[3][3] = MAT3_UNITY;
ReebArcIterator arc_iter;
- BArcIterator *iter = (BArcIterator*)&arc_iter;
- bArmature *arm= obedit->data;
+ BArcIterator *iter = (BArcIterator *)&arc_iter;
+ bArmature *arm = obedit->data;
initArcIterator(iter, arc, head);
@@ -5918,7 +5918,7 @@ EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, Re
void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
{
- Object *obedit= scene->obedit; // XXX get from context
+ Object *obedit = scene->obedit; // XXX get from context
GHash *arcBoneMap = NULL;
ReebArc *arc = NULL;
ReebNode *node = NULL;
@@ -5932,22 +5932,22 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
ED_armature_edit_free(obedit);
}
- dst = add_object(scene, OB_ARMATURE);
- ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot
- obedit= scene->basact->object;
+ dst = BKE_object_add(scene, OB_ARMATURE);
+ ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot
+ obedit = scene->basact->object;
/* Copy orientation from source */
copy_v3_v3(dst->loc, src->obmat[3]);
mat4_to_eul(dst->rot, src->obmat);
mat4_to_size(dst->size, src->obmat);
- where_is_object(scene, obedit);
+ BKE_object_where_is_calc(scene, obedit);
ED_armature_to_edit(obedit);
arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SkeletonFromReebGraph gh");
- BLI_markdownSymmetry((BGraph*)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit);
+ BLI_markdownSymmetry((BGraph *)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit);
for (arc = rg->arcs.first; arc; arc = arc->next)
{
@@ -6008,9 +6008,9 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
}
if (lastBone == NULL) {
- EditBone *bone;
+ EditBone *bone;
bone = ED_armature_edit_bone_add(obedit->data, "Bone");
- bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL;
+ bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL;
copy_v3_v3(bone->head, head->p);
copy_v3_v3(bone->tail, tail->p);
@@ -6029,7 +6029,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg)
int i;
for (i = 0; i < node->degree; i++) {
- arc = (ReebArc*)node->arcs[i];
+ arc = (ReebArc *)node->arcs[i];
/* if arc is incoming into the node */
if ((arc->head == node && arc->flag == -1) ||