Cleanup: skip redundant edit-bone select lookups
authorCampbell Barton <ideasman42@gmail.com>
Sun, 15 Apr 2018 19:45:19 +0000 (21:45 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 15 Apr 2018 19:46:25 +0000 (21:46 +0200)
source/blender/editors/armature/armature_edit.c
source/blender/editors/space_view3d/view3d_select.c

index ccbb2e95fc16ef2a74bac1ec939516195dd99c78..4562329706ff595a8a622eec592dea3ce5b5aeee 100644 (file)
@@ -1303,7 +1303,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op))
 {
        bArmature *arm;
        EditBone *curBone, *ebone_next;
-       Object *obedit = CTX_data_edit_object(C); // XXX get from context
+       Object *obedit = CTX_data_edit_object(C);
        bool changed = false;
        arm = obedit->data;
 
index 22ca3beae0a2b4e8a8f7a54f989ecb1c9ecf3f76..d184081b03a6b7dd60bd7348eb6a13c59fa606bd 100644 (file)
@@ -1914,7 +1914,6 @@ static int do_meta_box_select(ViewContext *vc, rcti *rect, bool select, bool ext
 static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool extend)
 {
        bArmature *arm = vc->obedit->data;
-       EditBone *ebone;
        int a;
 
        unsigned int buffer[MAXPICKBUF];
@@ -1923,7 +1922,7 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool
        hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, rect, VIEW3D_SELECT_ALL);
        
        /* clear flag we use to detect point was affected */
-       for (ebone = arm->edbo->first; ebone; ebone = ebone->next)
+       for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next)
                ebone->flag &= ~BONE_DONE;
        
        if (extend == false && select)
@@ -1933,17 +1932,17 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool
        for (a = 0; a < hits; a++) {
                int index = buffer[(4 * a) + 3];
                if (index != -1) {
-                       ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
                        if ((index & 0xFFFF0000) == 0) {
                                continue;
                        }
+                       EditBone *ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
                        if ((select == false) || ((ebone->flag & BONE_UNSELECTABLE) == 0)) {
                                if (index & BONESEL_TIP) {
                                        ebone->flag |= BONE_DONE;
                                        if (select) ebone->flag |= BONE_TIPSEL;
                                        else ebone->flag &= ~BONE_TIPSEL;
                                }
-                               
+
                                if (index & BONESEL_ROOT) {
                                        ebone->flag |= BONE_DONE;
                                        if (select) ebone->flag |= BONE_ROOTSEL;
@@ -1952,27 +1951,30 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool
                        }
                }
        }
-       
+
        /* now we have to flush tag from parents... */
-       for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
+       for (EditBone *ebone = arm->edbo->first; ebone; ebone = ebone->next) {
                if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
-                       if (ebone->parent->flag & BONE_DONE)
+                       if (ebone->parent->flag & BONE_DONE) {
                                ebone->flag |= BONE_DONE;
+                       }
                }
        }
-       
+
        /* only select/deselect entire bones when no points where in the rect */
        for (a = 0; a < hits; a++) {
                int index = buffer[(4 * a) + 3];
                if (index != -1) {
-                       ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
                        if (index & BONESEL_BONE) {
+                               EditBone *ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
                                if ((select == false) || ((ebone->flag & BONE_UNSELECTABLE) == 0)) {
                                        if (!(ebone->flag & BONE_DONE)) {
-                                               if (select)
+                                               if (select) {
                                                        ebone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
-                                               else
+                                               }
+                                               else {
                                                        ebone->flag &= ~(BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED);
+                                               }
                                        }
                                }
                        }