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>2019-03-18 01:28:32 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-18 01:40:38 +0300
commit4b3aafd44ffd855f0cdb0d5e368c1abce238e11d (patch)
tree61575921a8dc85db3c03be8f2bbc0295101058b3 /source/blender/blenlib/BLI_kdtree.h
parentdf96455c55110da00f0543c5895376ffbc66313b (diff)
BLI_kdtree: refactor boids specific logic into callback
Logic to for boids to avoid head-on collisions was in BLI_kdtree. Move this into a callback which is now defined in boids.c so the kdtree code can be kept generic.
Diffstat (limited to 'source/blender/blenlib/BLI_kdtree.h')
-rw-r--r--source/blender/blenlib/BLI_kdtree.h23
1 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/blenlib/BLI_kdtree.h b/source/blender/blenlib/BLI_kdtree.h
index 864055127fc..3b21ad76b4d 100644
--- a/source/blender/blenlib/BLI_kdtree.h
+++ b/source/blender/blenlib/BLI_kdtree.h
@@ -45,9 +45,9 @@ int BLI_kdtree_find_nearest(
KDTreeNearest *r_nearest) ATTR_NONNULL(1, 2);
#define BLI_kdtree_find_nearest_n(tree, co, r_nearest, n) \
- BLI_kdtree_find_nearest_n__normal(tree, co, NULL, r_nearest, n)
+ BLI_kdtree_find_nearest_n_with_len_squared_cb(tree, co, r_nearest, n, NULL, NULL)
#define BLI_kdtree_range_search(tree, co, r_nearest, range) \
- BLI_kdtree_range_search__normal(tree, co, NULL, r_nearest, range)
+ BLI_kdtree_range_search_with_len_squared_cb(tree, co, r_nearest, range, NULL, NULL)
int BLI_kdtree_find_nearest_cb(
const KDTree *tree, const float co[3],
@@ -61,15 +61,18 @@ int BLI_kdtree_calc_duplicates_fast(
const KDTree *tree, const float range, bool use_index_order,
int *doubles);
-/* Normal use is deprecated */
-/* remove __normal functions when last users drop */
-int BLI_kdtree_find_nearest_n__normal(
- const KDTree *tree, const float co[3], const float nor[3],
+/* Versions of find/range search that take a squared distance callback to support bias. */
+int BLI_kdtree_find_nearest_n_with_len_squared_cb(
+ const KDTree *tree, const float co[3],
KDTreeNearest *r_nearest,
- unsigned int n) ATTR_NONNULL(1, 2, 4);
-int BLI_kdtree_range_search__normal(
- const KDTree *tree, const float co[3], const float nor[3],
+ unsigned int n,
+ float (*len_sq_fn)(const float co_search[3], const float co_test[3], const void *user_data),
+ const void *user_data) ATTR_NONNULL(1, 2, 3);
+int BLI_kdtree_range_search_with_len_squared_cb(
+ const KDTree *tree, const float co[3],
KDTreeNearest **r_nearest,
- float range) ATTR_NONNULL(1, 2, 4) ATTR_WARN_UNUSED_RESULT;
+ float range,
+ float (*len_sq_fn)(const float co_search[3], const float co_test[3], const void *user_data),
+ const void *user_data) ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
#endif /* __BLI_KDTREE_H__ */