diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-06-10 10:50:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-06-10 11:04:01 +0300 |
commit | fc8a7a44b200e37066a8753c514564c674eace30 (patch) | |
tree | 5693da7412b5ca8f9a5552b9c59754cf4c11c9b1 /source/blender/gpu | |
parent | edb4e553f506c858e7df5e45ad6235cd59a181eb (diff) |
Fix T77560: Bone selection crashes
The was caused by 8b347fc2cdc67 as the old BONESEL_NOSEL flag
handled the -1 case (used for none).
Instead of checking for -1, remove these elements from the array
as selection code makes decisions based on the number of hits detected.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_select.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_select.c | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_select.h b/source/blender/gpu/GPU_select.h index 41d580f9b6d..d9a8e964a3d 100644 --- a/source/blender/gpu/GPU_select.h +++ b/source/blender/gpu/GPU_select.h @@ -57,6 +57,7 @@ void GPU_select_cache_end(void); /* utilities */ const uint *GPU_select_buffer_near(const uint *buffer, int hits); +uint GPU_select_buffer_remove_by_id(uint *buffer, int hits, uint select_id); void GPU_select_buffer_stride_realign(const struct rcti *src, const struct rcti *dst, uint *r_buf); #ifdef __cplusplus diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c index 1776f0f391d..5766a176a96 100644 --- a/source/blender/gpu/intern/gpu_select.c +++ b/source/blender/gpu/intern/gpu_select.c @@ -213,6 +213,24 @@ const uint *GPU_select_buffer_near(const uint *buffer, int hits) return buffer_near; } +uint GPU_select_buffer_remove_by_id(uint *buffer, int hits, uint select_id) +{ + uint *buffer_src = buffer; + uint *buffer_dst = buffer; + int hits_final = 0; + for (int i = 0; i < hits; i++) { + if (buffer_src[3] != select_id) { + if (buffer_dst != buffer_src) { + memcpy(buffer_dst, buffer_src, sizeof(int[4])); + } + buffer_dst += 4; + hits_final += 1; + } + buffer_src += 4; + } + return hits_final; +} + /* Part of the solution copied from `rect_subregion_stride_calc`. */ void GPU_select_buffer_stride_realign(const rcti *src, const rcti *dst, uint *r_buf) { |