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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-09-18 07:13:35 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-18 07:13:35 +0300
commitf677ff274c6815d9aa8e0e16fe0dbbdd3d33990c (patch)
tree07e7b3c268e797666c0b16287b7e669002e67872 /source
parentadd961c2097287bb338072aae82e1564bc8714a2 (diff)
Cleanup: group gizmo dial members into structs
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
index f6108134cd9..a47474e6e85 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
@@ -75,13 +75,17 @@ static int gizmo_dial_modal(
eWM_GizmoFlagTweak tweak_flag);
typedef struct DialInteraction {
- float init_mval[2];
+ struct {
+ float mval[2];
+ /* only for when using properties */
+ float prop_angle;
+ } init;
- /* only for when using properties */
- float init_prop_angle;
+ struct {
+ /* Cache the last angle to detect rotations bigger than -/+ PI. */
+ float angle;
+ } prev;
- /* cache the last angle to detect rotations bigger than -/+ PI */
- float last_angle;
/* number of full rotations */
int rotations;
@@ -223,7 +227,7 @@ static void dial_ghostarc_get_angles(
plane_from_point_normal_v3(dial_plane, gz->matrix_basis[3], axis_vec);
- if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init_mval, ray_co, ray_no, false) ||
+ if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init.mval, ray_co, ray_no, false) ||
!isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false))
{
goto fail;
@@ -253,15 +257,15 @@ static void dial_ghostarc_get_angles(
/* Change of sign, we passed the 180 degree threshold. This means we need to add a turn
* to distinguish between transition from 0 to -1 and -PI to +PI, use comparison with PI/2.
* Logic taken from BLI_dial_angle */
- if ((delta * inter->last_angle < 0.0f) &&
- (fabsf(inter->last_angle) > (float)M_PI_2))
+ if ((delta * inter->prev.angle < 0.0f) &&
+ (fabsf(inter->prev.angle) > (float)M_PI_2))
{
- if (inter->last_angle < 0.0f)
+ if (inter->prev.angle < 0.0f)
inter->rotations--;
else
inter->rotations++;
}
- inter->last_angle = delta;
+ inter->prev.angle = delta;
*r_start = start;
*r_delta = fmod(delta + 2.0f * (float)M_PI * inter->rotations, 2 * (float)M_PI);
@@ -419,7 +423,7 @@ static int gizmo_dial_modal(
/* set the property for the operator and call its modal function */
wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
if (WM_gizmo_target_property_is_valid(gz_prop)) {
- WM_gizmo_target_property_float_set(C, gz, gz_prop, inter->init_prop_angle + angle_delta);
+ WM_gizmo_target_property_float_set(C, gz, gz_prop, inter->init.prop_angle + angle_delta);
}
return OPERATOR_RUNNING_MODAL;
}
@@ -438,12 +442,12 @@ static int gizmo_dial_invoke(
{
DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__);
- inter->init_mval[0] = event->mval[0];
- inter->init_mval[1] = event->mval[1];
+ inter->init.mval[0] = event->mval[0];
+ inter->init.mval[1] = event->mval[1];
wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset");
if (WM_gizmo_target_property_is_valid(gz_prop)) {
- inter->init_prop_angle = WM_gizmo_target_property_float_get(gz, gz_prop);
+ inter->init.prop_angle = WM_gizmo_target_property_float_get(gz, gz_prop);
}
gz->interaction_data = inter;