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:
authorYimingWu <xp8110@outlook.com>2020-02-01 05:25:32 +0300
committerYimingWu <xp8110@outlook.com>2020-02-01 05:25:32 +0300
commitb47883a990ee68e659a8a8b44729be9b8e0d002f (patch)
tree24a7733807992fc84445d30b63deaedfe1ab40a1 /source/blender/editors/gizmo_library
parentb5abbc40a07041af91dca5d0a4acd8e5f1518c91 (diff)
parentd9ec25844b4ac3143775615469fe69b27105c108 (diff)
Merge remote-tracking branch 'origin/master' into temp-lanpr-review
Diffstat (limited to 'source/blender/editors/gizmo_library')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c32
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c2
2 files changed, 28 insertions, 6 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
index 24571f67fdb..1c8c46a2bad 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c
@@ -52,6 +52,7 @@
static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float color[4])
{
+ const int draw_style = RNA_enum_get(gz->ptr, "draw_style");
const float size = 0.11f;
const float size_breadth = size / 2.0f;
const float size_length = size * 1.7f;
@@ -74,11 +75,21 @@ static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float
immVertex2f(pos, 0.0f, arrow_length);
immEnd();
- immBegin(GPU_PRIM_TRIS, 3);
- immVertex2f(pos, size_breadth, arrow_length);
- immVertex2f(pos, -size_breadth, arrow_length);
- immVertex2f(pos, 0.0f, arrow_length + size_length);
- immEnd();
+ if (draw_style == ED_GIZMO_ARROW_STYLE_BOX) {
+ immBegin(GPU_PRIM_TRI_FAN, 4);
+ immVertex2f(pos, -size / 2, arrow_length);
+ immVertex2f(pos, size / 2, arrow_length);
+ immVertex2f(pos, size / 2, arrow_length + size);
+ immVertex2f(pos, -size / 2, arrow_length + size);
+ immEnd();
+ }
+ else {
+ immBegin(GPU_PRIM_TRIS, 3);
+ immVertex2f(pos, size_breadth, arrow_length);
+ immVertex2f(pos, -size_breadth, arrow_length);
+ immVertex2f(pos, 0.0f, arrow_length + size_length);
+ immEnd();
+ }
immUnbindProgram();
@@ -197,6 +208,11 @@ static void GIZMO_GT_arrow_2d(wmGizmoType *gzt)
gzt->struct_size = sizeof(wmGizmo);
/* rna */
+ static EnumPropertyItem rna_enum_draw_style_items[] = {
+ {ED_GIZMO_ARROW_STYLE_NORMAL, "NORMAL", 0, "Normal", ""},
+ {ED_GIZMO_ARROW_STYLE_BOX, "BOX", 0, "Box", ""},
+ {0, NULL, 0, NULL, NULL},
+ };
RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX);
RNA_def_float_rotation(gzt->srna,
"angle",
@@ -208,6 +224,12 @@ static void GIZMO_GT_arrow_2d(wmGizmoType *gzt)
"",
DEG2RADF(-360.0f),
DEG2RADF(360.0f));
+ RNA_def_enum(gzt->srna,
+ "draw_style",
+ rna_enum_draw_style_items,
+ ED_GIZMO_ARROW_STYLE_NORMAL,
+ "Draw Style",
+ "");
}
void ED_gizmotypes_arrow_2d(void)
diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
index 7e6db43dbb3..ef3014eabc2 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
@@ -286,7 +286,7 @@ static int gizmo_button2d_test_select(bContext *C, wmGizmo *gz, const int mval[2
else {
copy_v2_v2(point_local, (float[2]){UNPACK2(mval)});
sub_v2_v2(point_local, gz->matrix_basis[3]);
- mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC));
+ mul_v2_fl(point_local, 1.0f / gz->scale_final);
}
/* The 'gz->scale_final' is already applied when projecting. */
if (len_squared_v2(point_local) < 1.0f) {