fix [#24499] Consistency Issue with LassoSelect/ExtendOption
authorCampbell Barton <ideasman42@gmail.com>
Wed, 3 Nov 2010 01:56:02 +0000 (01:56 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 3 Nov 2010 01:56:02 +0000 (01:56 +0000)
Added extend option to lasso.

also...
- selecting bones wasn't checking their layer of if they were hidden in a number of places.
- fixed memory leak.

small unrealed changes
- added PBONE_VISIBLE macro
- renamed functions used for paint selectoin from *_tface to paintface_*. sine they no longer have anything todo with tface's.
- removed scanfill include from BLI_blenlib.h, this is only used in very few places and quite specific.

Noticed lasso select is broken for metaballs and face mask mode but this has been the case for a while, will look into it next.

21 files changed:
source/blender/blenkernel/BKE_armature.h
source/blender/blenkernel/intern/displist.c
source/blender/blenlib/BLI_blenlib.h
source/blender/editors/armature/editarmature.c
source/blender/editors/armature/poseobject.c
source/blender/editors/include/ED_armature.h
source/blender/editors/include/ED_mesh.h
source/blender/editors/include/ED_particle.h
source/blender/editors/mesh/editface.c
source/blender/editors/mesh/editmesh_tools.c
source/blender/editors/physics/particle_edit.c
source/blender/editors/screen/screen_context.c
source/blender/editors/sculpt_paint/paint_utils.c
source/blender/editors/space_outliner/outliner.c
source/blender/editors/space_view3d/drawarmature.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform_conversions.c
source/blender/editors/transform/transform_manipulator.c
source/creator/CMakeLists.txt
source/creator/creator.c

index 06e24431df4be3b1cd9cf465391ecbe3b4e7c2c1..eacb61d122c1d594255c5d57bc0f67d100251aec 100644 (file)
@@ -119,6 +119,10 @@ typedef struct Mat4 {
 
 Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan, int rest);
 
+/* like EBONE_VISIBLE */
+#define PBONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P))
+#define _BONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P))
+
 #ifdef __cplusplus
 }
 #endif
index d1830cb8243d67526fafdb9f0c995775b4b404ac..a8032f5a40dfdedf002fa2b5ca389f4db98bf3ab 100644 (file)
@@ -45,6 +45,7 @@
 #include "BLI_blenlib.h"
 #include "BLI_math.h"
 #include "BLI_editVert.h"
+#include "BLI_scanfill.h"
 
 #include "BKE_global.h"
 #include "BKE_displist.h"
index 3028161734c609e4fad37af1006d0331355eeb0b..8423c07e7c9019b2dac7f7806bf2f62d79f795ee 100644 (file)
@@ -84,8 +84,6 @@ extern "C" {
 
 #include "BLI_rect.h"
 
-#include "BLI_scanfill.h"
-
 #include "BLI_noise.h"
 
 /**
index 0be27e943f462c8b0dcce7ff6962b820ffeca066..cab2fdc547fe8cc52c9c89469e7bcda94677983a 100644 (file)
@@ -1359,8 +1359,9 @@ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_
        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))
+                               if ((arm->layer & curbone->layer) && !(pabone->flag & BONE_HIDDEN_A)) {
                                        chbone = curbone;
+                               }
                        }
                        else
                                chbone = curbone;
@@ -1887,7 +1888,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot)
  * toggle==2: only active tag
  * toggle==3: swap (no test)
  */
-void ED_armature_deselectall(Object *obedit, int toggle)
+void ED_armature_deselect_all(Object *obedit, int toggle)
 {
        bArmature *arm= obedit->data;
        EditBone        *eBone;
@@ -1914,7 +1915,7 @@ void ED_armature_deselectall(Object *obedit, int toggle)
                for (eBone=arm->edbo->first;eBone;eBone=eBone->next) {
                        if (sel==3) {
                                /* invert selection of bone */
-                               if ((arm->layer & eBone->layer) && (eBone->flag & BONE_HIDDEN_A)==0) {
+                               if(EBONE_VISIBLE(arm, eBone)) {
                                        eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
                                        if(arm->act_edbone==eBone)
                                                arm->act_edbone= NULL;
@@ -1922,7 +1923,7 @@ void ED_armature_deselectall(Object *obedit, int toggle)
                        }
                        else if (sel==1) {
                                /* select bone */
-                               if(arm->layer & eBone->layer && (eBone->flag & BONE_HIDDEN_A)==0) {
+                               if(EBONE_VISIBLE(arm, eBone)) {
                                        eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
                                        if(eBone->parent)
                                                eBone->parent->flag |= (BONE_TIPSEL);
@@ -1940,6 +1941,20 @@ void ED_armature_deselectall(Object *obedit, int toggle)
        ED_armature_sync_selection(arm->edbo);
 }
 
+void ED_armature_deselect_all_visible(Object *obedit)
+{
+       bArmature *arm= obedit->data;
+       EditBone        *ebone;
+
+       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) {
+                       ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
+               }
+       }
+
+       ED_armature_sync_selection(arm->edbo);
+}
 
 /* context: editmode armature in view3d */
 int mouse_armature(bContext *C, short mval[2], int extend)
@@ -1958,7 +1973,7 @@ int mouse_armature(bContext *C, short mval[2], int extend)
        if (nearBone) {
 
                if (!extend)
-                       ED_armature_deselectall(obedit, 0);
+                       ED_armature_deselect_all(obedit, 0);
                
                /* by definition the non-root connected bones have no root point drawn,
                   so a root selection needs to be delivered to the parent tip */
@@ -2355,7 +2370,7 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d)
        mul_m3_m3m3(totmat, obmat, viewmat);
        invert_m3_m3(imat, totmat);
        
-       ED_armature_deselectall(obedit, 0);
+       ED_armature_deselect_all(obedit, 0);
        
        /*      Create a bone   */
        bone= ED_armature_edit_bone_add(obedit->data, "Bone");
@@ -2408,7 +2423,7 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op))
                to_root= 1;
        }
        
-       ED_armature_deselectall(obedit, 0);
+       ED_armature_deselect_all(obedit, 0);
        
        /* we re-use code for mirror editing... */
        flipbone= NULL;
@@ -3575,7 +3590,7 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op)
        mul_m3_m3m3(totmat, obmat, viewmat);
        invert_m3_m3(imat, totmat);
        
-       ED_armature_deselectall(obedit, 0);
+       ED_armature_deselect_all(obedit, 0);
        
        /*      Create a bone   */
        bone= ED_armature_edit_bone_add(obedit->data, name);
@@ -4441,7 +4456,7 @@ void ED_pose_deselectall (Object *ob, int test)
        /*      Determine if we're selecting or deselecting     */
        if (test==1) {
                for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-                       if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+                       if (PBONE_VISIBLE(arm, pchan->bone)) {
                                if (pchan->bone->flag & BONE_SELECTED)
                                        break;
                        }
index 217a83c3b319bd4e7a207d7a6df0eee05ccc9c24..1bfbe869e6b2a28fd6936b46fa7df7cbd94d3474 100644 (file)
@@ -439,7 +439,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
                                        if (pchan->parent == NULL) continue;
                                        else pabone= pchan->parent->bone;
                                        
-                                       if ((arm->layer & pabone->layer) && !(pabone->flag & BONE_HIDDEN_P)) {
+                                       if (PBONE_VISIBLE(arm, pabone)) {
                                                if (!add_to_sel) curbone->flag &= ~BONE_SELECTED;
                                                pabone->flag |= BONE_SELECTED;
                                                arm->act_bone= pabone;
@@ -452,7 +452,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op)
                                        if (pchan->child == NULL) continue;
                                        else chbone = pchan->child->bone;
                                        
-                                       if ((arm->layer & chbone->layer) && !(chbone->flag & BONE_HIDDEN_P)) {
+                                       if (PBONE_VISIBLE(arm, chbone)) {
                                                if (!add_to_sel) curbone->flag &= ~BONE_SELECTED;
                                                chbone->flag |= BONE_SELECTED;
                                                arm->act_bone= chbone;
index 32fe10783a77493dd024f8eda715cc9eea9d65a1..3e16cae5527e096bdbe3a6deb02fa5ed7861b352 100644 (file)
@@ -91,8 +91,8 @@ typedef struct EditBone
 #define BONESEL_NOSEL  (1<<31) /* Indicates a negative number */
 
 /* useful macros */
-#define EBONE_VISIBLE(arm, ebone) ((arm->layer & ebone->layer) && !(ebone->flag & BONE_HIDDEN_A))
-#define EBONE_EDITABLE(ebone) ((ebone->flag & BONE_SELECTED) && !(ebone->flag & BONE_EDITMODE_LOCKED)) 
+#define EBONE_VISIBLE(arm, ebone) (((arm)->layer & (ebone)->layer) && !((ebone)->flag & BONE_HIDDEN_A))
+#define EBONE_EDITABLE(ebone) (((ebone)->flag & BONE_SELECTED) && !((ebone)->flag & BONE_EDITMODE_LOCKED)) 
 
 /* used in bone_select_hierachy() */
 #define BONE_SELECT_PARENT     0
@@ -107,7 +107,8 @@ void ED_keymap_armature(struct wmKeyConfig *keyconf);
 void ED_armature_from_edit(struct Object *obedit);
 void ED_armature_to_edit(struct Object *ob);
 void ED_armature_edit_free(struct Object *ob);
-void ED_armature_deselectall(struct Object *obedit, int toggle);
+void ED_armature_deselect_all(struct Object *obedit, int toggle);
+void ED_armature_deselect_all_visible(struct Object *obedit);
 
 int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer, 
                                                        short hits, short extend);
index 22779fbba0b9a83fedd93f97c84fde6b987a16e3..cf0334ce6b35cd368944edbb79d89dd0acfd1dbe 100644 (file)
@@ -181,12 +181,13 @@ void              EM_deselect_by_material(struct EditMesh *em, int index);
 void           EM_automerge(struct Scene *scene, struct Object *obedit, int update);
 
 /* editface.c */
+void paintface_flush_flags(struct Object *ob);
 struct MTFace  *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloppy);
-int face_select(struct bContext *C, struct Object *ob, short mval[2], int extend);
-void face_borderselect(struct bContext *C, struct Object *ob, struct rcti *rect, int select, int extend);
-void selectall_tface(struct Object *ob, int action);
-void select_linked_tfaces(struct bContext *C, struct Object *ob, short mval[2], int mode);
-int minmax_tface(struct Object *ob, float *min, float *max);
+int paintface_mouse_select(struct bContext *C, struct Object *ob, short mval[2], int extend);
+int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int select, int extend);
+void paintface_deselect_all_visible(struct Object *ob, int action, short flush_flags);
+void paintface_select_linked(struct bContext *C, struct Object *ob, short mval[2], int mode);
+int paintface_minmax(struct Object *ob, float *min, float *max);
 
 /* object_vgroup.c */
 
index 87aa7ca91956b53d968f1685f15d2906076e0f3c..f3b65b343efd27b8d5002da33d9c478cd85ecbf8 100644 (file)
@@ -59,7 +59,8 @@ void PE_update_object(struct Scene *scene, struct Object *ob, int useflag);
 int PE_mouse_particles(struct bContext *C, short *mval, int extend);
 int PE_border_select(struct bContext *C, struct rcti *rect, int select, int extend);
 int PE_circle_select(struct bContext *C, int selecting, short *mval, float rad);
-int PE_lasso_select(struct bContext *C, short mcords[][2], short moves, short select);
+int PE_lasso_select(struct bContext *C, short mcords[][2], short moves, short extend, short select);
+void PE_deselect_all_visible(struct PTCacheEdit *edit);
 
 /* undo */
 void PE_undo_push(struct Scene *scene, char *str);
index 81e19e5db3f104e1f99e4a41615ae7dd617d079e..b34f024e9fb1dd7751cb45153533f13ad3b1f939 100644 (file)
 /* own include */
 #include "mesh_intern.h"
 
-/* ***************** XXX **************** */
-static int pupmenu(const char *UNUSED(dummy)) {return 0;}
-/* ***************** XXX **************** */
-
-
 /* copy the face flags, most importantly selection from the mesh to the final derived mesh,
  * use in object mode when selecting faces (while painting) */
-void object_facesel_flush_dm(Object *ob)
+void paintface_flush_flags(Object *ob)
 {
        Mesh *me= get_mesh(ob);
        DerivedMesh *dm= ob->derivedFinal;
@@ -162,7 +157,7 @@ MTFace *EM_get_active_mtface(EditMesh *em, EditFace **act_efa, MCol **mcol, int
        return NULL;
 }
 
-void reveal_tface(Scene *scene)
+void paintface_unhide(Scene *scene)
 {
        Mesh *me;
        MFace *mface;
@@ -181,11 +176,10 @@ void reveal_tface(Scene *scene)
                mface++;
        }
 
-       object_facesel_flush_dm(OBACT);
-// XXX notifier!       object_tface_flags_changed(OBACT, 0);
+       paintface_flush_flags(OBACT);
 }
 
-void hide_tface(Scene *scene)
+void paintface_hide(Scene *scene)
 {
        Mesh *me;
        MFace *mface;
@@ -196,7 +190,7 @@ void hide_tface(Scene *scene)
        if(me==0 || me->totface==0) return;
        
        if(alt) {
-               reveal_tface(scene);
+               paintface_unhide(scene);
                return;
        }
        
@@ -217,8 +211,7 @@ void hide_tface(Scene *scene)
                mface++;
        }
        
-       object_facesel_flush_dm(OBACT);
-// XXX notifier!               object_tface_flags_changed(OBACT, 0);
+       paintface_flush_flags(OBACT);
 }
 
 /* Set tface seams based on edge data, uses hash table to find seam edges. */
@@ -236,7 +229,7 @@ static void hash_add_face(EdgeHash *ehash, MFace *mf)
 }
 
 
-void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
+static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
 {
        MFace *mf;
        int a, doit=1, mark=0;
@@ -338,12 +331,9 @@ void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int index)
        }
 
        MEM_freeN(linkflag);
