Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-06-17 08:32:47 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-06-17 08:32:47 +0300
commita56de26704e653f71d6c0a289070117b02263270 (patch)
tree906e359f73a3d08241ee5d0f251c3bd6d4c46ed1 /source/blender
parent865bf8ecbc1cf3aac3107cbb70b2e94d8e239adc (diff)
Manipulator: draw options for dial
- Option to start helper angle lines based on a vector instead of the initial mouse coords (useful for bisect & spin). - Option to show 2x helper lines useful when dial is used to rotate an axis value.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/editors/include/ED_manipulator_library.h5
-rw-r--r--source/blender/editors/manipulator_library/dial3d_manipulator.c50
-rw-r--r--source/blender/editors/mesh/editmesh_bisect.c6
-rw-r--r--source/blender/editors/mesh/editmesh_extrude.c4
4 files changed, 58 insertions, 7 deletions
diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h
index 7d92f4311d4..8d74ed941d0 100644
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -119,7 +119,10 @@ enum {
void ED_manipulator_dial3d_set_style(struct wmManipulator *mpr, int style);
void ED_manipulator_dial3d_set_up_vector(
struct wmManipulator *mpr, const float direction[3]);
-
+void ED_manipulator_dial3d_set_start_vector(
+ struct wmManipulator *mpr, const bool enabled, const float direction[3]);
+void ED_manipulator_dial3d_set_double_helper(
+ struct wmManipulator *mpr, const bool enabled);
/* -------------------------------------------------------------------- */
/* Grab Manipulator */
diff --git a/source/blender/editors/manipulator_library/dial3d_manipulator.c b/source/blender/editors/manipulator_library/dial3d_manipulator.c
index a0317fc34b2..283732c862f 100644
--- a/source/blender/editors/manipulator_library/dial3d_manipulator.c
+++ b/source/blender/editors/manipulator_library/dial3d_manipulator.c
@@ -70,6 +70,15 @@ typedef struct DialManipulator {
wmManipulator manipulator;
int style;
float direction[3];
+
+ /* Optional, for drawing the start of the pie based on on a vector
+ * instead of the initial mouse location. Only for display. */
+ float start_direction[3];
+ uint use_start_direction : 1;
+
+ /* Show 2x helper angles (a mirrored segment).
+ * Use when the dial represents a plane. */
+ uint use_double_helper : 1;
} DialManipulator;
typedef struct DialInteraction {
@@ -230,8 +239,11 @@ static void dial_ghostarc_get_angles(
madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda);
sub_v3_v3(proj_mval_new_rel, dial->manipulator.origin);
+ /* Start direction from mouse or set by user */
+ const float *proj_init_rel = dial->use_start_direction ? dial->start_direction : proj_mval_init_rel;
+
/* return angles */
- const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_mval_init_rel, axis_vec));
+ const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec));
const float delta = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_mval_init_rel, proj_mval_new_rel, axis_vec));
/* Change of sign, we passed the 180 degree threshold. This means we need to add a turn
@@ -288,14 +300,21 @@ static void dial_draw_intern(
manipulator_dial_modal((bContext *)C, &dial->manipulator, win->eventstate, 0);
}
- const float angle_ofs = inter->output.angle_ofs;
- const float angle_delta = inter->output.angle_delta;
+ float angle_ofs = inter->output.angle_ofs;
+ float angle_delta = inter->output.angle_delta;
/* draw! */
- dial_ghostarc_draw(dial, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f});
+ for (int i = 0; i < 2; i++) {
+ dial_ghostarc_draw(dial, angle_ofs, angle_delta, (const float [4]){0.8f, 0.8f, 0.8f, 0.4f});
- dial_ghostarc_draw_helpline(angle_ofs, co_outer, col); /* starting position */
- dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, col); /* starting position + current value */
+ dial_ghostarc_draw_helpline(angle_ofs, co_outer, col); /* starting position */
+ dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, col); /* starting position + current value */
+ if (dial->use_double_helper == false) {
+ break;
+ }
+
+ angle_ofs += M_PI;
+ }
}
/* draw actual dial manipulator */
@@ -437,6 +456,25 @@ void ED_manipulator_dial3d_set_up_vector(wmManipulator *mpr, const float directi
normalize_v3(dial->direction);
}
+void ED_manipulator_dial3d_set_start_vector(wmManipulator *mpr, const bool enabled, const float direction[3])
+{
+ ASSERT_TYPE_CHECK(mpr);
+ DialManipulator *dial = (DialManipulator *)mpr;
+
+ dial->use_start_direction = enabled;
+ if (enabled) {
+ normalize_v3_v3(dial->start_direction, direction);
+ }
+}
+
+void ED_manipulator_dial3d_set_double_helper(wmManipulator *mpr, const bool enabled)
+{
+ ASSERT_TYPE_CHECK(mpr);
+ DialManipulator *dial = (DialManipulator *)mpr;
+
+ dial->use_double_helper = enabled;
+}
+
static void MANIPULATOR_WT_dial_3d_3d(wmManipulatorType *wt)
{
/* identifiers */
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c
index 9bb847c2be1..8499949f589 100644
--- a/source/blender/editors/mesh/editmesh_bisect.c
+++ b/source/blender/editors/mesh/editmesh_bisect.c
@@ -444,6 +444,12 @@ static void manipulator_mesh_bisect_update_from_op(ManipulatorGroup *man)
ED_manipulator_grab3d_set_up_vector(man->translate_c, plane_no);
ED_manipulator_dial3d_set_up_vector(man->rotate_c, man->data.rotate_axis);
+
+ float plane_no_cross[3];
+ cross_v3_v3v3(plane_no_cross, plane_no, man->data.rotate_axis);
+
+ ED_manipulator_dial3d_set_start_vector(man->rotate_c, true, plane_no_cross);
+ ED_manipulator_dial3d_set_double_helper(man->rotate_c, true);
}
}
diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c
index e3c99fb4883..42683960407 100644
--- a/source/blender/editors/mesh/editmesh_extrude.c
+++ b/source/blender/editors/mesh/editmesh_extrude.c
@@ -879,6 +879,10 @@ static void manipulator_mesh_spin_update_from_op(ManipulatorSpinGroup *man)
ED_manipulator_grab3d_set_up_vector(man->translate_c, plane_no);
ED_manipulator_dial3d_set_up_vector(man->rotate_c, man->data.rotate_axis);
+
+ /* show the axis instead of mouse cursor */
+ ED_manipulator_dial3d_set_start_vector(man->rotate_c, true, plane_no);
+ ED_manipulator_dial3d_set_double_helper(man->rotate_c, true);
}
}