Fix: Selection-Next: Material asset drag&drop slot selection

The user code expects a single hit result when SELECT_PICK_NEAREST
is used.

Note there's still an issue causing the picking to be slightly offset.

Pull Request: https://projects.blender.org/blender/blender/pulls/133382
This commit is contained in:
Miguel Pozo 2025-01-21 17:34:12 +01:00
parent 74fff8623f
commit 71c889d283

View file

@ -278,11 +278,8 @@ struct SelectMap {
break;
case SelectType::SELECT_PICK_ALL:
case SelectType::SELECT_PICK_NEAREST:
for (auto i : IndexRange(select_id_map.size())) {
if (select_output_buf[i] != 0xFFFFFFFFu) {
/* NOTE: For `SELECT_PICK_NEAREST`, `select_output_buf` also contains the screen
* distance to cursor in the lowest bits. */
GPUSelectResult hit_result{};
hit_result.id = select_id_map[i];
hit_result.depth = select_output_buf[i];
@ -297,6 +294,28 @@ struct SelectMap {
}
}
break;
case SelectType::SELECT_PICK_NEAREST:
for (auto i : IndexRange(select_id_map.size())) {
if (select_output_buf[i] != 0xFFFFFFFFu) {
/* NOTE: For `SELECT_PICK_NEAREST`, `select_output_buf` also contains the screen
* distance to cursor in the lowest bits. */
GPUSelectResult hit_result{};
hit_result.id = select_id_map[i];
hit_result.depth = select_output_buf[i];
if (in_front_map[i]) {
/* Divide "In Front" objects depth so they go first. */
const uint32_t depth_mask = 0x00FFFFFFu;
uint32_t offset_depth = (hit_result.depth & depth_mask) / 100;
hit_result.depth &= ~depth_mask;
hit_result.depth |= offset_depth;
}
if (hit_results.is_empty() || hit_result.depth < hit_results[0].depth) {
hit_results = {hit_result};
}
}
}
break;
}
#ifdef DEBUG_PRINT
for (auto &hit : hit_results) {