-
-       // BIF_undo_push("Select linked UV face");
-       // object_tface_flags_changed(OBACT, 0);
 }
 
-void select_linked_tfaces(bContext *UNUSED(C), Object *ob, short UNUSED(mval[2]), int mode)
+void paintface_select_linked(bContext *UNUSED(C), Object *ob, short UNUSED(mval[2]), int mode)
 {
        Mesh *me;
        unsigned int index=0;
@@ -361,10 +351,11 @@ void select_linked_tfaces(bContext *UNUSED(C), Object *ob, short UNUSED(mval[2])
 
        select_linked_tfaces_with_seams(mode, me, index);
 
-       object_facesel_flush_dm(ob);
+       paintface_flush_flags(ob);
 }
 
-void selectall_tface(Object *ob, int action)
+/* note: caller needs to run paintface_flush_flags(ob) after this */
+void paintface_deselect_all_visible(Object *ob, int action, short flush_flags)
 {
        Mesh *me;
        MFace *mface;
@@ -406,11 +397,12 @@ void selectall_tface(Object *ob, int action)
                mface++;
        }
 
-       object_facesel_flush_dm(ob);
-// XXX notifier!               object_tface_flags_changed(OBACT, 0);
+       if(flush_flags) {
+               paintface_flush_flags(ob);
+       }
 }
 
-void selectswap_tface(Scene *scene)
+void paintface_select_swap(Scene *scene)
 {
        Mesh *me;
        MFace *mface;
@@ -430,11 +422,10 @@ void selectswap_tface(Scene *scene)
                mface++;
        }
        
-       object_facesel_flush_dm(OBACT);
-// XXX notifier!               object_tface_flags_changed(OBACT, 0);
+       paintface_flush_flags(OBACT);
 }
 
