GPU_select: correction to select-pick-finalize
authorCampbell Barton <ideasman42@gmail.com>
Tue, 27 Feb 2018 09:44:12 +0000 (20:44 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 27 Feb 2018 09:44:12 +0000 (20:44 +1100)
Would run twice, harmless at the moment but could cause issues later.

source/blender/gpu/intern/gpu_select_pick.c

index d7a3ad075584865614ad082b818dd2d245ed7daf..bd6b43ee42fdbf8857a6f3a78eb32cecf16528a5 100644 (file)
@@ -255,6 +255,7 @@ typedef struct GPUPickState {
 
                /* Set after first draw */
                bool is_init;
+               bool is_finalized;
                unsigned int prev_id;
        } gl;
 
@@ -366,6 +367,7 @@ void gpu_select_pick_begin(
 #endif
 
                ps->gl.is_init = false;
+               ps->gl.is_finalized = false;
                ps->gl.prev_id = 0;
        }
        else {
@@ -537,6 +539,7 @@ void gpu_select_pick_finalize(void)
                /* force finishing last pass */
                gpu_select_pick_load_id(ps->gl.prev_id);
        }
+       ps->gl.is_finalized = true;
 }
 
 unsigned int gpu_select_pick_end(void)
@@ -548,7 +551,9 @@ unsigned int gpu_select_pick_end(void)
 #endif
 
        if (ps->is_cached == false) {
-               gpu_select_pick_finalize();
+               if (ps->gl.is_finalized == false) {
+                       gpu_select_pick_finalize();
+               }
 
                glPopAttrib();
                glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);