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>2020-03-12 09:59:17 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-03-12 11:17:39 +0300
commit0c0895e3e679a22c7bb3674a43c9e020e23c93d6 (patch)
treebff912daee78b8846e9837adb08a5349c8e435ed /source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
parentd4d9ded09bd34e0b44abd6f1269ff04b200da3f0 (diff)
Fix move-3D gizmo in use 2D spaces
This fixes node corner-pin and sun-beam gizmo's cursor offsets.
Diffstat (limited to 'source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
index d8cd4d20579..f7d22223b55 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -119,21 +119,25 @@ static void move_geom_draw(const wmGizmo *gz,
immUniformColor4fv(color);
+ /* Use the final scale as a radius if it's not already applied to the final matrix. */
+ const float radius = (gz->flag & WM_GIZMO_DRAW_NO_SCALE) ? gz->scale_final : 1.0f;
+
if (draw_style == ED_GIZMO_MOVE_STYLE_RING_2D) {
if (filled) {
- imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
+ imm_draw_circle_fill_2d(pos, 0, 0, radius, DIAL_RESOLUTION);
}
else {
- imm_draw_circle_wire_2d(pos, 0, 0, 1.0f, DIAL_RESOLUTION);
+ imm_draw_circle_wire_2d(pos, 0, 0, radius, DIAL_RESOLUTION);
}
}
else if (draw_style == ED_GIZMO_MOVE_STYLE_CROSS_2D) {
+ const float radius_diag = M_SQRT1_2 * radius;
immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, 1.0f, 1.0f);
- immVertex2f(pos, -1.0f, -1.0f);
+ immVertex2f(pos, radius_diag, radius_diag);
+ immVertex2f(pos, -radius_diag, -radius_diag);
- immVertex2f(pos, -1.0f, 1.0f);
- immVertex2f(pos, 1.0f, -1.0f);
+ immVertex2f(pos, -radius_diag, radius_diag);
+ immVertex2f(pos, radius_diag, -radius_diag);
immEnd();
}
else {
@@ -260,6 +264,9 @@ static int gizmo_move_modal(bContext *C,
return OPERATOR_RUNNING_MODAL;
}
sub_v2_v2v2(prop_delta, mval_proj_curr, mval_proj_init);
+ if ((gz->flag & WM_GIZMO_DRAW_NO_SCALE) == 0) {
+ mul_v2_fl(prop_delta, gz->scale_final);
+ }
prop_delta[2] = 0.0f;
}
@@ -394,8 +401,10 @@ static int gizmo_move_test_select(bContext *C, wmGizmo *gz, const int mval[2])
return -1;
}
- /* The 'gz->scale_final' is already applied when projecting. */
- if (len_squared_v2(point_local) < 1.0f) {
+ /* The 'gz->scale_final' is already applied to the projection
+ * when #WM_GIZMO_DRAW_NO_SCALE isn't set. */
+ const float radius = (gz->flag & WM_GIZMO_DRAW_NO_SCALE) ? gz->scale_final : 1.0f;
+ if (len_squared_v2(point_local) < radius) {
return 0;
}