-int minmax_tface(Object *ob, float *min, float *max)
+int paintface_minmax(Object *ob, float *min, float *max)
 {
        Mesh *me= get_mesh(ob);
        MFace *mf;
@@ -672,7 +663,7 @@ int edgetag_shortest_path(Scene *scene, EditMesh *em, EditEdge *source, EditEdge
 }
 
 /* *************************************** */
-
+#if 0
 static void seam_edgehash_insert_face(EdgeHash *ehash, MFace *mf)
 {
        BLI_edgehash_insert(ehash, mf->v1, mf->v2, NULL);
@@ -739,11 +730,10 @@ void seam_mark_clear_tface(Scene *scene, short mode)
 //             unwrap_lscm(1);
 
        me->drawflag |= ME_DRAWSEAMS;
-
-// XXX notifier!               object_tface_flags_changed(OBACT, 1);
 }
+#endif
 
-int face_select(struct bContext *C, Object *ob, short mval[2], int extend)
+int paintface_mouse_select(struct bContext *C, Object *ob, short mval[2], int extend)
 {
        Mesh *me;
        MFace *mface, *msel;
@@ -780,48 +770,38 @@ int face_select(struct bContext *C, Object *ob, short mval[2], int extend)
        
        /* image window redraw */
        
-       object_facesel_flush_dm(ob);
-// XXX notifier!               object_tface_flags_changed(OBACT, 1);
+       paintface_flush_flags(ob);
        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
        ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
        return 1;
 }
 
-void face_borderselect(struct bContext *C, Object *ob, rcti *rect, int select, int extend)
+int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
 {
        Mesh *me;
        MFace *mface;
        struct ImBuf *ibuf;
        unsigned int *rt;
-       int a, sx, sy, index;
+       int a, index;
        char *selar;
-       
-       ViewContext vc;
-       view3d_set_viewcontext(C, &vc);
+       int sx= rect->xmax-rect->xmin+1;
+       int sy= rect->ymax-rect->ymin+1;
 
-       me= get_mesh(ob);
-       if(me==0) return;
-       if(me->totface==0) return;
+       me= get_mesh(vc->obact);
+
+       if(me==NULL || me->totface==0 || sx*sy <= 0)
+               return OPERATOR_CANCELLED;
 
        selar= MEM_callocN(me->totface+1, "selar");
 
-       sx= (rect->xmax-rect->xmin+1);
-       sy= (rect->ymax-rect->ymin+1);
-       if(sx*sy<=0) return;
+       if (extend == 0 && select)
+               paintface_deselect_all_visible(vc->obact, SEL_DESELECT, FALSE);
 
-       if (extend == 0 && select) {
-               mface= me->mface;
-               for(a=1; a<=me->totface; a++, mface++) {
-                       if((mface->flag & ME_HIDE) == 0)
-                               mface->flag &= ~ME_FACE_SEL;
-               }
-       }
-
-       view3d_validate_backbuf(&vc);
+       view3d_validate_backbuf(vc);
 
        ibuf = IMB_allocImBuf(sx,sy,32,IB_rect);
        rt = ibuf->rect;
-       glReadPixels(rect->xmin+vc.ar->winrct.xmin,  rect->ymin+vc.ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE,  ibuf->rect);
+       glReadPixels(rect->xmin+vc->ar->winrct.xmin,  rect->ymin+vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE,  ibuf->rect);
        if(ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
 
        a= sx*sy;
@@ -847,11 +827,11 @@ void face_borderselect(struct bContext *C, Object *ob, rcti *rect, int select, i
        IMB_freeImBuf(ibuf);
        MEM_freeN(selar);
 
-
-// XXX notifier!                       object_tface_flags_changed(OBACT, 0);
 #ifdef __APPLE__       
        glReadBuffer(GL_BACK);
 #endif
-       
-       object_facesel_flush_dm(ob);
+
+       paintface_flush_flags(vc->obact);
+
+       return OPERATOR_FINISHED;
 }
index 7fbdef7b39105fa213f3974ef3ff3d77f8b03237..eb450c7434bab7438473332bc7830ffe61002865 100644 (file)
@@ -57,6 +57,7 @@ editmesh_tool.c: UI called tools for editmesh, geometry changes here, otherwise
 #include "BLI_ghash.h"
 #include "BLI_linklist.h"
 #include "BLI_heap.h"
+#include "BLI_scanfill.h"
 
 #include "BKE_context.h"
 #include "BKE_depsgraph.h"
index fed4b8d9722d3bce9e3466e0ae6c2c90b87da693..e654b868622f1ee50960ee32c133c6f252236751 100644 (file)
@@ -1513,6 +1513,17 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot)
 }
 
 /************************ border select operator ************************/
+void PE_deselect_all_visible(PTCacheEdit *edit)
+{
+       POINT_P; KEY_K;
+
+       LOOP_VISIBLE_POINTS {
+               LOOP_SELECTED_KEYS {
+                       key->flag &= ~PEK_SELECT;
+                       point->flag |= PEP_EDIT_RECALC;
+               }
+       }
+}
 
 int PE_border_select(bContext *C, rcti *rect, int select, int extend)
 {
@@ -1524,16 +1535,8 @@ int PE_border_select(bContext *C, rcti *rect, int select, int extend)
        if(!PE_start_edit(edit))
                return OPERATOR_CANCELLED;
 
-       if (extend == 0 && select) {
-               POINT_P; KEY_K;
-
-               LOOP_VISIBLE_POINTS {
-                       LOOP_SELECTED_KEYS {
-                               key->flag &= ~PEK_SELECT;
-                               point->flag |= PEP_EDIT_RECALC;
-                       }
-               }
-       }
+       if (extend == 0 && select)
+               PE_deselect_all_visible(edit);
 
        PE_set_view3d_data(C, &data);
        data.rect= rect;
@@ -1574,7 +1577,7 @@ int PE_circle_select(bContext *C, int selecting, short *mval, float rad)
 
 /************************ lasso select operator ************************/
 
-int PE_lasso_select(bContext *C, short mcords[][2], short moves, short select)
+int PE_lasso_select(bContext *C, short mcords[][2], short moves, short extend, short select)
 {
        Scene *scene= CTX_data_scene(C);
        Object *ob= CTX_data_active_object(C);
@@ -1590,6 +1593,9 @@ int PE_lasso_select(bContext *C, short mcords[][2], short moves, short select)
        if(!PE_start_edit(edit))
                return OPERATOR_CANCELLED;
 
+       if (extend == 0 && select)
+               PE_deselect_all_visible(edit);
+       
        unit_m4(mat);
 
        LOOP_VISIBLE_POINTS {
index 08cc8ebaa2f6a5a5d6dae9969ba2672f5016684a..08962883ec31249b37098edcfb25761d37621dba 100644 (file)
@@ -36,6 +36,7 @@
 #include "BKE_context.h"
 #include "BKE_utildefines.h"
 #include "BKE_action.h"
+#include "BKE_armature.h"
 #include "BKE_sequencer.h"
 
 #include "RNA_access.h"
@@ -234,7 +235,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
                if (obpose && obpose->pose && arm) {
                        for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) {
                                /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
-                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+                               if (PBONE_VISIBLE(arm, pchan->bone)) {
                                        CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
                                }
                        }
@@ -250,7 +251,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
                if (obpose && obpose->pose && arm) {
                        for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) {
                                /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */
-                               if ((pchan->bone) && (arm->layer & pchan->bone->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+                               if (PBONE_VISIBLE(arm, pchan->bone)) {
                                        if (pchan->bone->flag & BONE_SELECTED || pchan->bone == arm->act_bone)
                                                CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan);
                                }
index e3a486a0feec121df6afe5328365cbbcd0950310..6e158fe2e66351951b27b9c34f9c0e6b097757c7 100644 (file)
@@ -235,7 +235,7 @@ void BRUSH_OT_curve_preset(wmOperatorType *ot)
 /* face-select ops */
 static int paint_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
 {
-       select_linked_tfaces(C, CTX_data_active_object(C), NULL, 2);
+       paintface_select_linked(C, CTX_data_active_object(C), NULL, 2);
        ED_region_tag_redraw(CTX_wm_region(C));
        return OPERATOR_FINISHED;
 }
@@ -255,7 +255,7 @@ void PAINT_OT_face_select_linked(wmOperatorType *ot)
 static int paint_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        int mode= RNA_boolean_get(op->ptr, "extend") ? 1:0;
-       select_linked_tfaces(C, CTX_data_active_object(C), event->mval, mode);
+       paintface_select_linked(C, CTX_data_active_object(C), event->mval, mode);
        ED_region_tag_redraw(CTX_wm_region(C));
        return OPERATOR_FINISHED;
 }
@@ -277,7 +277,8 @@ void PAINT_OT_face_select_linked_pick(wmOperatorType *ot)
 
 static int face_select_all_exec(bContext *C, wmOperator *op)
 {
-       selectall_tface(CTX_data_active_object(C), RNA_enum_get(op->ptr, "action"));
+       Object *ob= CTX_data_active_object(C);
+       paintface_deselect_all_visible(ob, RNA_enum_get(op->ptr, "action"), TRUE);
        ED_region_tag_redraw(CTX_wm_region(C));
        return OPERATOR_FINISHED;
 }
index 1f0725c5458c73cc51e08423b52aadc2ddfda157..f73da37e1efc80e27985cfe20d6d1968b7cc1e43 100644 (file)
@@ -2211,8 +2211,8 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te,
        if(set) {
                if(!(ebone->flag & BONE_HIDDEN_A)) {
                        bArmature *arm= scene->obedit->data;
-                       if(set==2) ED_armature_deselectall(scene->obedit, 2);   // only clear active tag
-                       else ED_armature_deselectall(scene->obedit, 0); // deselect
+                       if(set==2) ED_armature_deselect_all(scene->obedit, 2);  // only clear active tag
+                       else ED_armature_deselect_all(scene->obedit, 0);        // deselect
 
                        ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL;
                        arm->act_edbone= ebone;
index 33776abf4a09b669ac855b4a8ee20755f23e3be8..8cfb11478be9984907bbff9e504430d0a8d79486 100644 (file)
@@ -1979,7 +1979,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
                                        
                                        /* catch exception for bone with hidden parent */
                                        flag= eBone->flag;
-                                       if ( (eBone->parent) && ((eBone->parent->flag & BONE_HIDDEN_A) || (eBone->parent->layer & arm->layer)==0) )
+                                       if ( (eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent))
                                                flag &= ~BONE_CONNECTED;
                                                
                                        /* set temporary flag for drawing bone as active, but only if selected */
@@ -2018,7 +2018,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, int dt)
                                
                                /* catch exception for bone with hidden parent */
                                flag= eBone->flag;
-                               if ( (eBone->parent) && ((eBone->parent->flag & BONE_HIDDEN_A) || (eBone->parent->layer & arm->layer)==0) )
+                               if ( (eBone->parent) && !EBONE_VISIBLE(arm, eBone->parent))
                                        flag &= ~BONE_CONNECTED;
                                        
                                /* set temporary flag for drawing bone as active, but only if selected */
index a70774f27cea4b790edf4f50e2c60aae9933a872..d706dc27404e5286bbb43f1a118ed00b3d41159c 100644 (file)
@@ -1432,7 +1432,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca
                }
        }
        else if (paint_facesel_test(ob)) {
-               ok= minmax_tface(ob, min, max);
+               ok= paintface_minmax(ob, min, max);
        }
        else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT)) {
                ok= PE_minmax(scene, min, max);
index e3212e8a3d1e12a162958af0161425c8c6cc6920..bfc24e80f4c7335d1bd97ccb7d948a96c08127fb 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <math.h>
 #include <float.h>
+#include <assert.h>
 
 #include "DNA_armature_types.h"
 #include "DNA_curve_types.h"
@@ -48,6 +49,7 @@
 
 #include "BKE_context.h"
 #include "BKE_paint.h"
+#include "BKE_armature.h"
 
 
 #include "BIF_gl.h"
@@ -345,18 +347,21 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, short mcords[][2],
        bPoseChannel *pchan;
        float vec[3];
        short sco1[2], sco2[2];
+       bArmature *arm= ob->data;
        
        if(ob->type!=OB_ARMATURE || ob->pose==NULL) return;
-       
+
        for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
-               mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
-               project_short(vc->ar, vec, sco1);
-               mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
-               project_short(vc->ar, vec, sco2);
-               
-               if(lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
-                       if(select) pchan->bone->flag |= BONE_SELECTED;
-                       else pchan->bone->flag &= ~BONE_SELECTED;
+               if (PBONE_VISIBLE(arm, pchan->bone) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) {
+                       mul_v3_m4v3(vec, ob->obmat, pchan->pose_head);
+                       project_short(vc->ar, vec, sco1);
+                       mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail);
+                       project_short(vc->ar, vec, sco2);
+                       
+                       if(lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
+                               if(select) pchan->bone->flag |= BONE_SELECTED;
+                               else pchan->bone->flag &= ~BONE_SELECTED;
+                       }
                }
        }
        
@@ -368,11 +373,24 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, short mcords[][2],
        }
 }
 
