diff options
author | Colin Basnett <cmbasnett@gmail.com> | 2022-09-17 03:50:37 +0300 |
---|---|---|
committer | Colin Basnett <cmbasnett@gmail.com> | 2022-09-17 03:50:37 +0300 |
commit | 564bda241a973396da51d7c3ccd9efd97d51728a (patch) | |
tree | 4d9aa4cccd82e2e606b47774afa5e1015bf14768 /source/blender/blenlib/BLI_kdtree_impl.h | |
parent | 0fff238150d076576053c25b646f653d6e3b0edb (diff) | |
parent | 48d7ff68f0df209c77bbb081ab46fbc109fd825a (diff) |
Merge branch 'master' into feature-imformatfeature-imformat
Diffstat (limited to 'source/blender/blenlib/BLI_kdtree_impl.h')
-rw-r--r-- | source/blender/blenlib/BLI_kdtree_impl.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_kdtree_impl.h b/source/blender/blenlib/BLI_kdtree_impl.h index 08fa40fd972..4187724fbda 100644 --- a/source/blender/blenlib/BLI_kdtree_impl.h +++ b/source/blender/blenlib/BLI_kdtree_impl.h @@ -12,6 +12,10 @@ #define _BLI_CONCAT(MACRO_ARG1, MACRO_ARG2) _BLI_CONCAT_AUX(MACRO_ARG1, MACRO_ARG2) #define BLI_kdtree_nd_(id) _BLI_CONCAT(KDTREE_PREFIX_ID, _##id) +#ifdef __cplusplus +extern "C" { +#endif + struct KDTree; typedef struct KDTree KDTree; @@ -80,6 +84,29 @@ int BLI_kdtree_nd_(range_search_with_len_squared_cb)( const void *user_data), const void *user_data) ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT; +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus +template<typename Fn> +inline void BLI_kdtree_nd_(range_search_cb_cpp)(const KDTree *tree, + const float co[KD_DIMS], + float distance, + const Fn &fn) +{ + BLI_kdtree_nd_(range_search_cb)( + tree, + co, + distance, + [](void *user_data, const int index, const float *co, const float dist_sq) { + const Fn &fn = *static_cast<const Fn *>(user_data); + return fn(index, co, dist_sq); + }, + const_cast<Fn *>(&fn)); +} +#endif + #undef _BLI_CONCAT_AUX #undef _BLI_CONCAT #undef BLI_kdtree_nd_ |