Blender V5.3
BLI_kdtree_types.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11
12#include "BLI_sys_types.hh"
13
14#include <cstdint>
15
16namespace blender {
17
18template<typename CoordT> struct KDTreeCoordTraits {
19 static constexpr int DimsNum = CoordT::type_length;
20 using ValueType = typename CoordT::base_type;
21 static ValueType get(const CoordT &co, const int axis)
22 {
23 return co[axis];
24 }
25};
26
27template<> struct KDTreeCoordTraits<float> {
28 static constexpr int DimsNum = 1;
30 static float get(const float &co, const int /*axis*/)
31 {
32 return co;
33 }
34};
35
36template<typename CoordT> struct KDTreeNode_head {
38 CoordT co;
39 int index;
40};
41
42template<typename CoordT> struct KDTreeNode {
45
47 CoordT co;
48 int index;
49 uint d; /* range is only (0..DimsNum - 1) */
50};
51
52template<typename CoordT> struct KDTree {
54 constexpr static int DimsNum = NodeT::DimsNum;
55 using ValueType = typename NodeT::ValueType;
56
61#ifndef NDEBUG
62 bool is_balanced; /* ensure we call balance first */
63 uint32_t nodes_len_capacity; /* max size of the tree */
64#endif
65};
66
67template<typename CoordT> struct KDTreeNearest {
69 using ValueType = typename TreeT::ValueType;
70
71 int index;
73 CoordT co;
74};
75
76} // namespace blender
BMesh Iterators.
unsigned int uint
Definition BKE_text.h:55
unsigned int uint32_t
Definition BKE_text.h:81
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
static float get(const float &co, const int)
static constexpr int DimsNum
static ValueType get(const CoordT &co, const int axis)
typename CoordT::base_type ValueType
typename TreeT::ValueType ValueType
static constexpr int DimsNum
typename KDTreeCoordTraits< CoordT >::ValueType ValueType
KDTreeNode< CoordT > NodeT
typename NodeT::ValueType ValueType