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>2021-04-19 10:36:51 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-04-19 10:36:51 +0300
commiteae39a49737698a8a84d23ba34f632d497e2d7c1 (patch)
tree58c0c24d57412f1ffc583c41c0d32aa75b4e038e /source/blender/editors/gizmo_library
parent0af28f007f46eb0879cd06a9e0b064f372c5580a (diff)
parent9175911ffabefcd00f15d847ffdf8afe5efadb10 (diff)
Merge branch 'blender-v2.93-release'
Diffstat (limited to 'source/blender/editors/gizmo_library')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c40
1 files changed, 35 insertions, 5 deletions
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 f4c4e4eb2ac..d99ce25451c 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c
@@ -320,14 +320,44 @@ static int gizmo_button2d_cursor_get(wmGizmo *gz)
return WM_CURSOR_DEFAULT;
}
-static void gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box)
+static bool gizmo_button2d_bounds(bContext *C, wmGizmo *gz, rcti *r_bounding_box)
{
ScrArea *area = CTX_wm_area(C);
float rad = CIRCLE_RESOLUTION * U.dpi_fac / 2.0f;
- r_bounding_box->xmin = gz->matrix_basis[3][0] + area->totrct.xmin - rad;
- r_bounding_box->ymin = gz->matrix_basis[3][1] + area->totrct.ymin - rad;
- r_bounding_box->xmax = r_bounding_box->xmin + rad;
- r_bounding_box->ymax = r_bounding_box->ymin + rad;
+ const float *co = NULL;
+ float matrix_final[4][4];
+ float co_proj[3];
+ WM_gizmo_calc_matrix_final(gz, matrix_final);
+
+ if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) {
+ ARegion *region = CTX_wm_region(C);
+ if (ED_view3d_project_float_global(region, matrix_final[3], co_proj, V3D_PROJ_TEST_NOP) ==
+ V3D_PROJ_RET_OK) {
+ float matrix_final_no_offset[4][4];
+ const RegionView3D *rv3d = region->regiondata;
+ WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset);
+ const float factor = ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_final_no_offset[3]) /
+ ED_view3d_pixel_size_no_ui_scale(rv3d, matrix_final[3]);
+ /* It's possible (although unlikely) `matrix_final_no_offset` is behind the view.
+ * `matrix_final` has already been projected so both can't be negative. */
+ if (factor > 0.0f) {
+ rad *= factor;
+ }
+ co = co_proj;
+ }
+ }
+ else {
+ co = matrix_final[3];
+ }
+
+ if (co != NULL) {
+ r_bounding_box->xmin = co[0] + area->totrct.xmin - rad;
+ r_bounding_box->ymin = co[1] + area->totrct.ymin - rad;
+ r_bounding_box->xmax = r_bounding_box->xmin + rad;
+ r_bounding_box->ymax = r_bounding_box->ymin + rad;
+ return true;
+ }
+ return false;
}
static void gizmo_button2d_free(wmGizmo *gz)