+static void object_deselect_all_visible(Scene *scene, View3D *v3d)
+{
+       Base *base;
 
-static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short moves, short select)
+       for(base= scene->base.first; base; base= base->next) {
+               if(BASE_SELECTABLE(v3d, base)) {
+                       ED_base_object_select(base, BA_DESELECT);
+               }
+       }
+}
+
+static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short moves, short extend, short select)
 {
        Base *base;
        
+       if (extend == 0 && select)
+               object_deselect_all_visible(vc->scene, vc->v3d);
+
        for(base= vc->scene->base.first; base; base= base->next) {
                if(BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */
                        project_short(vc->ar, base->object->obmat[3], &base->sx);
@@ -389,7 +407,7 @@ static void do_lasso_select_objects(ViewContext *vc, short mcords[][2], short mo
        }
 }
 
-void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves)
+static void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves)
 {
        short a;
        
@@ -440,7 +458,7 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, EditFace *efa, in
        }
 }
 
-static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves, short select)
+static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves, short extend, short select)
 {
        struct { ViewContext vc; rcti *rect; short (*mcords)[2], moves, select, pass, done; } data;
        ToolSettings *ts= vc->scene->toolsettings;
@@ -460,8 +478,11 @@ static void do_lasso_select_mesh(ViewContext *vc, short mcords[][2], short moves
        data.done = 0;
        data.pass = 0;
 
+       if (extend == 0 && select)
+               EM_deselect_all(vc->em);
+
        /* workaround: init mats first, EM_mask_init_backbuf_border can change
-          view matrix to pixel space, breaking edge select with backbuf. fixes bug #20936 */
+          view matrix to pixel space, breaking edge select with backbuf. fixes bug [#20936] */
 
        /* [#21018] breaks zbuf select. run below. only if bbsel fails */
        /* ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d) */
@@ -589,7 +610,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP
        }
 }
 
-static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short moves, short select)
+static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short moves, short extend, short select)
 {
        struct { ViewContext *vc; short (*mcords)[2]; short moves; short select; } data;
 
@@ -599,6 +620,9 @@ static void do_lasso_select_curve(ViewContext *vc, short mcords[][2], short move
        data.moves = moves;
        data.select = select;
 
+       if (extend == 0 && select)
+               CU_deselect_all(vc->obedit);
+
        ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
        nurbs_foreachScreenVert(vc, do_lasso_select_curve__doSelect, &data);
 }
@@ -611,7 +635,7 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x,
                bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
        }
 }
-static void do_lasso_select_lattice(ViewContext *vc, short mcords[][2], short moves, short select)
+static void do_lasso_select_lattice(ViewContext *vc, short mcords[][2], short moves, short extend, short select)
 {
        struct { short (*mcords)[2]; short moves; short select; } data;
 
@@ -620,45 +644,52 @@ static void do_lasso_select_lattice(ViewContext *vc, short mcords[][2], short mo
        data.moves = moves;
        data.select = select;
 
+       if (extend == 0 && select)
+               ED_setflagsLatt(vc->obedit, 0);
+
        ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
        lattice_foreachScreenVert(vc, do_lasso_select_lattice__doSelect, &data);
 }
 
-static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short moves, short select)
+static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short moves, short extend, short select)
 {
        bArmature *arm= vc->obedit->data;
        EditBone *ebone;
        float vec[3];
        short sco1[2], sco2[2], didpoint;
        int change= FALSE;
-       
+
+       if (extend==0 && select)
+               ED_armature_deselect_all_visible(vc->obedit);
+
        /* set editdata in vc */
        
        for (ebone= arm->edbo->first; ebone; ebone=ebone->next) {
-
-               mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head);
-               project_short(vc->ar, vec, sco1);
-               mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail);
-               project_short(vc->ar, vec, sco2);
-               
-               didpoint= 0;
-               if(lasso_inside(mcords, moves, sco1[0], sco1[1])) {
-                       if(select) ebone->flag |= BONE_ROOTSEL;
-                       else ebone->flag &= ~BONE_ROOTSEL;
-                       didpoint= 1;
-                       change= TRUE;
-               }
-               if(lasso_inside(mcords, moves, sco2[0], sco2[1])) {
-                  if(select) ebone->flag |= BONE_TIPSEL;
-                  else ebone->flag &= ~BONE_TIPSEL;
-                  didpoint= 1;
-                  change= TRUE;
-               }
-               /* if one of points selected, we skip the bone itself */
-               if(didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
-                       if(select) ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED;
-                       else ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
-                       change= TRUE;
+               if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE)==0) {
+                       mul_v3_m4v3(vec, vc->obedit->obmat, ebone->head);
+                       project_short(vc->ar, vec, sco1);
+                       mul_v3_m4v3(vec, vc->obedit->obmat, ebone->tail);
+                       project_short(vc->ar, vec, sco2);
+                       
+                       didpoint= 0;
+                       if(lasso_inside(mcords, moves, sco1[0], sco1[1])) {
+                               if(select) ebone->flag |= BONE_ROOTSEL;
+                               else ebone->flag &= ~BONE_ROOTSEL;
+                               didpoint= 1;
+                               change= TRUE;
+                       }
+                       if(lasso_inside(mcords, moves, sco2[0], sco2[1])) {
+                          if(select) ebone->flag |= BONE_TIPSEL;
+                          else ebone->flag &= ~BONE_TIPSEL;
+                          didpoint= 1;
+                          change= TRUE;
+                       }
+                       /* if one of points selected, we skip the bone itself */
+                       if(didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) {
+                               if(select) ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED;
+                               else ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
+                               change= TRUE;
+                       }
                }
        }
        
@@ -669,25 +700,28 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m
        }
 }
 
-static void do_lasso_select_facemode(ViewContext *vc, short mcords[][2], short moves, short select)
+static void do_lasso_select_paintface(ViewContext *vc, short mcords[][2], short moves, short extend, short select)
 {
        Object *ob= vc->obact;
        Mesh *me= ob?ob->data:NULL;
        rcti rect;
        
-       if(me==NULL || me->mtface==NULL) return;
-       if(me->totface==0) return;
-       
+       if(me==NULL || me->mtface==NULL || me->totface)
+               return;
+
+       if(extend==0 && select)
+               paintface_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */
+
        em_vertoffs= me->totface+1;     /* max index array */
-       
+
        lasso_select_boundbox(&rect, mcords, moves);
        EM_mask_init_backbuf_border(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
        
        EM_backbuf_checkAndSelectTFaces(me, select);
-       
+
        EM_free_backbuf();
-       
-// XXX object_tface_flags_changed(ob, 0);
+
+       paintface_flush_flags(ob);
 }
 
 #if 0
@@ -721,31 +755,31 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select)
 }
 #endif
 
