Cleanup: move gizmo sort functions into an API
This commit is contained in:
parent
a2922f9840
commit
40f679ccb9
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue