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.c78
1 files changed, 48 insertions, 30 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 6cef843d828..ffdced3262f 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -657,12 +657,14 @@ static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata();
return OPERATOR_CANCELLED;
}
-
+
/* helpful warnings... */
- // TODO: add warnings to be careful about actions, applying deforms first, etc.
- if (ob->adt && ob->adt->action)
- BKE_report(op->reports, RPT_WARNING, "Actions on this armature will be destroyed by this new rest pose as the transforms stored are relative to the old rest pose");
-
+ /* TODO: add warnings to be careful about actions, applying deforms first, etc. */
+ if (ob->adt && ob->adt->action)
+ BKE_report(op->reports, RPT_WARNING,
+ "Actions on this armature will be destroyed by this new rest pose as the "
+ "transforms stored are relative to the old rest pose");
+
/* Get editbones of active armature to alter */
ED_armature_to_edit(ob);
@@ -1192,9 +1194,9 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op))
* 4. fix constraint links
* 5. make original armature active and enter editmode
*/
-
+
/* 1) only edit-base selected */
- // TODO: use context iterators for this?
+ /* TODO: use context iterators for this? */
CTX_DATA_BEGIN(C, Base *, base, visible_bases)
{
if (base->object == obedit) base->flag |= 1;
@@ -1213,6 +1215,8 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op))
/* 2) duplicate base */
newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */
+ DAG_scene_sort(bmain, scene);
+
newob = newbase->object;
newbase->flag &= ~SELECT;
@@ -1402,7 +1406,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)
@@ -1583,13 +1587,14 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
- /* properties s*/
+ /* properties */
RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first");
}
/* 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;
@@ -1829,7 +1834,7 @@ void ED_armature_deselect_all_visible(Object *obedit)
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_SELECTABLE(arm, ebone)) {
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}
@@ -2554,7 +2559,8 @@ void updateDuplicateSubtarget(EditBone *dupBone, ListBase *editbones, Object *ob
}
-EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase *editbones, Object *src_ob, Object *dst_ob)
+EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase *editbones,
+ Object *src_ob, Object *dst_ob)
{
EditBone *eBone = MEM_mallocN(sizeof(EditBone), "addup_editbone");
@@ -3034,7 +3040,8 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone
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...
@@ -3355,12 +3362,17 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (EBONE_VISIBLE(arm, ebone)) {
/* we extrude per definition the tip */
do_extrude = FALSE;
- if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED))
+ if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED)) {
do_extrude = TRUE;
+ }
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)) {
+ /* pass */
+ }
+ else {
+ do_extrude = 2;
+ }
}
if (do_extrude) {
@@ -4104,7 +4116,7 @@ static void select_similar_length(bArmature *arm, EditBone *ebone_act, const flo
const float len_max = ebone_act->length * (1.0f + thresh);
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
+ if (EBONE_SELECTABLE(arm, ebone)) {
if ((ebone->length >= len_min) &&
(ebone->length <= len_max))
{
@@ -4121,7 +4133,7 @@ static void select_similar_direction(bArmature *arm, EditBone *ebone_act, const
sub_v3_v3v3(dir_act, ebone_act->head, ebone_act->tail);
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
+ if (EBONE_SELECTABLE(arm, ebone)) {
float dir[3];
sub_v3_v3v3(dir, ebone->head, ebone->tail);
@@ -4137,7 +4149,7 @@ static void select_similar_layer(bArmature *arm, EditBone *ebone_act)
EditBone *ebone;
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
+ if (EBONE_SELECTABLE(arm, ebone)) {
if (ebone->layer & ebone_act->layer) {
ED_armature_edit_bone_select(ebone);
}
@@ -4159,7 +4171,7 @@ static void select_similar_prefix(bArmature *arm, EditBone *ebone_act)
/* Find matches */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
+ if (EBONE_SELECTABLE(arm, ebone)) {
char prefix_other[MAX_VGROUP_NAME];
BKE_deform_split_prefix(ebone->name, prefix_other, body_tmp);
if (!strcmp(prefix_act, prefix_other)) {
@@ -4183,7 +4195,7 @@ static void select_similar_suffix(bArmature *arm, EditBone *ebone_act)
/* Find matches */
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
- if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) {
+ if (EBONE_SELECTABLE(arm, ebone)) {
char suffix_other[MAX_VGROUP_NAME];
BKE_deform_split_suffix(ebone->name, body_tmp, suffix_other);
if (!strcmp(suffix_act, suffix_other)) {
@@ -4268,7 +4280,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op)
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_SELECTABLE(arm, curbone)) {
if (curbone == arm->act_edbone) {
if (direction == BONE_SELECT_PARENT) {
if (curbone->parent == NULL) continue;
@@ -4288,7 +4300,7 @@ 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) {
+ if (EBONE_SELECTABLE(arm, chbone)) {
chbone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
arm->act_edbone = chbone;
@@ -4474,7 +4486,8 @@ void ARMATURE_OT_align(wmOperatorType *ot)
/* ***************** 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
+/* 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 *))
{
@@ -4504,7 +4517,8 @@ static int bone_looper(Object *ob, Bone *bone, void *data,
/* called from editview.c, for mode-less pose selection */
/* 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, short deselect, short toggle)
+int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits,
+ short extend, short deselect, short toggle)
{
Object *ob = base->object;
Bone *nearBone;
@@ -4587,7 +4601,9 @@ void ED_pose_deselectall(Object *ob, int test)
int selectmode = 0;
/* we call this from outliner too */
- if (ELEM(NULL, ob, ob->pose)) return;
+ if (ob->pose == NULL) {
+ return;
+ }
/* Determine if we're selecting or deselecting */
if (test == 1) {
@@ -4748,7 +4764,9 @@ static void add_vgroups__mapFunc(void *userData, int index, const float co[3],
copy_v3_v3(verts[index], co);
}
-static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist, bDeformGroup **dgrouplist, bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], int *selected, float scale)
+static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], int numbones, Bone **bonelist,
+ bDeformGroup **dgrouplist, bDeformGroup **dgroupflip,
+ float (*root)[3], float (*tip)[3], int *selected, float scale)
{
/* Create vertex group weights from envelopes */
@@ -4773,7 +4791,7 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i
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 */
+ /* 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);
else
@@ -4838,7 +4856,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob,
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
+ * correspond to the skinnable bones (creating them
* as necessary. */
dgrouplist = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist");
dgroupflip = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgroupflip");
@@ -5404,7 +5422,7 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr
bArmature *arm = ob->data;
if (arm->layer & bone->layer) {
- // hrm... typo here?
+ /* hrm... typo here? */
if ((bone->flag & BONE_SELECTED) == 0) {
bone->flag |= BONE_HIDDEN_P;
if (arm->act_bone == bone)