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>2017-06-02 09:35:58 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-06-02 09:38:35 +0300
commit678a6b6c49aabc215dc90bc07d41529cce82b6e1 (patch)
treed84174bcafb62ba58e705c930c4aeeb8ee1f1ad5 /source/blender/editors/space_view3d/view3d_select.c
parenteae486f5e6c79b7b31e276dfaea69d2ece7fbf7f (diff)
Fix T51695: Border select fails w/ lamps
Draw order doesn't match scene order when mixing object types.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_select.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index a15e4baced2..1686a08654d 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -1993,6 +1993,27 @@ static int do_armature_box_select(ViewContext *vc, rcti *rect, bool select, bool
return hits > 0 ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
+/**
+ * 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)
+{
+ /* 4th element is select id */
+ const uint sel_a = ((uint *)sel_a_p)[3];
+ const uint sel_b = ((uint *)sel_b_p)[3];
+
+ if (sel_a < sel_b) {
+ return -1;
+ }
+ else if (sel_a > sel_b) {
+ return 1;
+ }
+ else {
+ return 0;
+ }
+}
+
static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, bool select, bool extend)
{
Bone *bone;
@@ -2034,15 +2055,19 @@ static int do_object_pose_box_select(bContext *C, ViewContext *vc, rcti *rect, b
* is the same as the object, we have a hit and can move to the next color
* and object pair, if not, just move to the next object,
* keeping the same color until we have a hit.
- *
- * The buffer order is defined by OGL standard, hopefully no stupid GFX card
- * does it incorrectly.
*/
if (hits > 0) { /* no need to loop if there's no hit */
Base *base;
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);
+
+ /*
+ * Even though 'DRW_draw_select_loop' uses 'DEG_OBJECT_ITER',
+ * we can be sure the order remains the same between both.
+ */
for (base = vc->scene_layer->object_bases.first; base && hits; base = base->next) {
if (BASE_SELECTABLE_NEW(base)) {
while (base->selcol == (*col & 0xFFFF)) { /* we got an object */