Fix for [#20180] Wrong multiplicator in Random Selection
Also: Added extend select option to select random (off by default) Tweaked 'Select Axis' to use an enum for axes
This commit is contained in:
@@ -3582,14 +3582,11 @@ void MESH_OT_select_less(wmOperatorType *ot)
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
|
||||
static void selectrandom_mesh(EditMesh *em, float perc) /* randomly selects a user-set % of vertices/edges/faces */
|
||||
static void selectrandom_mesh(EditMesh *em, float randfac) /* randomly selects a user-set % of vertices/edges/faces */
|
||||
{
|
||||
EditVert *eve;
|
||||
EditEdge *eed;
|
||||
EditFace *efa;
|
||||
float randfac= perc;
|
||||
/* Get the percentage of vertices to randomly select as 'randfac' */
|
||||
// XXX if(button(&randfac,0, 100,"Percentage:")==0) return;
|
||||
|
||||
BLI_srand( BLI_rand() ); /* random seed */
|
||||
|
||||
@@ -3629,7 +3626,10 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op)
|
||||
Object *obedit= CTX_data_edit_object(C);
|
||||
EditMesh *em= BKE_mesh_get_editmesh(((Mesh *)obedit->data));
|
||||
|
||||
selectrandom_mesh(em, RNA_float_get(op->ptr,"percent"));
|
||||
if(!RNA_boolean_get(op->ptr, "extend"))
|
||||
EM_deselect_all(em);
|
||||
|
||||
selectrandom_mesh(em, RNA_float_get(op->ptr, "percentage")/100.0f);
|
||||
|
||||
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
|
||||
|
||||
@@ -3646,14 +3646,14 @@ void MESH_OT_select_random(wmOperatorType *ot)
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= mesh_select_random_exec;
|
||||
ot->invoke= WM_operator_props_popup;
|
||||
ot->poll= ED_operator_editmesh;
|
||||
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
|
||||
/* props */
|
||||
RNA_def_float_percentage(ot->srna, "percent", 50.0f, 0.0f, 100.0f, "Percent", "Percentage of vertices to select randomly.", 0.0001f, 1.0f);
|
||||
RNA_def_float_percentage(ot->srna, "percentage", 50.f, 0.0f, 100.0f, "Percentage", "Percentage of elements to select randomly.", 0.f, 100.0f);
|
||||
RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "");
|
||||
}
|
||||
|
||||
void EM_select_by_material(EditMesh *em, int index)
|
||||
|
||||
@@ -7192,7 +7192,7 @@ 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 axis= RNA_enum_get(op->ptr, "axis");
|
||||
int mode= RNA_enum_get(op->ptr, "mode"); /* -1==aligned, 0==neg, 1==pos*/
|
||||
|
||||
EditSelection *ese = em->selected.last;
|
||||
@@ -7243,6 +7243,12 @@ void MESH_OT_select_axis(wmOperatorType *ot)
|
||||
{1, "NEGATIVE", 0, "Negative Axis", ""},
|
||||
{-1, "ALIGNED", 0, "Aligned Axis", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem axis_items[] = {
|
||||
{0, "X_AXIS", 0, "X Axis", ""},
|
||||
{1, "Y_AXIS", 0, "Y Axis", ""},
|
||||
{2, "Z_AXIS", 0, "Z Axis", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Select Axis";
|
||||
@@ -7258,6 +7264,6 @@ void MESH_OT_select_axis(wmOperatorType *ot)
|
||||
|
||||
/* 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);
|
||||
RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Select the axis to compare each vertex on");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user