diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-06-16 23:13:44 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-06-16 23:14:29 +0300 |
commit | df017f7867ebb4a7a9c78f77d2b9deb2ffd54278 (patch) | |
tree | b14e7a239b0f5b91b5e2547445342d06266f60c1 /source/blender/editors/mesh | |
parent | 2b8d599b3a93c78661ff9a2c460b7144278409be (diff) |
Manipulator: New grab preset, use for bisect
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_bisect.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 199ac050b5a..2ad457f1190 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -389,6 +389,8 @@ void MESH_OT_bisect(struct wmOperatorType *ot) typedef struct ManipulatorGroup { /* Arrow to change plane depth. */ struct wmManipulator *translate_z; + /* Translate XYZ */ + struct wmManipulator *translate_c; /* For grabbing the manipulator and moving freely. */ struct wmManipulator *rotate_c; @@ -427,10 +429,13 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man) RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); WM_manipulator_set_origin(man->translate_z, plane_co); + WM_manipulator_set_origin(man->translate_c, plane_co); WM_manipulator_set_origin(man->rotate_c, plane_co); ED_manipulator_arrow3d_set_direction(man->translate_z, plane_no); + WM_manipulator_set_scale(man->translate_c, 0.2); + RegionView3D *rv3d = ED_view3d_context_rv3d(man->data.context); if (rv3d) { normalize_v3_v3(man->data.rotate_axis, rv3d->viewinv[2]); @@ -440,6 +445,7 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man) project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis); normalize_v3(man->data.rotate_up); + ED_manipulator_grab3d_set_up_vector(man->translate_c, plane_no); ED_manipulator_dial3d_set_up_vector(man->rotate_c, man->data.rotate_axis); } } @@ -485,6 +491,32 @@ static void manipulator_bisect_prop_depth_set( manipulator_bisect_exec(man); } +/* translate callbacks */ +static void manipulator_bisect_prop_translate_get( + const wmManipulator *mpr, wmManipulatorProperty *UNUSED(mpr_prop), void *UNUSED(user_data), + float *value, uint value_len) +{ + ManipulatorGroup *man = mpr->parent_mgroup->customdata; + wmOperator *op = man->data.op; + + BLI_assert(value_len == 3); + RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, value); +} + +static void manipulator_bisect_prop_translate_set( + const wmManipulator *mpr, wmManipulatorProperty *UNUSED(mpr_prop), void *UNUSED(user_data), + const float *value, uint value_len) +{ + ManipulatorGroup *man = mpr->parent_mgroup->customdata; + wmOperator *op = man->data.op; + + BLI_assert(value_len == 3); + RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, value); + + manipulator_bisect_exec(man); +} + + /* angle callbacks */ static void manipulator_bisect_prop_angle_get( const wmManipulator *mpr, wmManipulatorProperty *UNUSED(mpr_prop), void *UNUSED(user_data), @@ -563,8 +595,10 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup mgroup->customdata = man; man->translate_z = ED_manipulator_arrow3d_new(mgroup, "translate_z", ED_MANIPULATOR_ARROW_STYLE_NORMAL); + man->translate_c = ED_manipulator_grab3d_new(mgroup, "translate_c", 0); man->rotate_c = ED_manipulator_dial3d_new(mgroup, "rotate_c", ED_MANIPULATOR_DIAL_STYLE_RING); + WM_manipulator_set_flag(man->translate_c, WM_MANIPULATOR_DRAW_VALUE, true); WM_manipulator_set_flag(man->rotate_c, WM_MANIPULATOR_DRAW_VALUE, true); { @@ -588,6 +622,15 @@ static void manipulator_mesh_bisect_setup(const bContext *C, wmManipulatorGroup }); WM_manipulator_property_def_func( + man->translate_c, "offset", + &(const struct wmManipulatorPropertyFnParams) { + .value_get_fn = manipulator_bisect_prop_translate_get, + .value_set_fn = manipulator_bisect_prop_translate_set, + .range_get_fn = NULL, + .user_data = NULL, + }); + + WM_manipulator_property_def_func( man->rotate_c, "offset", &(const struct wmManipulatorPropertyFnParams) { .value_get_fn = manipulator_bisect_prop_angle_get, |