-void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short select)
+static void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short extend, short select)
 {
        Object *ob = CTX_data_active_object(C);
 
        if(vc->obedit==NULL) { /* Object Mode */
                if(paint_facesel_test(ob))
-                       do_lasso_select_facemode(vc, mcords, moves, select);
+                       do_lasso_select_paintface(vc, mcords, moves, extend, select);
                else if(ob && ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))
                        ;
                else if(ob && ob->mode & OB_MODE_PARTICLE_EDIT)
-                       PE_lasso_select(C, mcords, moves, select);
+                       PE_lasso_select(C, mcords, moves, extend, select);
                else {
-                       do_lasso_select_objects(vc, mcords, moves, select);
+                       do_lasso_select_objects(vc, mcords, moves, extend, select);
                        WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, vc->scene);
                }
        }
        else { /* Edit Mode */
                if(vc->obedit->type==OB_MESH)
-                       do_lasso_select_mesh(vc, mcords, moves, select);
+                       do_lasso_select_mesh(vc, mcords, moves, extend, select);
                else if(vc->obedit->type==OB_CURVE || vc->obedit->type==OB_SURF) 
-                       do_lasso_select_curve(vc, mcords, moves, select);
+                       do_lasso_select_curve(vc, mcords, moves, extend, select);
                else if(vc->obedit->type==OB_LATTICE) 
-                       do_lasso_select_lattice(vc, mcords, moves, select);
+                       do_lasso_select_lattice(vc, mcords, moves, extend, select);
                else if(vc->obedit->type==OB_ARMATURE)
-                       do_lasso_select_armature(vc, mcords, moves, select);
+                       do_lasso_select_armature(vc, mcords, moves, extend, select);
        
                WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc->obedit->data);
        }
@@ -757,7 +791,7 @@ void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short
 static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
 {
        ViewContext vc;
-       int select, i= 0;
+       int i= 0;
        short mcords[1024][2];
 
        RNA_BEGIN(op->ptr, itemptr, "path") {
@@ -772,13 +806,15 @@ static int view3d_lasso_select_exec(bContext *C, wmOperator *op)
        RNA_END;
        
        if(i>1) {
+               short extend, select;
                view3d_operator_needs_opengl(C);
                
                /* setup view context for argument to callbacks */
                view3d_set_viewcontext(C, &vc);
                
+               extend= RNA_boolean_get(op->ptr, "extend");
                select= !RNA_boolean_get(op->ptr, "deselect");
-               view3d_lasso_select(C, &vc, mcords, i, select);
+               view3d_lasso_select(C, &vc, mcords, i, extend, select);
                
                return OPERATOR_FINISHED;
        }
@@ -801,6 +837,7 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot)
        
        RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", "");
        RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect rather than select items.");
+       RNA_def_boolean(ot->srna, "extend", 1, "Extend", "Extend selection instead of deselecting everything first.");
 }
 
 
@@ -1319,7 +1356,7 @@ static void do_nurbs_box_select__doSelect(void *userData, Nurb *UNUSED(nu), BPoi
                }
        }
 }
-static void do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int extend)
+static int do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int extend)
 {
        struct { ViewContext *vc; rcti *rect; int select; } data;
        
@@ -1327,12 +1364,13 @@ static void do_nurbs_box_select(ViewContext *vc, rcti *rect, int select, int ext
        data.rect = rect;
        data.select = select;
 
-       if (extend == 0 && select) {
+       if (extend == 0 && select)
                CU_deselect_all(vc->obedit);
-       }
 
        ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
        nurbs_foreachScreenVert(vc, do_nurbs_box_select__doSelect, &data);
+
+       return OPERATOR_FINISHED;
 }
 
 static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, int y)
@@ -1343,7 +1381,7 @@ static void do_lattice_box_select__doSelect(void *userData, BPoint *bp, int x, i
                bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
        }
 }
-static void do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int extend)
+static int do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int extend)
 {
        struct { ViewContext vc; rcti *rect; int select, pass, done; } data;
 
@@ -1351,12 +1389,13 @@ static void do_lattice_box_select(ViewContext *vc, rcti *rect, int select, int e
        data.rect = rect;
        data.select = select;
 
-       if (extend == 0 && select) {
+       if (extend == 0 && select)
                ED_setflagsLatt(vc->obedit, 0);
-       }
 
        ED_view3d_init_mats_rv3d(vc->obedit, vc->rv3d); /* for foreach's screen/vert projection */
        lattice_foreachScreenVert(vc, do_lattice_box_select__doSelect, &data);
+       
+       return OPERATOR_FINISHED;
 }
 
 static void do_mesh_box_select__doSelectVert(void *userData, EditVert *eve, int x, int y, int UNUSED(index))
@@ -1392,7 +1431,7 @@ static void do_mesh_box_select__doSelectFace(void *userData, EditFace *efa, int
                EM_select_face_fgon(data->vc.em, efa, data->select);
        }
 }
-static void do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend)
+static int do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int extend)
 {
        struct { ViewContext vc; rcti *rect; short select, pass, done; } data;
        ToolSettings *ts= vc->scene->toolsettings;
@@ -1405,9 +1444,7 @@ static void do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exte
        data.done = 0;
 
        if (extend == 0 && select)
-       {
                EM_deselect_all(vc->em);
-       }
 
        /* workaround: init mats first, EM_mask_init_backbuf_border can change
           view matrix to pixel space, breaking edge select with backbuf. fixes bug #20936 */
@@ -1451,261 +1488,280 @@ static void do_mesh_box_select(ViewContext *vc, rcti *rect, int select, int exte
        EM_free_backbuf();
                
        EM_selectmode_flush(vc->em);
+       
+       return OPERATOR_FINISHED;
 }
 
-static int view3d_borderselect_exec(bContext *C, wmOperator *op)
+static int do_meta_box_select(ViewContext *vc, rcti *rect, int select, int extend)
 {
-       ViewContext vc;
-       Scene *scene= CTX_data_scene(C);
-       ScrArea *sa= CTX_wm_area(C);
-       View3D *v3d= sa->spacedata.first;
-       Object *obedit= CTX_data_edit_object(C);
-       Object *obact= CTX_data_active_object(C);
-       rcti rect;
-       Base *base;
+       MetaBall *mb = (MetaBall*)vc->obedit->data;
        MetaElem *ml;
+       int a;
+
        unsigned int buffer[4*MAXPICKBUF];
-       int a, index;
-       int extend;
-       short hits, selecting;
+       short hits;
 
-       view3d_operator_needs_opengl(C);
-       
-       /* setup view context for argument to callbacks */
-       view3d_set_viewcontext(C, &vc);
-       
-       selecting= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT);
-       rect.xmin= RNA_int_get(op->ptr, "xmin");
-       rect.ymin= RNA_int_get(op->ptr, "ymin");
-       rect.xmax= RNA_int_get(op->ptr, "xmax");
-       rect.ymax= RNA_int_get(op->ptr, "ymax");
-       extend = RNA_boolean_get(op->ptr, "extend");
+       hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, rect);
 
