Commit: 40f679ccb9370a3827a2ac44b8bab40290768548 Author: Campbell Barton Date: Thu Oct 18 11:26:03 2018 +1100 Branches: blender2.8 https://developer.blender.org/rB40f679ccb9370a3827a2ac44b8bab40290768548
Cleanup: move gizmo sort functions into an API =================================================================== M source/blender/editors/mesh/editmesh_extrude_gizmo.c M source/blender/windowmanager/gizmo/WM_gizmo_api.h M source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c =================================================================== diff --git a/source/blender/editors/mesh/editmesh_extrude_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_gizmo.c index e0b1f5e9916..83c88b94ace 100644 --- a/source/blender/editors/mesh/editmesh_extrude_gizmo.c +++ b/source/blender/editors/mesh/editmesh_extrude_gizmo.c @@ -337,15 +337,6 @@ static void gizmo_mesh_extrude_refresh(const bContext *C, wmGizmoGroup *gzgroup) } } -static int gizmo_cmp_temp_f(const void *gz_a_ptr, const void *gz_b_ptr) -{ - const wmGizmo *gz_a = gz_a_ptr; - const wmGizmo *gz_b = gz_b_ptr; - if (gz_a->temp.f < gz_b->temp.f) return -1; - else if (gz_a->temp.f > gz_b->temp.f) return 1; - else return 0; -} - static void gizmo_mesh_extrude_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) { GizmoExtrudeGroup *ggd = gzgroup->customdata; @@ -365,9 +356,9 @@ static void gizmo_mesh_extrude_draw_prepare(const bContext *C, wmGizmoGroup *gzg { RegionView3D *rv3d = CTX_wm_region_view3d(C); LISTBASE_FOREACH (wmGizmo *, gz, &gzgroup->gizmos) { - gz->temp.f = -dot_v3v3(rv3d->viewinv[2], gz->matrix_offset[3]); + gz->temp.f = dot_v3v3(rv3d->viewinv[2], gz->matrix_offset[3]); } - BLI_listbase_sort(&gzgroup->gizmos, gizmo_cmp_temp_f); + BLI_listbase_sort(&gzgroup->gizmos, WM_gizmo_cmp_temp_fl_reverse); } } diff --git a/source/blender/windowmanager/gizmo/WM_gizmo_api.h b/source/blender/windowmanager/gizmo/WM_gizmo_api.h index 153840986ef..9f05437eaa8 100644 --- a/source/blender/windowmanager/gizmo/WM_gizmo_api.h +++ b/source/blender/windowmanager/gizmo/WM_gizmo_api.h @@ -240,6 +240,9 @@ struct wmKeyMap *WM_gizmogroup_keymap_common( struct wmKeyMap *WM_gizmogroup_keymap_common_select( const struct wmGizmoGroupType *gzgt, struct wmKeyConfig *config); +/* Sort utilities for use with 'BLI_listbase_sort'. */ +int WM_gizmo_cmp_temp_fl(const void *gz_a_ptr, const void *gz_b_ptr); +int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr); /* -------------------------------------------------------------------- */ /* wmGizmoMap */ diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c index 9cc8bacd20b..90a0ff8b651 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_group.c @@ -147,6 +147,24 @@ void wm_gizmogroup_gizmo_register(wmGizmoGroup *gzgroup, wmGizmo *gz) gz->parent_gzgroup = gzgroup; } +int WM_gizmo_cmp_temp_fl(const void *gz_a_ptr, const void *gz_b_ptr) +{ + const wmGizmo *gz_a = gz_a_ptr; + const wmGizmo *gz_b = gz_b_ptr; + if (gz_a->temp.f < gz_b->temp.f) return -1; + else if (gz_a->temp.f > gz_b->temp.f) return 1; + else return 0; +} + +int WM_gizmo_cmp_temp_fl_reverse(const void *gz_a_ptr, const void *gz_b_ptr) +{ + const wmGizmo *gz_a = gz_a_ptr; + const wmGizmo *gz_b = gz_b_ptr; + if (gz_a->temp.f < gz_b->temp.f) return 1; + else if (gz_a->temp.f > gz_b->temp.f) return -1; + else return 0; +} + wmGizmo *wm_gizmogroup_find_intersected_gizmo( const wmGizmoGroup *gzgroup, bContext *C, const wmEvent *event, int *r_part) _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs