diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-04-30 22:47:06 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-04-30 22:47:06 +0400 |
commit | 4734a3321516283d1f2557818ddeb155aa34c56b (patch) | |
tree | d09129769e507920ca007a5093bb7e7a21c5ebdf /source/blender/editors | |
parent | f86565c90e8351ad271b6caaed9d234ab0e069cf (diff) |
Fix #27224: Extrude Repeat Mesh doesn't have options
Poll function was too strict for this case that's why there was
no options in operator panel.
Additional changes:
- Added 'direction' parameter to operator so now extruding
could be made from script by providing direction vector.
- Fill this direction vection in operator's invoke functions
so abjusting offset/steps in operator panel gives better visual
feedback -- direction stays unchanged so user could easily see
final result.
- Made some tweaks to soft limits, so adjusting values by mouse
drag isn't such confusing now.
Tested in normal mode (from 3d view), as script and in background mode.
Haven't noticed any regressions.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/mesh/editmesh_tools.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 5901a36980c..a66c72bf329 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -891,13 +891,11 @@ void MESH_OT_split(wmOperatorType *ot) } -static int extrude_repeat_mesh(bContext *C, wmOperator *op) +static int extrude_repeat_mesh_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); - RegionView3D *rv3d = ED_view3d_context_rv3d(C); - int steps = RNA_int_get(op->ptr,"steps"); float offs = RNA_float_get(op->ptr,"offset"); @@ -906,9 +904,7 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) short a; /* dvec */ - dvec[0]= rv3d->persinv[2][0]; - dvec[1]= rv3d->persinv[2][1]; - dvec[2]= rv3d->persinv[2][2]; + RNA_float_get_array(op->ptr, "direction", dvec); normalize_v3(dvec); dvec[0]*= offs; dvec[1]*= offs; @@ -935,6 +931,17 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* get center and axis, in global coords */ +static int extrude_repeat_mesh_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + RegionView3D *rv3d= ED_view3d_context_rv3d(C); + + if(rv3d) + RNA_float_set_array(op->ptr, "direction", rv3d->persinv[2]); + + return extrude_repeat_mesh_exec(C, op); +} + void MESH_OT_extrude_repeat(wmOperatorType *ot) { /* identifiers */ @@ -943,15 +950,17 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) ot->idname= "MESH_OT_extrude_repeat"; /* api callbacks */ - ot->exec= extrude_repeat_mesh; - ot->poll= ED_operator_editmesh_region_view3d; + ot->invoke= extrude_repeat_mesh_invoke; + ot->exec= extrude_repeat_mesh_exec; + ot->poll= ED_operator_editmesh; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, FLT_MAX); - RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, INT_MAX); + RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, 100.0f); + RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, 180); + RNA_def_float_vector(ot->srna, "direction", 3, NULL, -FLT_MAX, FLT_MAX, "Direction", "Direction of extrude", -FLT_MAX, FLT_MAX); } /* ************************** spin operator ******************** */ |