selectrandom mesh , temp using space key
This commit is contained in:
@@ -3555,12 +3555,11 @@ void MESH_OT_select_less(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
void selectrandom_mesh(EditMesh *em) /* randomly selects a user-set % of vertices/edges/faces */
|
||||
void selectrandom_mesh(EditMesh *em, int randfac) /* randomly selects a user-set % of vertices/edges/faces */
|
||||
{
|
||||
EditVert *eve;
|
||||
EditEdge *eed;
|
||||
EditFace *efa;
|
||||
static short randfac = 50;
|
||||
|
||||
/* Get the percentage of vertices to randomly select as 'randfac' */
|
||||
// XXX if(button(&randfac,0, 100,"Percentage:")==0) return;
|
||||
@@ -3598,6 +3597,37 @@ void selectrandom_mesh(EditMesh *em) /* randomly selects a user-set % of vertice
|
||||
// if (EM_texFaceCheck())
|
||||
}
|
||||
|
||||
static int selectrandom_mesh_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= ((Mesh *)obedit->data)->edit_mesh;
|
||||
|
||||
selectrandom_mesh(em, RNA_int_get(op->ptr,"percentage"));
|
||||
|
||||
WM_event_add_notifier(C, NC_OBJECT|ND_GEOM_SELECT, obedit);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void MESH_OT_selectrandom_mesh(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Select random mesh";
|
||||
ot->idname= "MESH_OT_selectrandom_mesh";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= selectrandom_mesh_exec;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER/*|OPTYPE_UNDO*/;
|
||||
|
||||
/* props */
|
||||
|
||||
|
||||
RNA_def_int(ot->srna, "percentage", 50, 0, 100, "percentage", "", 0, 100);
|
||||
}
|
||||
|
||||
void editmesh_select_by_material(EditMesh *em, int index)
|
||||
{
|
||||
EditFace *efa;
|
||||
|
||||
@@ -189,6 +189,7 @@ void MESH_OT_shortest_path_select(struct wmOperatorType *ot);
|
||||
void MESH_OT_similar_vertex_select(struct wmOperatorType *ot);
|
||||
void MESH_OT_similar_edge_select(struct wmOperatorType *ot);
|
||||
void MESH_OT_similar_face_select(struct wmOperatorType *ot);
|
||||
void MESH_OT_selectrandom_mesh(struct wmOperatorType *ot);
|
||||
|
||||
extern EditEdge *findnearestedge(ViewContext *vc, int *dist);
|
||||
extern void EM_automerge(int update);
|
||||
|
||||
@@ -113,6 +113,7 @@ void ED_operatortypes_mesh(void)
|
||||
WM_operatortype_append(MESH_OT_select_non_manifold);
|
||||
WM_operatortype_append(MESH_OT_selectconnected_mesh_all);
|
||||
WM_operatortype_append(MESH_OT_selectconnected_mesh);
|
||||
WM_operatortype_append(MESH_OT_selectrandom_mesh);
|
||||
WM_operatortype_append(MESH_OT_hide_mesh);
|
||||
WM_operatortype_append(MESH_OT_reveal_mesh);
|
||||
WM_operatortype_append(MESH_OT_consistant_normals);
|
||||
@@ -182,7 +183,9 @@ void ED_keymap_mesh(wmWindowManager *wm)
|
||||
RNA_boolean_set(WM_keymap_add_item(keymap, "MESH_OT_selectconnected_mesh", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "deselect", 1);
|
||||
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_linked_flat_faces", FKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_sharp_edges", SKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0);
|
||||
RNA_float_set(WM_keymap_add_item(keymap, "MESH_OT_select_sharp_edges", SKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0)->ptr,"sharpness",135.0);
|
||||
|
||||
WM_keymap_add_item(keymap, "MESH_OT_selectrandom_mesh", SPACEKEY, KM_PRESS, 0, 0);
|
||||
|
||||
/* temp hotkeys! */
|
||||
WM_keymap_add_item(keymap, "MESH_OT_similar_vertex_select", GKEY, KM_PRESS, KM_SHIFT, 0);
|
||||
|
||||
Reference in New Issue
Block a user