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:
authorCampbell Barton <ideasman42@gmail.com>2010-12-08 06:05:46 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-12-08 06:05:46 +0300
commit2e667e45fc02c5de285df836e59248a82b45dff9 (patch)
treedb50ed1d0d743baf836dbc1cf5a185c4c4342e93 /source/blender/editors/armature
parent47d6166adb7a5100e04c645e7d6284c5c1b95c9d (diff)
Changed armature active bone so it is separate from selection this is consistent with active object, mesh editmode, curves & metaballs.
- active is no longer assumed to be selected. this fixes a simple bug - eg: Adding a new armature, entering pose mode and toggling selection failed. - outliner editbone selection now works like object and pose mode. - mouse selection sets the bone active even when the tip is selected. - active, unselected bones draw as wire color with a 15% tint of the selected color.
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r--source/blender/editors/armature/editarmature.c91
-rw-r--r--source/blender/editors/armature/poselib.c2
-rw-r--r--source/blender/editors/armature/poseobject.c14
3 files changed, 47 insertions, 60 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 36544bcb086..66af2f34f0f 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -119,7 +119,7 @@ void ED_armature_validate_active(struct bArmature *arm)
EditBone *ebone= arm->act_edbone;
if(ebone) {
- if(ebone->flag & BONE_HIDDEN_A || (ebone->flag & BONE_SELECTED)==0)
+ if(ebone->flag & BONE_HIDDEN_A)
arm->act_edbone= NULL;
}
}
@@ -1875,8 +1875,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
/* toggle==0: deselect
* toggle==1: swap (based on test)
- * toggle==2: only active tag
- * toggle==3: swap (no test)
+ * toggle==2: swap (no test), CURRENTLY UNUSED
*/
void ED_armature_deselect_all(Object *obedit, int toggle)
{
@@ -1898,34 +1897,30 @@ void ED_armature_deselect_all(Object *obedit, int toggle)
}
else sel= toggle;
- if(sel==2) {
- arm->act_edbone= NULL;
- } else {
- /* Set the flags */
- for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
- if (sel==3) {
- /* 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;
- }
- }
- else if (sel==1) {
- /* select bone */
- if(EBONE_VISIBLE(arm, eBone)) {
- eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
- if(eBone->parent)
- eBone->parent->flag |= (BONE_TIPSEL);
- }
- }
- else {
- /* deselect bone */
- eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ /* Set the flags */
+ 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;
}
}
+ else if (sel==1) {
+ /* select bone */
+ if(EBONE_VISIBLE(arm, eBone)) {
+ eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ if(eBone->parent)
+ eBone->parent->flag |= (BONE_TIPSEL);
+ }
+ }
+ else {
+ /* deselect bone */
+ eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+ if(arm->act_edbone==eBone)
+ arm->act_edbone= NULL;
+ }
}
ED_armature_sync_selection(arm->edbo);
@@ -1946,6 +1941,17 @@ void ED_armature_deselect_all_visible(Object *obedit)
ED_armature_sync_selection(arm->edbo);
}
+/* accounts for connected parents */
+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));
+ }
+ else {
+ return ebone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL);
+ }
+}
+
/* context: editmode armature in view3d */
int mouse_armature(bContext *C, short mval[2], int extend)
{
@@ -2014,7 +2020,9 @@ int mouse_armature(bContext *C, short mval[2], int extend)
if(nearBone) {
/* then now check for active status */
- if(nearBone->flag & BONE_SELECTED) arm->act_edbone= nearBone;
+ if(ebone_select_flag(nearBone)) {
+ arm->act_edbone= nearBone;
+ }
}
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
@@ -3098,13 +3106,13 @@ 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) || start==arm->act_edbone)==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) || end==arm->act_edbone)==0) {
+ if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED)==0) {
copy_v3_v3(tail, end->head);
}
else {
@@ -3188,7 +3196,7 @@ static int armature_merge_exec (bContext *C, wmOperator *op)
/* check if visible + selected */
if ( EBONE_VISIBLE(arm, ebo) &&
((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) &&
- ((ebo->flag & BONE_SELECTED) || (ebo==arm->act_edbone)) )
+ (ebo->flag & BONE_SELECTED) )
{
/* set either end or start (end gets priority, unless it is already set) */
if (bend == NULL) {
@@ -3518,9 +3526,6 @@ static int armature_extrude_exec(bContext *C, wmOperator *op)
if (totbone==1 && first) arm->act_edbone= first;
if (totbone==0) return OPERATOR_CANCELLED;
-
- if(arm->act_edbone && (((EditBone *)arm->act_edbone)->flag & BONE_SELECTED)==0)
- arm->act_edbone= NULL;
/* Transform the endpoints */
ED_armature_sync_selection(arm->edbo);
@@ -4465,9 +4470,6 @@ void ED_pose_deselectall (Object *ob, int test)
}
}
}
-
- if(arm->act_bone && (arm->act_bone->flag & BONE_SELECTED)==0)
- arm->act_bone= NULL;
}
static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap)
@@ -5174,20 +5176,7 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
if (action == SEL_TOGGLE) {
- bPoseChannel *pchan= CTX_data_active_pose_bone(C);
- int num_sel = CTX_DATA_COUNT(C, selected_pose_bones);
-
- /* cases for deselect:
- * 1) there's only one bone selected, and that is the active one
- * 2) there's more than one bone selected
- */
- if ( ((num_sel == 1) && (pchan) && (pchan->bone->flag & BONE_SELECTED)) ||
- (num_sel > 1) )
- {
- action = SEL_DESELECT;
- }
- else
- action = SEL_SELECT;
+ action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
}
/* Set the flags */
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index 5636b67df9a..e143425036e 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -740,7 +740,7 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld)
}
else if (pchan->bone) {
/* only ok if bone is visible and selected */
- if ( (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone) &&
+ if ( (pchan->bone->flag & BONE_SELECTED) &&
(pchan->bone->flag & BONE_HIDDEN_P)==0 &&
(pchan->bone->layer & arm->layer) )
ok = 1;
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 55d24550167..f1bace1201f 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -164,7 +164,7 @@ void ED_armature_exit_posemode(bContext *C, Base *base)
/* if a selected or active bone is protected, throw error (oonly if warn==1) and return 1 */
/* only_selected==1 : the active bone is allowed to be protected */
-static short pose_has_protected_selected(Object *ob, short only_selected, short warn)
+static short pose_has_protected_selected(Object *ob, short warn)
{
/* check protection */
if (ob->proxy) {
@@ -174,8 +174,7 @@ static short pose_has_protected_selected(Object *ob, short only_selected, short
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
if (pchan->bone && (pchan->bone->layer & arm->layer)) {
if (pchan->bone->layer & arm->layer_protected) {
- if (only_selected && (pchan->bone == arm->act_bone));
- else if (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone)
+ if (pchan->bone->flag & BONE_SELECTED)
break;
}
}
@@ -363,13 +362,12 @@ void POSE_OT_paths_clear (wmOperatorType *ot)
static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_pose_armature(CTX_data_active_object(C));
- bArmature *arm= ob->data;
bConstraint *con;
int found= 0;
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones)
{
- if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
+ if (pchan->bone->flag & BONE_SELECTED) {
for (con= pchan->constraints.first; con; con= con->next) {
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
ListBase targets = {NULL, NULL};
@@ -527,7 +525,7 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend)
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones)
{
/* keep track of group as group to use later? */
- if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone)) {
+ if (pchan->bone->flag & BONE_SELECTED) {
group_flags[pchan->agrp_index] = 1;
tagged= 1;
}
@@ -574,7 +572,7 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend)
CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones)
{
/* keep track of layers to use later? */
- if ((pchan->bone->flag & BONE_SELECTED) || (pchan->bone == arm->act_bone))
+ if (pchan->bone->flag & BONE_SELECTED)
layers |= pchan->bone->layer;
/* deselect all bones before selecting new ones? */
@@ -681,7 +679,7 @@ void pose_copy_menu(Scene *scene)
/* if proxy-protected bones selected, some things (such as locks + displays) shouldn't be changable,
* but for constraints (just add local constraints)
*/
- if (pose_has_protected_selected(ob, 1, 0)) {
+ if (pose_has_protected_selected(ob, 0)) {
i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */
if (i < 25)
nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5");