[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46986] trunk/blender/source/blender/ editors: Modifications to the view3d.select() operator:

Campbell Barton ideasman42 at gmail.com
Thu May 24 23:22:32 CEST 2012


editmesh_select.c:1499 --- should this be 'toggle' ? - it is for edge
and vertex but not face.

On Thu, May 24, 2012 at 11:05 PM, Nathan Vegdahl <cessen at cessen.com> wrote:
> Revision: 46986
>          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46986
> Author:   cessen
> Date:     2012-05-24 21:05:27 +0000 (Thu, 24 May 2012)
> Log Message:
> -----------
> Modifications to the view3d.select() operator:
>
> 1. Two new boolean options have been added to the operator: "deselect"
>   and "toggle".
> 2. The previous behavior of "extend" (toggling the selection) has
>   been moved to the "toggle" option.
> 3. "extend" now only extends the selection, it never deselects.
> 4. "deselect" is pretty self-explanatory: it deselects (i.e. opposite
>   of extend).
> 5. The built-in keymap has been changed to use "toggle" where
>   "extend" was used before for this operator, to maintain the
>   previous behavior in the default keymap.
>
> In short, this works towards making "extend" and "deselect" fully
> consistent across all selection tools (adding to and removing from
> selection, respectively), but still preserves the old behavior
> as well.
>
> (Patch reviewed by Brecht.)
>
> Modified Paths:
> --------------
>    trunk/blender/source/blender/editors/armature/editarmature.c
>    trunk/blender/source/blender/editors/curve/editcurve.c
>    trunk/blender/source/blender/editors/include/ED_armature.h
>    trunk/blender/source/blender/editors/include/ED_curve.h
>    trunk/blender/source/blender/editors/include/ED_mball.h
>    trunk/blender/source/blender/editors/include/ED_mesh.h
>    trunk/blender/source/blender/editors/include/ED_object.h
>    trunk/blender/source/blender/editors/include/ED_particle.h
>    trunk/blender/source/blender/editors/mesh/editface.c
>    trunk/blender/source/blender/editors/mesh/editmesh_select.c
>    trunk/blender/source/blender/editors/metaball/mball_edit.c
>    trunk/blender/source/blender/editors/object/object_lattice.c
>    trunk/blender/source/blender/editors/physics/particle_edit.c
>    trunk/blender/source/blender/editors/space_view3d/view3d_ops.c
>    trunk/blender/source/blender/editors/space_view3d/view3d_select.c
>
> Modified: trunk/blender/source/blender/editors/armature/editarmature.c
> ===================================================================
> --- trunk/blender/source/blender/editors/armature/editarmature.c        2012-05-24 20:20:12 UTC (rev 46985)
> +++ trunk/blender/source/blender/editors/armature/editarmature.c        2012-05-24 21:05:27 UTC (rev 46986)
> @@ -1842,7 +1842,7 @@
>  }
>
>  /* context: editmode armature in view3d */
> -int mouse_armature(bContext *C, const int mval[2], int extend)
> +int mouse_armature(bContext *C, const int mval[2], int extend, int deselect, int toggle)
>  {
>        Object *obedit = CTX_data_edit_object(C);
>        bArmature *arm = obedit->data;
> @@ -1857,7 +1857,7 @@
>        nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask);
>        if (nearBone) {
>
> -               if (!extend)
> +               if (!extend && !deselect && !toggle)
>                        ED_armature_deselect_all(obedit, 0);
>
>                /* by definition the non-root connected bones have no root point drawn,
> @@ -1867,6 +1867,18 @@
>                        if (nearBone->parent && (nearBone->flag & BONE_CONNECTED)) {
>                                /* click in a chain */
>                                if (extend) {
> +                                       /* select this bone */
> +                                       nearBone->flag |= BONE_TIPSEL;
> +                                       nearBone->parent->flag |= BONE_TIPSEL;
> +                               }
> +                               else if (deselect) {
> +                                       /* deselect this bone */
> +                                       nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED);
> +                                       /* only deselect parent tip if it is not selected */
> +                                       if (!(nearBone->parent->flag & BONE_SELECTED))
> +                                               nearBone->parent->flag &= ~BONE_TIPSEL;
> +                               }
> +                               else if (toggle) {
>                                        /* hold shift inverts this bone's selection */
>                                        if (nearBone->flag & BONE_SELECTED) {
>                                                /* deselect this bone */
> @@ -1889,18 +1901,29 @@
>                        }
>                        else {
>                                if (extend) {
> +                                       nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
> +                               }
> +                               else if (deselect) {
> +                                       nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
> +                               }
> +                               else if (toggle) {
>                                        /* hold shift inverts this bone's selection */
>                                        if (nearBone->flag & BONE_SELECTED)
>                                                nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL);
>                                        else
>                                                nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
>                                }
> -                               else nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
> +                               else
> +                                       nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL);
>                        }
>                }
>                else {
> -                       if (extend && (nearBone->flag & selmask))
> +                       if (extend)
> +                               nearBone->flag |= selmask;
> +                       else if (deselect)
>                                nearBone->flag &= ~selmask;
> +                       else if (toggle && (nearBone->flag & selmask))
> +                               nearBone->flag &= ~selmask;
>                        else
>                                nearBone->flag |= selmask;
>                }
> @@ -4475,7 +4498,7 @@
>
>  /* called from editview.c, for mode-less pose selection */
>  /* assumes scene obact and basact is still on old situation */
> -int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend)
> +int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend, short deselect, short toggle)
>  {
>        Object *ob = base->object;
>        Bone *nearBone;
> @@ -4494,7 +4517,7 @@
>                 * note, special exception for armature mode so we can do multi-select
>                 * we could check for multi-select explicitly but think its fine to
>                 * always give predictable behavior in weight paint mode - campbell */
> -               if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) {
> +               if ((!extend && !deselect && !toggle)|| ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) {
>                        ED_pose_deselectall(ob, 0);
>                        nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
>                        arm->act_bone = nearBone;
> @@ -4503,25 +4526,34 @@
>                        //select_actionchannel_by_name(ob->action, nearBone->name, 1);
>                }
>                else {
> -                       if (nearBone->flag & BONE_SELECTED) {
> -                               /* if not active, we make it active */
> -                               if (nearBone != arm->act_bone) {
> -                                       arm->act_bone = nearBone;
> +                       if (extend) {
> +                               nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
> +                               arm->act_bone = nearBone;
> +                       }
> +                       else if (deselect) {
> +                               nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
> +                       }
> +                       else if (toggle) {
> +                               if (nearBone->flag & BONE_SELECTED) {
> +                                       /* if not active, we make it active */
> +                                       if (nearBone != arm->act_bone) {
> +                                               arm->act_bone = nearBone;
> +                                       }
> +                                       else {
> +                                               nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
> +
> +                                               // XXX old cruft! use notifiers instead
> +                                               //select_actionchannel_by_name(ob->action, nearBone->name, 0);
> +                                       }
>                                }
>                                else {
> -                                       nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
> -
> +                                       nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
> +                                       arm->act_bone = nearBone;
> +
>                                        // XXX old cruft! use notifiers instead
> -                                       //select_actionchannel_by_name(ob->action, nearBone->name, 0);
> +                                       //select_actionchannel_by_name(ob->action, nearBone->name, 1);
>                                }
> -                       }
> -                       else {
> -                               nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
> -                               arm->act_bone = nearBone;
> -
> -                               // XXX old cruft! use notifiers instead
> -                               //select_actionchannel_by_name(ob->action, nearBone->name, 1);
> -                       }
> +                       }
>                }
>
>                /* in weightpaint we select the associated vertex group too */
>
> Modified: trunk/blender/source/blender/editors/curve/editcurve.c
> ===================================================================
> --- trunk/blender/source/blender/editors/curve/editcurve.c      2012-05-24 20:20:12 UTC (rev 46985)
> +++ trunk/blender/source/blender/editors/curve/editcurve.c      2012-05-24 21:05:27 UTC (rev 46986)
> @@ -4126,7 +4126,7 @@
>
>  /***************** pick select from 3d view **********************/
>
> -int mouse_nurb(bContext *C, const int mval[2], int extend)
> +int mouse_nurb(bContext *C, const int mval[2], int extend, int deselect, int toggle)
>  {
>        Object *obedit = CTX_data_edit_object(C);
>        Curve *cu = obedit->data;
> @@ -4146,12 +4146,8 @@
>        hand = findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp);
>
>        if (bezt || bp) {
> -               if (extend == 0) {
> -
> -                       setflagsNurb(editnurb, 0);
> -
> +               if (extend) {
>                        if (bezt) {
> -
>                                if (hand == 1) {
>                                        select_beztriple(bezt, SELECT, 1, HIDDEN);
>                                        cu->lastsel = bezt;
> @@ -4167,11 +4163,28 @@
>                                cu->lastsel = bp;
>                                select_bpoint(bp, SELECT, 1, HIDDEN);
>                        }
> -
>                }
> -               else {
> +               else if (deselect) {
>                        if (bezt) {
>                                if (hand == 1) {
> +                                       select_beztriple(bezt, DESELECT, 1, HIDDEN);
> +                                       if (bezt == cu->lastsel) cu->lastsel = NULL;
> +                               }
> +                               else if (hand == 0) {
> +                                       bezt->f1 &= ~SELECT;
> +                               }
> +                               else {
> +                                       bezt->f3 &= ~SELECT;
> +                               }
> +                       }
> +                       else {
> +                               select_bpoint(bp, DESELECT, 1, HIDDEN);
> +                               if (cu->lastsel == bp) cu->lastsel = NULL;
> +                       }
> +               }
> +               else if (toggle) {
> +                       if (bezt) {
> +                               if (hand == 1) {
>                                        if (bezt->f2 & SELECT) {
>                                                select_beztriple(bezt, DESELECT, 1, HIDDEN);
>                                                if (bezt == cu->lastsel) cu->lastsel = NULL;
> @@ -4198,7 +4211,27 @@
>                                        cu->lastsel = bp;
>                                }
>                        }
> +               }
> +               else {
> +                       setflagsNurb(editnurb, 0);
>
> +                       if (bezt) {
> +
> +                               if (hand == 1) {
> +                                       select_beztriple(bezt, SELECT, 1, HIDDEN);
> +                                       cu->lastsel = bezt;
> +                               }
> +                               else {
> +                                       if (hand == 0) bezt->f1 |= SELECT;
> +                                       else bezt->f3 |= SELECT;
> +
> +                                       cu->lastsel = NULL;
> +                               }
> +                       }
> +                       else {
> +                               cu->lastsel = bp;
> +                               select_bpoint(bp, SELECT, 1, HIDDEN);
> +                       }
>                }
>
>                if (nu != get_actNurb(obedit))
>
> Modified: trunk/blender/source/blender/editors/include/ED_armature.h
> ===================================================================
> --- trunk/blender/source/blender/editors/include/ED_armature.h  2012-05-24 20:20:12 UTC (rev 46985)
> +++ trunk/blender/source/blender/editors/include/ED_armature.h  2012-05-24 21:05:27 UTC (rev 46986)
> @@ -113,8 +113,8 @@
>  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);
> -int mouse_armature(struct bContext *C, const int mval[2], int extend);
> +                            short hits, short extend, short deselect, short toggle);
> +int mouse_armature(struct bContext *C, const int mval[2], int extend, int deselect, int toggle);
>  int join_armature_exec(struct bContext *C, struct wmOperator *op);
>  struct Bone *get_indexed_bone(struct Object *ob, int index);
>  float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only);
>
> Modified: trunk/blender/source/blender/editors/include/ED_curve.h
> ===================================================================
> --- trunk/blender/source/blender/editors/include/ED_curve.h     2012-05-24 20:20:12 UTC (rev 46985)
> +++ trunk/blender/source/blender/editors/include/ED_curve.h     2012-05-24 21:05:27 UTC (rev 46986)
> @@ -65,7 +65,7 @@
>
>  void    BKE_curve_editNurb_free(struct Curve *cu);
>
> -int     mouse_nurb(struct bContext *C, const int mval[2], int extend);
> +int     mouse_nurb(struct bContext *C, const int mval[2], int extend, int deselect, int toggle);
>
>  struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob);
>
>
> Modified: trunk/blender/source/blender/editors/include/ED_mball.h
> ===================================================================
> --- trunk/blender/source/blender/editors/include/ED_mball.h     2012-05-24 20:20:12 UTC (rev 46985)
> +++ trunk/blender/source/blender/editors/include/ED_mball.h     2012-05-24 21:05:27 UTC (rev 46986)
> @@ -40,7 +40,7 @@
>
>  struct MetaElem *add_metaball_primitive(struct bContext *C, float mat[4][4], int type, int newname);
>
> -int mouse_mball(struct bContext *C, const int mval[2], int extend);
> +int mouse_mball(struct bContext *C, const int mval[2], int extend, int deselect, int toggle);
>
>  void free_editMball(struct Object *obedit);
>  void make_editMball(struct Object *obedit);
>
> Modified: trunk/blender/source/blender/editors/include/ED_mesh.h
> ===================================================================
> --- trunk/blender/source/blender/editors/include/ED_mesh.h      2012-05-24 20:20:12 UTC (rev 46985)
> +++ trunk/blender/source/blender/editors/include/ED_mesh.h      2012-05-24 21:05:27 UTC (rev 46986)
> @@ -156,7 +156,7 @@
>  /* editmesh_mods.c */
>  extern unsigned int bm_vertoffs, bm_solidoffs, bm_wireoffs;
>
> -int         mouse_mesh(struct bContext *C, const int mval[2], short extend);
> +int         mouse_mesh(struct bContext *C, const int mval[2], short extend, short deselect, short toggle);
>
>  struct BMVert *editbmesh_get_x_mirror_vert(struct Object *ob, struct BMEditMesh *em, struct BMVert *eve, const float co[3], int index);
>  int            mesh_get_x_mirror_vert(struct Object *ob, int index);
>
> @@ Diff output truncated at 10240 characters. @@
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs



-- 
- Campbell


More information about the Bf-committers mailing list