diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-11-05 21:29:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-11-05 21:29:48 +0300 |
commit | aec92ddc51cbcda0b706f9029838b3bb7b211f71 (patch) | |
tree | ae37b1bb746896afcc83b0d3625f1a21b7d00cf8 /source/blender/editors | |
parent | 1196947a987ae67a61aa1cdd7f27b00b4a6e0877 (diff) |
operator to select pos/neg verts on any axis relative to the active vertex
- useful to select the center verts of a model without having to attempt to border select
- useful for selecting one half or a model
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 75 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_ops.c | 1 |
3 files changed, 77 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index eae6f47a122..cea7ec33d3a 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -7197,3 +7197,78 @@ void MESH_OT_faces_shade_flat(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +/* TODO - some way to select on an arbitrary axis */ +static int select_axis_exec(bContext *C, wmOperator *op) +{ + Object *obedit= CTX_data_edit_object(C); + EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); + + int axis= RNA_int_get(op->ptr, "axis"); + int mode= RNA_enum_get(op->ptr, "mode"); /* -1==aligned, 0==neg, 1==pos*/ + + EditSelection *ese = em->selected.last; + + + if(ese==NULL) + return OPERATOR_CANCELLED; + + if(ese->type==EDITVERT) { + EditVert *ev; + EditVert *act_vert= (EditVert*)ese->data; + float value= act_vert->co[axis]; + float limit= CTX_data_tool_settings(C)->doublimit; // XXX + + if(mode==0) value -= limit; + else if (mode==1) value += limit; + + for(ev=em->verts.first;ev;ev=ev->next) { + if(!ev->h) { + switch(mode) { + case -1: /* aligned */ + if(fabs(ev->co[axis] - value) < limit) + ev->f |= SELECT; + break; + case 0: /* neg */ + if(ev->co[axis] > value) + ev->f |= SELECT; + break; + case 1: /* pos */ + if(ev->co[axis] < value) + ev->f |= SELECT; + break; + } + } + } + } + + EM_select_flush(em); + WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + + return OPERATOR_FINISHED; +} + +void MESH_OT_select_axis(wmOperatorType *ot) +{ + static EnumPropertyItem axis_mode_items[] = { + {0, "POSITIVE", 0, "Positive Axis", ""}, + {1, "NEGATIVE", 0, "Negative Axis", ""}, + {-1, "ALIGNED", 0, "Aligned Axis", ""}, + {0, NULL, 0, NULL, NULL}}; + + /* identifiers */ + ot->name= "Select Axis"; + ot->description= "Select all data in the mesh on a single axis."; + ot->idname= "MESH_OT_select_axis"; + + /* api callbacks */ + ot->exec= select_axis_exec; + ot->poll= ED_operator_editmesh; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_enum(ot->srna, "mode", axis_mode_items, 0, "Axis Mode", "Axis side to use when selecting"); + RNA_def_int(ot->srna, "axis", 0, 0, 2, "Axis", "Select the axis to compare each vertex on", 0, 2); +} + diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 9ff3a3b684c..3f79b9b4370 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -217,6 +217,7 @@ void MESH_OT_edge_rotate(struct wmOperatorType *ot); void MESH_OT_select_vertex_path(struct wmOperatorType *ot); void MESH_OT_loop_to_region(struct wmOperatorType *ot); void MESH_OT_region_to_loop(struct wmOperatorType *ot); +void MESH_OT_select_axis(struct wmOperatorType *ot); void MESH_OT_uvs_rotate(struct wmOperatorType *ot); void MESH_OT_uvs_mirror(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 1e1234d040a..9f16e7adbf8 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -109,6 +109,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_select_vertex_path); WM_operatortype_append(MESH_OT_loop_to_region); WM_operatortype_append(MESH_OT_region_to_loop); + WM_operatortype_append(MESH_OT_select_axis); WM_operatortype_append(MESH_OT_uvs_rotate); WM_operatortype_append(MESH_OT_uvs_mirror); |