possible fix [#23331] Hidden Bones Contribute to Axis Normal

cant redo this bug but noticed a number of places where bone selection/hidden state isn't being set properly.
This commit is contained in:
Campbell Barton 2010-08-22 10:52:30 +00:00
parent 4e4b797165
commit 2462d4976b
5 changed files with 29 additions and 34 deletions

@ -1130,8 +1130,8 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
* rather than just chopping and adding numbers, * rather than just chopping and adding numbers,
* shave off the end chars until we have a unique name. * shave off the end chars until we have a unique name.
* Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */ * Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */
if (nr==0 && name[left_len]== left[left_len]) { if (nr==0 && name[left_len]== '\0') {
int len = strlen(name)-1; int len = left_len-1;
idtest= is_dupid(lb, id, name); idtest= is_dupid(lb, id, name);
while (idtest && len> 1) { while (idtest && len> 1) {

@ -5275,6 +5275,7 @@ static int hide_selected_pose_bone(Object *ob, Bone *bone, void *ptr)
if (arm->layer & bone->layer) { if (arm->layer & bone->layer) {
if (bone->flag & BONE_SELECTED) { if (bone->flag & BONE_SELECTED) {
bone->flag |= BONE_HIDDEN_P; bone->flag |= BONE_HIDDEN_P;
bone->flag &= ~BONE_SELECTED;
if(arm->act_bone==bone) if(arm->act_bone==bone)
arm->act_bone= NULL; arm->act_bone= NULL;
} }

@ -1554,10 +1554,10 @@ static void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short
void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem) void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *tselem)
{ {
Base *base= (Base *)te->directdata; Base *base= (Base *)te->directdata;
if(base || (base= object_in_scene((Object *)tselem->id, scene))) {
if(base==NULL) base= object_in_scene((Object *)tselem->id, scene); if((base->object->restrictflag ^= OB_RESTRICT_VIEW)) {
if(base) { ED_base_object_select(base, BA_DESELECT);
base->object->restrictflag^=OB_RESTRICT_VIEW; }
} }
} }
@ -1883,8 +1883,8 @@ static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
} }
/* find associated base in current scene */ /* find associated base in current scene */
for(base= FIRSTBASE; base; base= base->next) base= object_in_scene(ob, scene);
if(base->object==ob) break;
if(base) { if(base) {
if(set==2) { if(set==2) {
/* swap select */ /* swap select */
@ -1894,12 +1894,8 @@ static void tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops
ED_base_object_select(base, BA_SELECT); ED_base_object_select(base, BA_SELECT);
} }
else { else {
Base *b;
/* deleselect all */ /* deleselect all */
for(b= FIRSTBASE; b; b= b->next) { scene_deselect_all(scene);
b->flag &= ~SELECT;
b->object->flag= b->flag;
}
ED_base_object_select(base, BA_SELECT); ED_base_object_select(base, BA_SELECT);
} }
if(C) if(C)
@ -4835,7 +4831,6 @@ static void outliner_draw_restrictcols(ARegion *ar, SpaceOops *soops)
static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
{ {
Base *base;
Scene *scene = (Scene *)poin; Scene *scene = (Scene *)poin;
Object *ob = (Object *)poin2; Object *ob = (Object *)poin2;
Object *obedit= CTX_data_edit_object(C); Object *obedit= CTX_data_edit_object(C);
@ -4851,15 +4846,9 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
/* deselect objects that are invisible */ /* deselect objects that are invisible */
if (ob->restrictflag & OB_RESTRICT_VIEW) { if (ob->restrictflag & OB_RESTRICT_VIEW) {
/* Ouch! There is no backwards pointer from Object to Base, /* Ouch! There is no backwards pointer from Object to Base,
* so have to do loop to find it. */ * so have to do loop to find it. */
for(base= FIRSTBASE; base; base= base->next) { ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT);
if(base->object==ob) {
base->flag &= ~SELECT;
base->object->flag= base->flag;
}
}
} }
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
@ -4867,21 +4856,14 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2)
static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2)
{ {
Base *base;
Scene *scene = (Scene *)poin; Scene *scene = (Scene *)poin;
Object *ob = (Object *)poin2; Object *ob = (Object *)poin2;
/* if select restriction has just been turned on */ /* if select restriction has just been turned on */
if (ob->restrictflag & OB_RESTRICT_SELECT) { if (ob->restrictflag & OB_RESTRICT_SELECT) {
/* Ouch! There is no backwards pointer from Object to Base, /* Ouch! There is no backwards pointer from Object to Base,
* so have to do loop to find it. */ * so have to do loop to find it. */
for(base= FIRSTBASE; base; base= base->next) { ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT);
if(base->object==ob) {
base->flag &= ~SELECT;
base->object->flag= base->flag;
}
}
} }
WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
@ -4908,9 +4890,20 @@ static void restrictbutton_modifier_cb(bContext *C, void *poin, void *poin2)
static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2) static void restrictbutton_bone_cb(bContext *C, void *poin, void *poin2)
{ {
Bone *bone= (Bone *)poin2;
if(bone && (bone->flag & BONE_HIDDEN_P))
bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
} }
static void restrictbutton_ebone_cb(bContext *C, void *poin, void *poin2)
{
EditBone *ebone= (EditBone *)poin2;
if(ebone && (ebone->flag & BONE_HIDDEN_A))
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL);
}
static int group_restrict_flag(Group *gr, int flag) static int group_restrict_flag(Group *gr, int flag)
{ {
@ -5195,7 +5188,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
uiBlockSetEmboss(block, UI_EMBOSSN); uiBlockSetEmboss(block, UI_EMBOSSN);
bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF,
(int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone);
bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
(int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
@ -5207,11 +5200,11 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
uiBlockSetEmboss(block, UI_EMBOSSN); uiBlockSetEmboss(block, UI_EMBOSSN);
bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF,
(int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View");
uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone);
bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF,
(int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (short)te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View");
uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL);
} }
} }

@ -647,7 +647,8 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb)
} }
} }
/* sets transform flags in the bones, returns total */ /* sets transform flags in the bones
* returns total number of bones with BONE_TRANSFORM */
int count_set_pose_transflags(int *out_mode, short around, Object *ob) int count_set_pose_transflags(int *out_mode, short around, Object *ob)
{ {
bArmature *arm= ob->data; bArmature *arm= ob->data;

@ -288,7 +288,7 @@ int calc_manipulator_stats(const bContext *C)
bArmature *arm= obedit->data; bArmature *arm= obedit->data;
EditBone *ebo; EditBone *ebo;
for (ebo= arm->edbo->first; ebo; ebo=ebo->next){ for (ebo= arm->edbo->first; ebo; ebo=ebo->next){
if(ebo->layer & arm->layer) { if(ebo->layer & arm->layer && !(ebo->flag & BONE_HIDDEN_A)) {
if (ebo->flag & BONE_TIPSEL) { if (ebo->flag & BONE_TIPSEL) {
calc_tw_center(scene, ebo->tail); calc_tw_center(scene, ebo->tail);
totsel++; totsel++;