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-07-19 13:12:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-07-19 13:12:24 +0300
commitabe0527e0fa77f15de4ebc7a7752a4c1375de1f1 (patch)
treefaf9cec7e670d6d067e6f81bc0aebfcd174ca4a2 /source/blender/gpu/intern/gpu_select.c
parentdd64cedd0b6b2bda4819e7093029f2a216f3082d (diff)
Manipulators: use nearest manipulator
Add utility function to get the nearest hit
Diffstat (limited to 'source/blender/gpu/intern/gpu_select.c')
-rw-r--r--source/blender/gpu/intern/gpu_select.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_select.c b/source/blender/gpu/intern/gpu_select.c
index 162a605ef3d..affc96b2843 100644
--- a/source/blender/gpu/intern/gpu_select.c
+++ b/source/blender/gpu/intern/gpu_select.c
@@ -227,3 +227,29 @@ bool GPU_select_is_cached(void)
{
return g_select_state.use_cache && gpu_select_pick_is_cached();
}
+
+
+/* ----------------------------------------------------------------------------
+ * Utilities
+ */
+
+/**
+ * Helper function, nothing special but avoids doing inline since hit's aren't sorted by depth
+ * and purpose of 4x buffer indices isn't so clear.
+ *
+ * Note that comparing depth as uint is fine.
+ */
+const uint *GPU_select_buffer_near(const uint *buffer, int hits)
+{
+ const uint *buffer_near = NULL;
+ uint depth_min = (uint)-1;
+ for (int i = 0; i < hits; i++) {
+ if (buffer[1] < depth_min) {
+ BLI_assert(buffer[3] != -1);
+ depth_min = buffer[1];
+ buffer_near = buffer;
+ }
+ buffer += 4;
+ }
+ return buffer_near;
+} \ No newline at end of file