-       if(obedit==NULL && (paint_facesel_test(OBACT))) {
-               face_borderselect(C, obact, &rect, selecting, extend);
-               return OPERATOR_FINISHED;
-       }
-       else if(obedit==NULL && (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) {
-               return PE_border_select(C, &rect, selecting, extend);
+       if (extend == 0 && select) {
+               for(ml= mb->editelems->first; ml; ml= ml->next) {
+                       ml->flag &= ~SELECT;
+               }
        }
-       else if(obedit==NULL && (obact && obact->mode & OB_MODE_SCULPT))
-               return OPERATOR_CANCELLED;
        
-       if(obedit) {
-               if(obedit->type==OB_MESH) {
-                       Mesh *me= obedit->data;
-                       vc.em= me->edit_mesh;
-                       do_mesh_box_select(&vc, &rect, selecting, extend);
-//                     if (EM_texFaceCheck())
-                       WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
-                       
-               }
-               else if(ELEM(obedit->type, OB_CURVE, OB_SURF)) {
-                       do_nurbs_box_select(&vc, &rect, selecting, extend);
-               }
-               else if(obedit->type==OB_MBALL) {
-                       MetaBall *mb = (MetaBall*)obedit->data;
-                       hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
-                       
-                       if (extend == 0 && selecting) {
-                               ml= mb->editelems->first;
-
-                               while(ml) {
-                                       ml->flag &= ~SELECT;
-                                       ml= ml->next;
-                               }
+       for(ml= mb->editelems->first; ml; ml= ml->next) {
+               for(a=0; a<hits; a++) {
+                       if(ml->selcol1==buffer[ (4 * a) + 3 ]) {
+                               ml->flag |= MB_SCALE_RAD;
+                               if(select)      ml->flag |= SELECT;
+                               else                    ml->flag &= ~SELECT;
+                               break;
                        }
-
-                       ml= mb->editelems->first;
-                       
-                       while(ml) {
-                               for(a=0; a<hits; a++) {
-                                       if(ml->selcol1==buffer[ (4 * a) + 3 ]) {
-                                               ml->flag |= MB_SCALE_RAD;
-                                               if(selecting)   ml->flag |= SELECT;
-                                               else                    ml->flag &= ~SELECT;
-                                               break;
-                                       }
-                                       if(ml->selcol2==buffer[ (4 * a) + 3 ]) {
-                                               ml->flag &= ~MB_SCALE_RAD;
-                                               if(selecting)   ml->flag |= SELECT;
-                                               else                    ml->flag &= ~SELECT;
-                                               break;
-                                       }
-                               }
-                               ml= ml->next;
+                       if(ml->selcol2==buffer[ (4 * a) + 3 ]) {
+                               ml->flag &= ~MB_SCALE_RAD;
+                               if(select)      ml->flag |= SELECT;
+                               else                    ml->flag &= ~SELECT;
+                               break;
                        }
                }
-               else if(obedit->type==OB_ARMATURE) {
-                       bArmature *arm= obedit->data;
-                       EditBone *ebone;
-                       
-                       /* clear flag we use to detect point was affected */
-                       for(ebone= arm->edbo->first; ebone; ebone= ebone->next)
-                               ebone->flag &= ~BONE_DONE;
-                       
-                       if (extend==0 && selecting) {
-                               /*      Set the flags */
-                               CTX_DATA_BEGIN(C, EditBone *, ebone, visible_bones) {
-                                       /* ignore bone if selection can't change */
-                                       if ((ebone->flag & BONE_UNSELECTABLE) == 0) {
-                                               ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
-                                       }
-                               }
-                               CTX_DATA_END;
-                       }
+       }
 
-                       hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect);
-                       
-                       /* first we only check points inside the border */
-                       for (a=0; a<hits; a++){
-                               index = buffer[(4*a)+3];
-                               if (index!=-1) {
-                                       ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
-                                       if (index & BONESEL_TIP) {
-                                               ebone->flag |= BONE_DONE;
-                                               if (selecting)  ebone->flag |= BONE_TIPSEL;
-                                               else                    ebone->flag &= ~BONE_TIPSEL;
-                                       }
-                                       
-                                       if (index & BONESEL_ROOT) {
-                                               ebone->flag |= BONE_DONE;
-                                               if (selecting)  ebone->flag |= BONE_ROOTSEL;
-                                               else                    ebone->flag &= ~BONE_ROOTSEL;
-                                       }
+       return OPERATOR_FINISHED;
+}
+
+static int do_armature_box_select(ViewContext *vc, rcti *rect, short select, short extend)
+{
+       bArmature *arm= vc->obedit->data;
+       EditBone *ebone;
+       int a;
+
+       unsigned int buffer[4*MAXPICKBUF];
+       short hits;
+
+       hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, rect);
+       
+       /* clear flag we use to detect point was affected */
+       for(ebone= arm->edbo->first; ebone; ebone= ebone->next)
+               ebone->flag &= ~BONE_DONE;
+       
+       if (extend==0 && select)
+               ED_armature_deselect_all_visible(vc->obedit);
+
+       /* first we only check points inside the border */
+       for (a=0; a<hits; a++){
+               int index = buffer[(4*a)+3];
+               if (index!=-1) {
+                       ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
+                       if ((ebone->flag & BONE_UNSELECTABLE)==0) {
+                               if (index & BONESEL_TIP) {
+                                       ebone->flag |= BONE_DONE;
+                                       if (select)     ebone->flag |= BONE_TIPSEL;
+                                       else            ebone->flag &= ~BONE_TIPSEL;
                                }
-                       }
-                       
-                       /* now we have to flush tag from parents... */
-                       for(ebone= arm->edbo->first; ebone; ebone= ebone->next) {
-                               if(ebone->parent && (ebone->flag & BONE_CONNECTED)) {
-                                       if(ebone->parent->flag & BONE_DONE)
-                                               ebone->flag |= BONE_DONE;
+                               
+                               if (index & BONESEL_ROOT) {
+                                       ebone->flag |= BONE_DONE;
+                                       if (select)     ebone->flag |= BONE_ROOTSEL;
+                                       else            ebone->flag &= ~BONE_ROOTSEL;
                                }
                        }
-                       
-                       /* only select/deselect entire bones when no points where in the rect */
-                       for (a=0; a<hits; a++){
-                               index = buffer[(4*a)+3];
-                               if (index!=-1) {
-                                       ebone = BLI_findlink(arm->edbo, index & ~(BONESEL_ANY));
-                                       if (index & BONESEL_BONE) {
-                                               if(!(ebone->flag & BONE_DONE)) {
-                                                       if (selecting)
-                                                               ebone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
-                                                       else
-                                                               ebone->flag &= ~(BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
-                                               }
+               }
+       }
+       
+       /* now we have to flush tag from parents... */
+       for(ebone= arm->edbo->first; ebone; ebone= ebone->next) {
+               if(ebone->parent && (ebone->flag & BONE_CONNECTED)) {
+                       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) {
+                               if ((ebone->flag & BONE_UNSELECTABLE)==0) {
+                                       if(!(ebone->flag & BONE_DONE)) {
+                                               if (select)
+                                                       ebone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
+                                               else
+                                                       ebone->flag &= ~(BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED);
                                        }
                                }
                        }
-                       
-                       ED_armature_sync_selection(arm->edbo);
-                       WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
-               }
-               else if(obedit->type==OB_LATTICE) {
-                       do_lattice_box_select(&vc, &rect, selecting, extend);
                }
        }
-       else {  /* no editmode, unified for bones and objects */
-               Bone *bone;
-               Object *ob= OBACT;
-               unsigned int *vbuffer=NULL; /* selection buffer */
-               unsigned int *col;                      /* color in buffer      */
-               int bone_only;
-               int bone_selected=0;
-               int totobj= MAXPICKBUF; // XXX solve later
-               
-               if((ob) && (ob->mode & OB_MODE_POSE))
-                       bone_only= 1;
-               else
-                       bone_only= 0;
-               
-               if (extend == 0 && selecting) {
-                       base= FIRSTBASE;
+       
+       ED_armature_sync_selection(arm->edbo);
+       
+       return OPERATOR_CANCELLED;
+}
 
-                       if (bone_only) {
-                               CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) {
+static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, int select, int extend)
+{
+       Bone *bone;
+       Object *ob= vc->obact;
+       unsigned int *vbuffer=NULL; /* selection buffer */
+       unsigned int *col;                      /* color in buffer      */
+       int bone_only;
+       int bone_selected=0;
+       int totobj= MAXPICKBUF; // XXX solve later
+       short hits;
+       
+       if((ob) && (ob->mode & OB_MODE_POSE))
+               bone_only= 1;
+       else
+               bone_only= 0;
+       
+       if (extend == 0 && select) {
+               if (bone_only) {
+                       CTX_DATA_BEGIN(C, bPoseChannel *, pchan, visible_pose_bones) {
+                               if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) {
                                        pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
                                }
-                               CTX_DATA_END;
-                       } else {
-                               while(base) {
-                                       Base *next = base->next;
-                                       if(BASE_SELECTABLE(v3d, base)) {
-                                               ED_base_object_select(base, BA_DESELECT);
-                                       }
-                                       base= next;
-                               }
                        }
+                       CTX_DATA_END;
+               } else {
+                       object_deselect_all_visible(vc->scene, vc->v3d);
                }
+       }
 
-               /* selection buffer now has bones potentially too, so we add MAXPICKBUF */
-               vbuffer = MEM_mallocN(4 * (totobj+MAXPICKBUF) * sizeof(unsigned int), "selection buffer");
-               hits= view3d_opengl_select(&vc, vbuffer, 4*(totobj+MAXPICKBUF), &rect);
-               /*
-               LOGIC NOTES (theeth):
-               The buffer and ListBase have the same relative order, which makes the selection
-               very simple. Loop through both data sets at the same time, if the color
-               is the same as the object, we have a hit and can move to the next color
-               and object pair, if not, just move to the next object,
-               keeping the same color until we have a hit.
-
-               The buffer order is defined by OGL standard, hopefully no stupid GFX card
-               does it incorrectly.
-               */
-
-               if (hits>0) { /* no need to loop if there's no hit */
-                       base= FIRSTBASE;
-                       col = vbuffer + 3;
-                       
-                       while(base && hits) {
-                               Base *next = base->next;
-                               if(BASE_SELECTABLE(v3d, base)) {
-                                       while (base->selcol == (*col & 0xFFFF)) {       /* we got an object */
-                                               
-                                               if(*col & 0xFFFF0000) {                                 /* we got a bone */
-                                                       bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
-                                                       if(bone) {
-                                                               if(selecting) {
-                                                                       bone->flag |= BONE_SELECTED;
-                                                                       bone_selected=1;
+       /* selection buffer now has bones potentially too, so we add MAXPICKBUF */
+       vbuffer = MEM_mallocN(4 * (totobj+MAXPICKBUF) * sizeof(unsigned int), "selection buffer");
+       hits= view3d_opengl_select(vc, vbuffer, 4*(totobj+MAXPICKBUF), rect);
+       /*
+       LOGIC NOTES (theeth):
+       The buffer and ListBase have the same relative order, which makes the selection
+       very simple. Loop through both data sets at the same time, if the color
+       is the same as the object, we have a hit and can move to the next color
+       and object pair, if not, just move to the next object,
+       keeping the same color until we have a hit.
+
+       The buffer order is defined by OGL standard, hopefully no stupid GFX card
+       does it incorrectly.
+       */
+
+       if (hits>0) { /* no need to loop if there's no hit */
+               Base *base;
+               col = vbuffer + 3;
+               
+               for(base= vc->scene->base.first; base && hits; base= base->next) {
+                       if(BASE_SELECTABLE(vc->v3d, base)) {
+                               while (base->selcol == (*col & 0xFFFF)) {       /* we got an object */
+                                       
+                                       if(*col & 0xFFFF0000) {                                 /* we got a bone */
+                                               bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
+                                               if(bone) {
+                                                       if(select) {
+                                                               bone->flag |= BONE_SELECTED;
+                                                               bone_selected=1;
 // XXX                                                                 select_actionchannel_by_name(base->object->action, bone->name, 1);
-                                                               }
-                                                               else {
-                                                                       bArmature *arm= base->object->data;
-                                                                       bone->flag &= ~BONE_SELECTED;
+                                                       }
+                                                       else {
+                                                               bArmature *arm= base->object->data;
+                                                               bone->flag &= ~BONE_SELECTED;
 // XXX                                                                 select_actionchannel_by_name(base->object->action, bone->name, 0);
-                                                                       if(arm->act_bone==bone)
-                                                                               arm->act_bone= NULL;
-                                                                       
-                                                               }
+                                                               if(arm->act_bone==bone)
+                                                                       arm->act_bone= NULL;
+                                                               
                                                        }
                                                }
-                                               else if(!bone_only) {
-                                                       if (selecting)
-                                                               ED_base_object_select(base, BA_SELECT);
-                                                       else
-                                                               ED_base_object_select(base, BA_DESELECT);
-                                               }
-
-                                               col+=4; /* next color */
-                                               hits--;
-                                               if(hits==0) break;
                                        }
+                                       else if(!bone_only) {
+                                               if (select)
+                                                       ED_base_object_select(base, BA_SELECT);
+                                               else
+                                                       ED_base_object_select(base, BA_DESELECT);
+                                       }
+
+                                       col+=4; /* next color */
+                                       hits--;
+                                       if(hits==0) break;
                                }
-                               
-                               if (bone_selected)      WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, base->object);
-                               
-                               base= next;
                        }
+                       
+                       if (bone_selected) {
+                               WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, base->object);
+                       }
+               }
 
-                       WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene);
+               WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, vc->scene);
+
+       }
+       MEM_freeN(vbuffer);
+
+       return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
+}
+
+static int view3d_borderselect_exec(bContext *C, wmOperator *op)
+{
+       ViewContext vc;
+       rcti rect;
+       short extend;
+       short select;
+
+       int ret= OPERATOR_CANCELLED;
 
+       view3d_operator_needs_opengl(C);
+
+       /* setup view context for argument to callbacks */
+       view3d_set_viewcontext(C, &vc);
+       
+       select= (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT);
+       rect.xmin= RNA_int_get(op->ptr, "xmin");
+       rect.ymin= RNA_int_get(op->ptr, "ymin");
+       rect.xmax= RNA_int_get(op->ptr, "xmax");
+       rect.ymax= RNA_int_get(op->ptr, "ymax");
+       extend = RNA_boolean_get(op->ptr, "extend");
+
+       if(vc.obedit) {
+               switch(vc.obedit->type) {
+               case OB_MESH:
+                       vc.em= ((Mesh *)vc.obedit->data)->edit_mesh;
+                       ret= do_mesh_box_select(&vc, &rect, select, extend);
+//                     if (EM_texFaceCheck())
+                       if(ret & OPERATOR_FINISHED) {
+                               WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit->data);
+                       }
+                       break;
+               case OB_CURVE:
+               case OB_SURF:
+                       ret= do_nurbs_box_select(&vc, &rect, select, extend);
+                       break;
+               case OB_MBALL:
+                       ret= do_meta_box_select(&vc, &rect, select, extend);
+                       break;
+               case OB_ARMATURE:
+                       ret= do_armature_box_select(&vc, &rect, select, extend);
+                       if(ret & OPERATOR_FINISHED) {
+                               WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit);
+                       }
+                       break;
+               case OB_LATTICE:
+                       ret= do_lattice_box_select(&vc, &rect, select, extend);                 
+                       break;                  
+               default:
+                       assert(!"border select on incorrect object type");
                }
-               MEM_freeN(vbuffer);
        }
-       return OPERATOR_FINISHED;
+       else {  /* no editmode, unified for bones and objects */
+               if(vc.obact && vc.obact->mode & OB_MODE_SCULPT) {
+                       /* pass */
+               }
+               else if(vc.obact && paint_facesel_test(vc.obact)) {
+                       ret= do_paintface_box_select(&vc, &rect, select, extend);
+               }
+               else if(vc.obact && vc.obact->mode & OB_MODE_PARTICLE_EDIT) {
+                       ret= PE_border_select(C, &rect, select, extend);
+               }
+               else { /* object mode with none active */
+                       ret= do_object_pose_box_select(C, &vc, &rect, select, extend);
+               }
+       }
+
+       return ret;
 } 
 
 
@@ -1764,7 +1820,7 @@ static int view3d_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
        else if(obact && obact->mode & OB_MODE_PARTICLE_EDIT)
                return PE_mouse_particles(C, event->mval, extend);
        else if(obact && paint_facesel_test(obact))
-               retval = face_select(C, obact, event->mval, extend);
+               retval = paintface_mouse_select(C, obact, event->mval, extend);
        else
                retval = mouse_select(C, event->mval, extend, center, enumerate);
 
@@ -1829,7 +1885,7 @@ static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y
        }
 }
 
-static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, float rad)
+static void mesh_circle_select(ViewContext *vc, int select, short *mval, float rad)
 {
        ToolSettings *ts= vc->scene->toolsettings;
        int bbsel;
@@ -1841,14 +1897,14 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa
        vc->em= ((Mesh *)vc->obedit->data)->edit_mesh;
 
        data.vc = vc;
-       data.select = selecting;
+       data.select = select;
        data.mval[0] = mval[0];
        data.mval[1] = mval[1];
        data.radius = rad;
 
        if(ts->selectmode & SCE_SELECT_VERTEX) {
                if(bbsel) {
-                       EM_backbuf_checkAndSelectVerts(vc->em, selecting==LEFTMOUSE);
+                       EM_backbuf_checkAndSelectVerts(vc->em, select==LEFTMOUSE);
                } else {
                        mesh_foreachScreenVert(vc, mesh_circle_doSelectVert, &data, 1);
                }
@@ -1856,7 +1912,7 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa
 
        if(ts->selectmode & SCE_SELECT_EDGE) {
                if (bbsel) {
-                       EM_backbuf_checkAndSelectEdges(vc->em, selecting==LEFTMOUSE);
+                       EM_backbuf_checkAndSelectEdges(vc->em, select==LEFTMOUSE);
                } else {
                        mesh_foreachScreenEdge(vc, mesh_circle_doSelectEdge, &data, 0);
                }
@@ -1864,7 +1920,7 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa
        
        if(ts->selectmode & SCE_SELECT_FACE) {
                if(bbsel) {
-                       EM_backbuf_checkAndSelectFaces(vc->em, selecting==LEFTMOUSE);
+                       EM_backbuf_checkAndSelectFaces(vc->em, select==LEFTMOUSE);
                } else {
                        mesh_foreachScreenFace(vc, mesh_circle_doSelectFace, &data);
                }
@@ -1874,7 +1930,7 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa
        EM_selectmode_flush(vc->em);
 }
 
-static void paint_facesel_circle_select(ViewContext *vc, int selecting, short *mval, float rad)
+static void paint_facesel_circle_select(ViewContext *vc, int select, short *mval, float rad)
 {
        Object *ob= vc->obact;
        Mesh *me = ob?ob->data:NULL;
@@ -1884,10 +1940,8 @@ static void paint_facesel_circle_select(ViewContext *vc, int selecting, short *m
                em_vertoffs= me->totface+1;     /* max index array */
 
                bbsel= EM_init_backbuf_circle(vc, mval[0], mval[1], (short)(rad+1.0));
-               EM_backbuf_checkAndSelectTFaces(me, selecting==LEFTMOUSE);
+               EM_backbuf_checkAndSelectTFaces(me, select==LEFTMOUSE);
                EM_free_backbuf();
-
-// XXX                 object_tface_flags_changed(OBACT, 0);
        }
 }
 
@@ -1923,13 +1977,13 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint
                }
        }
 }
-static void nurbscurve_circle_select(ViewContext *vc, int selecting, short *mval, float rad)
+static void nurbscurve_circle_select(ViewContext *vc, int select, short *mval, float rad)
 {
        struct {ViewContext *vc; short select, mval[2]; float radius; } data;
 
        /* set vc-> edit data */
        
-       data.select = selecting;
+       data.select = select;
        data.mval[0] = mval[0];
        data.mval[1] = mval[1];
        data.radius = rad;
@@ -1950,13 +2004,13 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int
                bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT);
        }
 }
-static void lattice_circle_select(ViewContext *vc, int selecting, short *mval, float rad)
+static void lattice_circle_select(ViewContext *vc, int select, short *mval, float rad)
 {
        struct {ViewContext *vc; short select, mval[2]; float radius; } data;
 
        /* set vc-> edit data */
        
-       data.select = selecting;
+       data.select = select;
        data.mval[0] = mval[0];
        data.mval[1] = mval[1];
        data.radius = rad;
@@ -1989,7 +2043,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int
        }
        return 0;
 }
-static void armature_circle_select(ViewContext *vc, int selecting, short *mval, float rad)
+static void armature_circle_select(ViewContext *vc, int select, short *mval, float rad)
 {
        struct {ViewContext *vc; short select, mval[2]; float radius; } data;
        bArmature *arm= vc->obedit->data;
@@ -1997,7 +2051,7 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval,
        int change= FALSE;
        
        /* set vc->edit data */
-       data.select = selecting;
+       data.select = select;
        data.mval[0] = mval[0];
        data.mval[1] = mval[1];
        data.radius = rad;
@@ -2029,7 +2083,7 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval,
                /* only if the endpoints didn't get selected, deal with the middle of the bone too */
                // XXX should we just do this always?
                if ( (didpoint==0) && edge_inside_circle(mval[0], mval[1], rad, sco1[0], sco1[1], sco2[0], sco2[1]) ) {
-                       if (selecting
+                       if (select) 
                                ebone->flag |= BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED;
                        else 
                                ebone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL);
@@ -2045,21 +2099,21 @@ static void armature_circle_select(ViewContext *vc, int selecting, short *mval,
 
 /** Callbacks for circle selection in Editmode */
 
-static void obedit_circle_select(ViewContext *vc, short selecting, short *mval, float rad) 
+static void obedit_circle_select(ViewContext *vc, short select, short *mval, float rad) 
 {
        switch(vc->obedit->type) {              
        case OB_MESH:
-               mesh_circle_select(vc, selecting, mval, rad);
+               mesh_circle_select(vc, select, mval, rad);
                break;
        case OB_CURVE:
        case OB_SURF:
-               nurbscurve_circle_select(vc, selecting, mval, rad);
+               nurbscurve_circle_select(vc, select, mval, rad);
                break;
        case OB_LATTICE:
-               lattice_circle_select(vc, selecting, mval, rad);
+               lattice_circle_select(vc, select, mval, rad);
                break;
        case OB_ARMATURE:
-               armature_circle_select(vc, selecting, mval, rad);
+               armature_circle_select(vc, select, mval, rad);
                break;
        default:
                return;
@@ -2078,9 +2132,9 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
        int y= RNA_int_get(op->ptr, "y");
        int radius= RNA_int_get(op->ptr, "radius");
        int gesture_mode= RNA_int_get(op->ptr, "gesture_mode");
-       int selecting;
+       int select;
        
-       selecting= (gesture_mode==GESTURE_MODAL_SELECT);
+       select= (gesture_mode==GESTURE_MODAL_SELECT);
     
        if(CTX_data_edit_object(C) || paint_facesel_test(obact) ||
                (obact && obact->mode & OB_MODE_PARTICLE_EDIT)) {
@@ -2094,22 +2148,22 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
                mval[1]= y;
 
                if(CTX_data_edit_object(C)) {
-                       obedit_circle_select(&vc, selecting, mval, (float)radius);
+                       obedit_circle_select(&vc, select, mval, (float)radius);
                        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data);
                }
                else if(paint_facesel_test(obact)) {
-                       paint_facesel_circle_select(&vc, selecting, mval, (float)radius);
+                       paint_facesel_circle_select(&vc, select, mval, (float)radius);
                        WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obact->data);
                }
                else
-                       return PE_circle_select(C, selecting, mval, (float)radius);
+                       return PE_circle_select(C, select, mval, (float)radius);
        }
        else if(obact && obact->mode & OB_MODE_SCULPT) {
                return OPERATOR_CANCELLED;
        }
        else {
                Base *base;
-               selecting= selecting?BA_SELECT:BA_DESELECT;
+               select= select?BA_SELECT:BA_DESELECT;
                for(base= FIRSTBASE; base; base= base->next) {
                        if(BASE_SELECTABLE(v3d, base)) {
                                project_short(ar, base->object->obmat[3], &base->sx);
@@ -2117,7 +2171,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op)
                                        int dx= base->sx-x;
                                        int dy= base->sy-y;
                                        if( dx*dx + dy*dy < radius*radius)
-                                               ED_base_object_select(base, selecting);
+                                               ED_base_object_select(base, select);
                                }
                        }
                }
index 123db2ce65a0c5635c9aef8966a4339462511b0a..29496d2aa751bbe044743d2fb8c95cfe3eed4235 100644 (file)
@@ -678,7 +678,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 
        for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
                bone = pchan->bone;
-               if ((bone->layer & arm->layer) && !(pchan->bone->flag & BONE_HIDDEN_P)) {
+               if (PBONE_VISIBLE(arm, bone)) {
                        if ((bone->flag & BONE_SELECTED) && !(ob->proxy && pchan->bone->layer & arm->layer_protected))
                                bone->flag |= BONE_TRANSFORM;
                        else
index 73b58b51ffcbedc1df2ff1f02144e10feebef190..b3dbf3c853aee2e514d712ac620d6bc9118923c3 100644 (file)
@@ -316,7 +316,7 @@ int calc_manipulator_stats(const bContext *C)
                        bArmature *arm= obedit->data;
                        EditBone *ebo;
                        for (ebo= arm->edbo->first; ebo; ebo=ebo->next){
-                               if(ebo->layer & arm->layer && !(ebo->flag & BONE_HIDDEN_A)) {
+                               if(EBONE_VISIBLE(arm, ebo)) {
                                        if (ebo->flag & BONE_TIPSEL) {
                                                calc_tw_center(scene, ebo->tail);
                                                totsel++;
index c661f6b2812c0c849c1e3f2e3c0f5b582f047559..e093eb8cb656c4ca988e791f70b4b8cb7a319028 100644 (file)
@@ -40,8 +40,6 @@ INCLUDE_DIRECTORIES(
        ../blender/makesdna
        ../blender/gpu
        ../blender/windowmanager
-       ../kernel/gen_messaging
-       ../kernel/gen_system
 )
 
 IF(WIN32)
@@ -78,6 +76,11 @@ IF(WITH_PYTHON)
 ENDIF(WITH_PYTHON)
 
 IF(WITH_GAMEENGINE)
+       INCLUDE_DIRECTORIES(
+               ../kernel/gen_messaging
+               ../kernel/gen_system
+       )
+
        ADD_DEFINITIONS(-DWITH_GAMEENGINE)
 ENDIF(WITH_GAMEENGINE)
 
index 4a217a147fa15239c232ee25b1dbaf5e75957e2e..aad70ea91780d8d98afb5ccf1b7b246d4516c259 100644 (file)
@@ -57,8 +57,7 @@
 
 #include "BLI_args.h"
 #include "BLI_threads.h"
-
-#include "GEN_messaging.h"
+#include "BLI_scanfill.h" // for BLI_setErrorCallBack, TODO, move elsewhere
 
 #include "DNA_ID.h"
 #include "DNA_scene_types.h"
@@ -98,6 +97,7 @@
 
 /* for passing information between creator and gameengine */
 #ifdef WITH_GAMEENGINE
+#include "GEN_messaging.h"
 #include "SYS_System.h"
 #else /* dummy */
 #define SYS_SystemHandle int