From bfb633087b60f28ece96d93becee0141e964c015 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 16 Apr 2018 08:51:41 +0200 Subject: Fix object/bone select buffer big-endian sorting --- source/blender/editors/space_view3d/view3d_select.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/space_view3d/view3d_select.c') diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c38bcbcd645..6833dac558d 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -55,6 +55,10 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#ifdef __BIG_ENDIAN__ +# include "BLI_endian_switch.h" +#endif + /* vertex box select */ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -1980,11 +1984,16 @@ static int do_armature_box_select( * Compare result of 'GPU_select': 'uint[4]', * needed for when we need to align with object draw-order. */ -static int opengl_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p) +static int opengl_bone_select_buffer_cmp(const void *sel_a_p, const void *sel_b_p) { /* 4th element is select id */ - const uint sel_a = ((uint *)sel_a_p)[3]; - const uint sel_b = ((uint *)sel_b_p)[3]; + uint sel_a = ((uint *)sel_a_p)[3]; + uint sel_b = ((uint *)sel_b_p)[3]; + +#ifdef __BIG_ENDIAN__ + BLI_endian_switch_uint32(&sel_a); + BLI_endian_switch_uint32(&sel_b); +#endif if (sel_a < sel_b) { return -1; @@ -2048,7 +2057,7 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b col = vbuffer + 3; /* The draw order doesn't always match the order we populate the engine, see: T51695. */ - qsort(vbuffer, hits, sizeof(uint[4]), opengl_select_buffer_cmp); + qsort(vbuffer, hits, sizeof(uint[4]), opengl_bone_select_buffer_cmp); /* * Even though 'DRW_draw_select_loop' uses 'DEG_OBJECT_ITER_BEGIN', -- cgit v1.2.3