54#define BM_LOOPS_OF_VERT_ITER_BEGIN(l_iter_radial_, v_) \
58 BMEdge *e_iter, *e_first; \
59 BMLoop *l_iter_radial; \
63 _iter.e_iter = _iter.e_first = _iter.v->e; \
65 if (_iter.e_iter->l) { \
66 _iter.l_iter_radial = _iter.e_iter->l; \
68 if (_iter.l_iter_radial->v == _iter.v) { \
69 l_iter_radial_ = _iter.l_iter_radial;
71#define BM_LOOPS_OF_VERT_ITER_END \
74 while ((_iter.l_iter_radial = _iter.l_iter_radial->radial_next) != _iter.e_iter->l) \
78 while ((_iter.e_iter = BM_DISK_EDGE_NEXT(_iter.e_iter, _iter.v)) != _iter.e_first) \
84#define BM_FACES_OF_VERT_ITER_BEGIN(f_iter_, v_) \
86 BMLoop *l_iter_radial_; \
87 BM_LOOPS_OF_VERT_ITER_BEGIN (l_iter_radial_, v_) { \
88 f_iter_ = l_iter_radial_->f;
90#define BM_FACES_OF_VERT_ITER_END \
92 BM_LOOPS_OF_VERT_ITER_END; \
98 return {
float3(std::numeric_limits<float>::max()),
float3(std::numeric_limits<float>::lowest())};
116 std::array<BMVert *, 3>
result;
146 !
ELEM(v_opposite, l_radial_first->
v, l_radial_first->
next->
v, l_radial_first->
prev->
v));
147 if (l_radial_first->
radial_next != l_radial_first) {
151 if (l_radial_iter->
prev->
v == v_opposite) {
152 return l_radial_iter->
f;
154 }
while ((l_radial_iter = l_radial_iter->
radial_next) != l_radial_first);
167 if (v_next_p ==
nullptr) {
171 if (*v_next_p ==
nullptr) {
187 const int node_index,
188 const int cd_vert_node_offset,
189 const int cd_face_node_offset)
191 bool has_visible =
false;
201 const BMLoop *l_iter = l_first;
216 }
while ((l_iter = l_iter->
next) != l_first);
234 const int cd_vert_node_offset,
235 const int cd_face_node_offset,
237 const int node_index)
242 nodes[node_index], node_index, cd_vert_node_offset, cd_face_node_offset);
248 for (
const BMFace *f :
nodes[node_index].bm_faces_) {
259 const int children =
nodes.size();
260 nodes[node_index].children_offset_ = children;
262 node_changed.
resize(node_changed.
size() + 2,
true);
269 c2->parent_ = node_index;
271 c2->bm_faces_.reserve(
nodes[node_index].bm_faces_.size() / 2);
280 c2->bm_faces_.add(f);
289 other = &c2->bm_faces_;
291 else if (c2->bm_faces_.is_empty()) {
292 empty = &c2->bm_faces_;
296 for (
BMFace *f : *other) {
314 nodes[node_index].bm_faces_.clear();
317 node_changed[node_index] =
true;
321 nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, face_bounds, children);
323 nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, face_bounds, children + 1);
327 nodes[
nodes[node_index].children_offset_ + 1].bounds_);
328 nodes[node_index].bounds_orig_ =
nodes[node_index].bounds_;
335 const int cd_vert_node_offset,
336 const int cd_face_node_offset,
337 const int node_index)
339 const int faces_num =
nodes[node_index].bm_faces_.size();
356 }
while ((l_iter = l_iter->
next) != l_first);
367 nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, face_bounds, node_index);
377 cd_vert_node_offset);
385 cd_face_node_offset);
391 const int cd_vert_node_offset,
398 const int cd_face_node_offset,
410 const int node_index,
413 const int cd_vert_node_offset,
414 const int cd_vert_mask_offset)
428 node.bm_unique_verts_.add(
v);
432 node_changed[node_index] =
true;
446 const int cd_face_node_offset,
448 const int node_index,
461 node.bm_faces_.add(f);
465 node_changed[node_index] =
true;
474#define pbvh_bmesh_node_vert_use_count_is_equal(nodes, cd_face_node_offset, node, v, n) \
475 (pbvh_bmesh_node_vert_use_count_at_most(nodes, cd_face_node_offset, node, v, (n) + 1) == n)
478 const int cd_face_node_offset,
488 if (f_node ==
node) {
490 if (count == count_max) {
502 const int cd_face_node_offset,
511 if (f_node != current_node) {
522 const int cd_vert_node_offset,
523 const int new_owner_index,
529 node_changed[new_owner_index] =
true;
545 node_changed[new_owner_index] =
true;
550 const int cd_vert_node_offset,
551 const int cd_face_node_offset,
567 if (f_node_index_prev != f_node_index) {
568 f_node_index_prev = f_node_index;
572 node_changed[f_node_index] =
true;
586 const int cd_vert_node_offset,
587 const int cd_face_node_offset,
596 const BMLoop *l_iter = l_first;
604 cd_vert_node_offset, cd_face_node_offset,
v);
609 nodes, node_changed, cd_vert_node_offset, *new_node,
v);
617 }
while ((l_iter = l_iter->
next) != l_first);
628 node_changed[node_index] =
true;
634 std::array<BMLoop *, 2> manifold_loops;
635 if (
BM_edge_loop_pair(
e, manifold_loops.data(), manifold_loops.data() + 1)) [[likely]] {
646 node->orig_positions_ = {};
647 node->orig_tris_ = {};
648 node->orig_verts_ = {};
678#define EDGE_QUEUE_TEST(e) BM_elem_flag_test((CHECK_TYPE_INLINE(e, BMEdge *), e), BM_ELEM_TAG)
679#define EDGE_QUEUE_ENABLE(e) BM_elem_flag_enable((CHECK_TYPE_INLINE(e, BMEdge *), e), BM_ELEM_TAG)
680#define EDGE_QUEUE_DISABLE(e) \
681 BM_elem_flag_disable((CHECK_TYPE_INLINE(e, BMEdge *), e), BM_ELEM_TAG)
685 std::array<BMVert *, 3> v_tri;
701 std::array<BMVert *, 3> v_tri;
706 std::array<float3, 3> tri_proj;
768 const BMEdge *first_edge = edge;
769 if (first_edge ==
nullptr) {
839 const float limit_len)
854 if (
G.debug_value == 1234) [[unlikely]] {
861 static constexpr float even_edgelen_threshold = 1.2f;
864 static constexpr float even_generation_scale = 1.6f;
866 const float len_sq_cmp = len_sq * even_edgelen_threshold;
868 const float new_limit_len = limit_len * even_generation_scale;
869 const float new_limit_len_sq =
square_f(new_limit_len);
871 const BMLoop *l_iter = l_edge;
873 std::array<BMLoop *, 2> l_adjacent = {l_iter->
next, l_iter->
prev};
874 for (
int i = 0; i < l_adjacent.size(); i++) {
876 if (len_sq_other >
max_ff(len_sq_cmp, new_limit_len_sq)) {
879 eq_ctx, l_adjacent[i]->radial_next, l_adjacent[i], len_sq_other, new_limit_len);
906 const BMLoop *l_iter = l_first;
913 }
while ((l_iter = l_iter->
next) != l_first);
928 const BMLoop *l_iter = l_first;
931 }
while ((l_iter = l_iter->
next) != l_first);
946 const float max_edge_len,
949 const std::optional<float3> view_normal,
951 const bool use_frontface,
952 const bool use_projected)
955 view_normal || (!use_frontface && !use_projected),
956 "If either use_frontface or use_projected is specified, view_normal must be non-empty");
968 if (use_projected && view_normal) {
999 const float min_edge_len,
1002 const std::optional<float3> view_normal,
1004 const bool use_frontface,
1005 const bool use_projected)
1008 view_normal || (!use_frontface && !use_projected),
1009 "If either use_frontface or use_projected is specified, view_normal must be non-empty");
1021 if (use_projected && view_normal) {
1072 const int cd_vert_node_offset,
1073 const int cd_face_node_offset,
1094 cd_vert_node_offset,
1099 const BMLoop *l_adj = edge_loops[i];
1113 if (ni != node_index && i == 0) {
1143 const std::array<BMVert *, 3> first_tri({v1, v_new, v_opp});
1148 bm,
nodes, node_changed, cd_face_node_offset, bm_log, ni, first_tri, first_edges, f_adj);
1152 const std::array<BMVert *, 3> second_tri({v_new,
v2, v_opp});
1153 const std::array<BMEdge *, 3> second_edges{
1161 bm,
nodes, node_changed, cd_face_node_offset, bm_log, ni, second_tri, second_edges, f_adj);
1166 nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log, f_adj);
1170 if (!
nodes[ni].bm_unique_verts_.contains(v_new)) {
1171 nodes[ni].bm_other_verts_.add(v_new);
1190 const int cd_vert_node_offset,
1191 const int cd_face_node_offset,
1196 bool any_subdivided =
false;
1225 any_subdivided =
true;
1228 eq_ctx,
bm,
nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log,
e);
1233 return any_subdivided;
1299 CLOG_WARN(&
LOG,
"Unable to find edge shared between deleting and flap faces");
1314 const std::array<const BMEdge *, 4> source_edges{
1327 for (
const BMEdge *src_edge : source_edges) {
1329 CLOG_WARN(&
LOG,
"Unable to find source edge for flap attributes merge");
1344 BMVert *flap_vert =
nullptr;
1391 const BMEdge *edge_2 = l_flap->
e;
1452 CLOG_WARN(&
LOG,
"Unable to find edge shared between old and new faces");
1459 if (dst_edge == edge_v1_v2) {
1475 CLOG_WARN(&
LOG,
"Unable to find edge to merge attributes from");
1483 const int cd_vert_node_offset,
1484 const int cd_face_node_offset,
1497 if (v1_on_boundary || v2_on_boundary) {
1503 if (v1_on_boundary) {
1546 deleted_faces.
append(f_del);
1554 deleted_faces.
append(existing_face);
1561 while ((l_adj =
e->l)) {
1565 nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log, f_adj);
1581 const std::array<BMVert *, 3> v_tri{v_conn,
l->
next->
v,
l->
prev->
v};
1585 const int ni = n -
nodes.data();
1588 bm,
nodes, node_changed, cd_face_node_offset, bm_log, ni, v_tri, e_tri, f);
1601 for (
BMFace *f_del : deleted_faces) {
1605 const std::array<BMVert *, 3> v_tri{l_iter->
v, l_iter->
next->
v, l_iter->
next->
next->
v};
1606 const std::array<BMEdge *, 3> e_tri{l_iter->
e, l_iter->
next->
e, l_iter->
next->
next->
e};
1615 nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log, f_del);
1629 if ((v_tri[j] != v_del) && (v_tri[j]->
e ==
nullptr)) {
1631 nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, v_tri[j]);
1635 if (v_tri[j] == v_conn) {
1638 deleted_verts.
add_new(v_tri[j],
nullptr);
1656 if (v_conn !=
nullptr) {
1661 node_changed[f_node] =
true;
1670 deleted_verts.
add_new(v_del, v_conn);
1675 const float min_edge_len,
1679 const int cd_vert_node_offset,
1680 const int cd_face_node_offset,
1685 const float min_len_squared = min_edge_len * min_edge_len;
1686 bool any_collapsed =
false;
1700 if (!v1 || !
v2 || (v1 ==
v2)) {
1724 any_collapsed =
true;
1729 cd_vert_node_offset,
1730 cd_face_node_offset,
1741 return any_collapsed;
1748 const float3 &ray_normal,
1752 BMVert **r_active_vertex,
1756 float3 nearest_vertex_co(0.0f);
1758 use_original = use_original && !
node.orig_tris_.is_empty();
1761 for (
const int tri_idx :
node.orig_tris_.index_range()) {
1762 const std::array<float3, 3> positions = {
node.orig_positions_[
node.orig_tris_[tri_idx][0]],
1763 node.orig_positions_[
node.orig_tris_[tri_idx][1]],
1764 node.orig_positions_[
node.orig_tris_[tri_idx][2]]};
1767 ray_start, isect_precalc, positions[0], positions[1], positions[2], depth))
1771 r_face_normal =
math::normal_tri(positions[0], positions[1], positions[2]);
1773 if (r_active_vertex) {
1774 const float3 location = ray_start + ray_normal * *depth;
1775 for (
int i = 0; i < positions.size(); i++) {
1779 nearest_vertex_co = positions[i];
1780 *r_active_vertex =
node.orig_verts_[
node.orig_tris_[tri_idx][i]];
1792 std::array<BMVert *, 3> v_tri;
1795 std::array<float3, 3> positions = {v_tri[0]->co, v_tri[1]->co, v_tri[2]->co};
1798 ray_start, isect_precalc, positions[0], positions[1], positions[2], depth))
1802 r_face_normal =
math::normal_tri(positions[0], positions[1], positions[2]);
1804 if (r_active_vertex) {
1805 const float3 location = ray_start + ray_normal * *depth;
1806 for (
int i = 0; i < positions.size(); i++) {
1810 nearest_vertex_co = positions[i];
1811 *r_active_vertex = v_tri[i];
1827 float *r_edge_length)
1839 std::array<BMVert *, 3> v_tri;
1842 ray_start, isect_precalc, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, depth))
1851 std::array<BMVert *, 3> v_tri;
1859 *r_edge_length =
sqrtf(std::max({len1, len2, len3}));
1867 const float3 &ray_normal,
1870 const bool use_original)
1874 if (use_original && !
node.orig_tris_.is_empty()) {
1875 for (
const int i :
node.orig_tris_.index_range()) {
1876 const int *t =
node.orig_tris_[i];
1879 node.orig_positions_[t[0]],
1880 node.orig_positions_[t[1]],
1881 node.orig_positions_[t[2]],
1890 std::array<BMVert *, 3> v_tri;
1894 ray_start, ray_normal, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co, r_depth, dist_sq);
1942 for (
int i = 0; i <
node->totface; i++) {
1957 const int end =
node->start +
node->totface;
1958 for (
int i =
node->start; i < end - num_child2; i++) {
1959 const BMFace *f = nodeinfo[i];
1963 int i_iter = end - num_child2 - 1;
1967 for (; i_iter > i; i_iter--) {
1968 const BMFace *f_iter = nodeinfo[i_iter];
1971 face_bounds[face_iter_i].
max[axis]) <= mid)
1980 if (candidate != -1) {
1981 BMFace *tmp = nodeinfo[i];
1982 nodeinfo[i] = nodeinfo[candidate];
1983 nodeinfo[candidate] = tmp;
2000 if (num_child2 == 0) {
2004 else if (num_child1 == 0) {
2019 node->child1 = child1;
2020 node->child2 = child2;
2024 child1->
child1 =
nullptr;
2025 child1->
child2 =
nullptr;
2028 child2->
start =
node->start + num_child1;
2029 child2->
child1 =
nullptr;
2030 child2->
child2 =
nullptr;
2037 const int cd_vert_node_offset,
2038 const int cd_face_node_offset,
2042 const int node_index,
2043 const int parent_index)
2046 nodes[node_index].parent_ = parent_index;
2050 int children_offset_ =
nodes.size();
2052 nodes[node_index].children_offset_ = children_offset_;
2055 cd_vert_node_offset,
2056 cd_face_node_offset,
2063 cd_vert_node_offset,
2064 cd_face_node_offset,
2068 children_offset_ + 1,
2076 nodes[node_index].bm_faces_.reserve(
node->totface);
2078 const int end =
node->start +
node->totface;
2080 for (
int i =
node->start; i < end; i++) {
2084 nodes[node_index].bm_faces_.add_new(f);
2089 const BMLoop *l_iter = l_first;
2092 if (!
nodes[node_index].bm_unique_verts_.contains(
v)) {
2094 nodes[node_index].bm_other_verts_.add(
v);
2097 nodes[node_index].bm_unique_verts_.add(
v);
2101 }
while ((l_iter = l_iter->
next) != l_first);
2133 const BMLoop *l_iter = l_first;
2136 }
while ((l_iter = l_iter->
next) != l_first);
2166 nodes, cd_vert_node_offset, cd_face_node_offset, nodeinfo, face_bounds, &rootnode, 0, -1);
2169 pbvh.update_bounds_bmesh(
bm);
2173 for (const int i : range) {
2174 const Set<BMFace *, 0> &faces = BKE_pbvh_bmesh_node_faces(&nodes[i]);
2175 if (std::all_of(faces.begin(),
2177 [&](const BMFace *face) { return BM_elem_flag_test(face, BM_ELEM_HIDDEN); }))
2179 nodes[i].flag_ |= Node::FullyHidden;
2194 const float min_edge_len,
2195 const float max_edge_len,
2197 const std::optional<float3> &view_normal,
2199 const bool use_frontface,
2200 const bool use_projected)
2209 bool modified =
false;
2212 "View normal must be non-zero length if provided");
2224 cd_vert_mask_offset,
2225 cd_vert_node_offset,
2226 cd_face_node_offset,
2230 &eq_ctx, min_edge_len,
nodes, center, view_normal, radius, use_frontface, use_projected);
2236 cd_vert_node_offset,
2237 cd_face_node_offset,
2250 cd_vert_mask_offset,
2251 cd_vert_node_offset,
2252 cd_face_node_offset,
2256 &eq_ctx, max_edge_len,
nodes, center, view_normal, radius, use_frontface, use_projected);
2258 &eq_ctx,
bm,
nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, bm_log);
2265 pbvh.tag_positions_changed(node_mask);
2266 pbvh.tag_topology_changed(node_mask);
2280 if (!
node.orig_tris_.is_empty()) {
2296 if (!use_original) {
2297 node->orig_positions_[i] =
v->
co;
2302 node->orig_positions_[i] = origco;
2305 node->orig_positions_[i] =
v->
co;
2309 node->orig_verts_[i] =
v;
2320 if (!
node->orig_tris_.is_empty()) {
2324 const int totvert =
node->bm_unique_verts_.size() +
node->bm_other_verts_.size();
2326 node->orig_positions_.reinitialize(totvert);
2327 node->orig_verts_.reinitialize(totvert);
2348 const int tris_num = std::count_if(
2349 node->bm_faces_.begin(),
node->bm_faces_.end(), [&](
const BMFace *face) {
2350 return !BM_elem_flag_test_bool(face, BM_ELEM_HIDDEN);
2352 node->orig_tris_.reinitialize(tris_num);
2375 for (
const int i : orig_range) {
2379 pbvh_bmesh_node_drop_orig(n);
2382 pbvh_bmesh_node_limit_ensure(
2383 bm,
nodes, node_changed, cd_vert_node_offset, cd_face_node_offset, i);
2389 pbvh.tag_positions_changed(node_mask);
2390 pbvh.tag_topology_changed(node_mask);
2391 update_mask_bmesh(
bm, node_mask,
pbvh);
2401 return node->bm_unique_verts_;
2406 return node->bm_other_verts_;
2411 return node->bm_faces_;
A BVH for high poly meshes.
A min-heap / priority queue ADT.
#define BLI_MEMARENA_STD_BUFSIZE
Platform independent time functions.
#define CLOG_DEBUG(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define PRF_scope(category)
#define UNUSED_VARS_NDEBUG(...)
#define BLI_assert_msg(a, msg)
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_DISK_EDGE_NEXT(e, v)
#define BM_ELEM_CD_GET_INT(ele, offset)
#define BM_ELEM_CD_SET_INT(ele, offset, f)
#define BM_FACE_FIRST_LOOP(p)
#define BM_elem_index_get(ele)
#define BM_elem_index_set(ele, index)
#define BM_elem_flag_test(ele, hflag)
#define BM_elem_flag_test_bool(ele, hflag)
#define BM_ITER_ELEM(ele, iter, data, itype)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
#define BM_vert_face_count_is_equal(v, n)
#define BM_vert_edge_count_is_over(v, n)
Array(Allocator allocator={}) noexcept
IndexRange index_range() const
static IndexMask from_bools(Span< bool > bools, LinearAllocator<> &memory)
constexpr IndexRange()=default
const Value * lookup_ptr(const Key &key) const
void add_new(const Key &key, const Value &value)
constexpr const T * data() const
void reserve(const int64_t n)
int64_t index_of(const Key &key) const
void append(const T &value)
IndexRange index_range() const
void resize(const int64_t new_size)
Bounds< float3 > bounds_orig_
Tree(const Tree &other)=delete
static Tree from_bmesh(BMesh &bm)
Span< NodeT > nodes() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
static void edge_queue_insert(const EdgeQueueContext *eq_ctx, BMEdge *e, const float priority)
static BMFace * pbvh_bmesh_face_create(BMesh &bm, MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_face_node_offset, BMLog &bm_log, const int node_index, const Span< BMVert * > v_tri, const Span< BMEdge * > e_tri, const BMFace *f_example)
static void long_edge_queue_edge_add_recursive(const EdgeQueueContext *eq_ctx, const BMLoop *l_edge, const BMLoop *l_end, const float len_sq, const float limit_len)
static std::array< BMEdge *, 3 > bm_edges_from_tri(BMesh &bm, const Span< BMVert * > v_tri)
static void long_edge_queue_face_add(const EdgeQueueContext *eq_ctx, BMFace *f)
static bool check_mask(const EdgeQueueContext *eq_ctx, const BMVert *v)
static void pbvh_bmesh_vert_remove(MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, BMVert *v)
bool bmesh_node_nearest_to_ray(BMeshNode &node, const float3 &ray_start, const float3 &ray_normal, float *r_depth, float *dist_sq, const bool use_original)
static void long_edge_queue_create(const EdgeQueueContext *eq_ctx, const float max_edge_len, MutableSpan< BMeshNode > nodes, const float3 ¢er, const std::optional< float3 > view_normal, const float radius, const bool use_frontface, const bool use_projected)
static void pbvh_bmesh_node_split(Vector< BMeshNode > &nodes, Vector< bool > &node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, const Span< Bounds< float3 > > face_bounds, const int node_index)
void update_mask_bmesh(const BMesh &bm, const IndexMask &node_mask, Tree &pbvh)
static void pbvh_bmesh_vert_ownership_transfer(MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_vert_node_offset, const int new_owner_index, BMVert *v)
static void pbvh_bmesh_collapse_edge(BMesh &bm, MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, BMLog &bm_log, BMEdge *e, BMVert *v1, BMVert *v2, Map< BMVert *, BMVert * > &deleted_verts, const EdgeQueueContext *eq_ctx)
static BMVert * pbvh_bmesh_vert_create(BMesh &bm, MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, BMLog &bm_log, const BMVert *v1, const BMVert *v2, const int node_index, const float3 &co, const float3 &no, const int cd_vert_node_offset, const int cd_vert_mask_offset)
static void pbvh_bmesh_create_nodes_fast_recursive(Vector< BMeshNode > &nodes, const int cd_vert_node_offset, const int cd_face_node_offset, const Span< BMFace * > nodeinfo, const Span< Bounds< float3 > > face_bounds, const FastNodeBuildInfo *node, const int node_index, const int parent_index)
BLI_INLINE int pbvh_bmesh_node_index_from_face(const int cd_face_node_offset, const BMFace *key)
static BMVert * bm_vert_hash_lookup_chain(Map< BMVert *, BMVert * > &deleted_verts, BMVert *v)
static void copy_original_vert(BMLog *log, BMeshNode *node, BMVert *v, int i, bool use_original)
BLI_INLINE std::array< BMVert *, 3 > bm_face_as_array(const BMFace &f)
static BMVert * find_outer_flap_vert(BMFace &face)
bool ray_face_nearest_tri(const float3 &ray_start, const float3 &ray_normal, const float3 &t0, const float3 &t1, const float3 &t2, float *r_depth, float *dist_sq)
static bool pbvh_bmesh_node_limit_ensure(BMesh &bm, Vector< BMeshNode > &nodes, Vector< bool > &node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, const int node_index)
void bmesh_normals_update(Tree &pbvh, const IndexMask &nodes_to_update)
static void short_edge_queue_create(const EdgeQueueContext *eq_ctx, const float min_edge_len, MutableSpan< BMeshNode > nodes, const float3 ¢er, const std::optional< float3 > view_normal, const float radius, const bool use_frontface, const bool use_projected)
static bool pbvh_bmesh_subdivide_long_edges(const EdgeQueueContext *eq_ctx, BMesh &bm, MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, BMLog &bm_log)
bool node_raycast_bmesh(BMeshNode &node, const float3 &ray_start, const float3 &ray_normal, const IsectRayPrecalc *isect_precalc, float *depth, bool use_original, BMVert **r_active_vertex, float3 &r_face_normal)
static bool pbvh_bmesh_collapse_short_edges(const EdgeQueueContext *eq_ctx, const float min_edge_len, BMesh &bm, MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, BMLog &bm_log)
static Bounds< float3 > negative_bounds()
static bool is_boundary_edge(const BMEdge &edge)
static void pbvh_bmesh_split_edge(const EdgeQueueContext *eq_ctx, BMesh &bm, MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, BMLog &bm_log, BMEdge *e)
static BMFace * bm_face_exists_tri_from_loop_vert(const BMLoop *l_radial_first, const BMVert *v_opposite)
static bool edge_queue_tri_in_sphere(const EdgeQueue *queue, BMFace *f)
static void merge_edge_data(BMesh &bm, BMEdge &dst, const BMEdge &src)
static constexpr int dyntopo_node_none
static void short_edge_queue_edge_add(const EdgeQueueContext *eq_ctx, BMEdge *e)
static void try_merge_flap_edge_data_before_dissolve(BMesh &bm, BMFace &face)
static std::optional< int > pbvh_bmesh_vert_other_node_find(const int cd_vert_node_offset, const int cd_face_node_offset, BMVert *v)
BLI_INLINE BMeshNode * pbvh_bmesh_node_from_vert(MutableSpan< BMeshNode > nodes, const int cd_vert_node_offset, const BMVert *key)
bool bmesh_update_topology(BMesh &bm, Tree &pbvh, BMLog &bm_log, PBVHTopologyUpdateMode mode, float min_edge_len, float max_edge_len, const float3 ¢er, const std::optional< float3 > &view_normal, float radius, bool use_frontface, bool use_projected)
static void merge_flap_edge_data(BMesh &bm, const BMFace *del_face, const BMFace *flap_face, BMEdge *e, BMVert *v_del, const BMLoop *l_del, BMVert *v_conn)
bool raycast_node_detail_bmesh(const BMeshNode &node, const float3 &ray_start, const IsectRayPrecalc *isect_precalc, float *depth, float *r_edge_length)
static void merge_face_edge_data(BMesh &bm, BMFace *, BMFace *new_face, BMVert *v_del, const BMLoop *l_del, const BMVert *v_conn)
static void pbvh_bmesh_node_drop_orig(BMeshNode *node)
static void copy_edge_data(BMesh &bm, BMEdge &dst, const BMEdge &src)
static void pbvh_bmesh_node_limit_ensure_fast(const MutableSpan< BMFace * > nodeinfo, const Span< Bounds< float3 > > face_bounds, FastNodeBuildInfo *node, MemArena *arena)
static void pbvh_bmesh_node_finalize(BMeshNode &n, const int node_index, const int cd_vert_node_offset, const int cd_face_node_offset)
BLI_INLINE int pbvh_bmesh_node_index_from_vert(const int cd_vert_node_offset, const BMVert *key)
bool ray_face_intersection_tri(const float3 &ray_start, const IsectRayPrecalc *isect_precalc, const float3 &t0, const float3 &t1, const float3 &t2, float *depth)
static void short_edge_queue_face_add(const EdgeQueueContext *eq_ctx, BMFace *f)
BLI_INLINE BMeshNode * pbvh_bmesh_node_from_face(MutableSpan< BMeshNode > nodes, const int cd_face_node_offset, const BMFace *key)
static bool vert_in_face_adjacent_to_edge(BMVert &vert, BMEdge &edge)
static float long_edge_queue_priority(const BMEdge &edge)
static bool is_boundary_vert(const BMVert &vertex)
static float short_edge_queue_priority(const BMEdge &edge)
void store_bounds_orig(Tree &pbvh)
static void pbvh_bmesh_face_remove(MutableSpan< BMeshNode > nodes, MutableSpan< bool > node_changed, const int cd_vert_node_offset, const int cd_face_node_offset, BMLog &bm_log, BMFace *f)
static Array< BMLoop * > pbvh_bmesh_edge_loops(BMEdge *e)
static bool is_edge_adjacent_to_boundary(const BMEdge &edge)
static void long_edge_queue_edge_add(const EdgeQueueContext *eq_ctx, BMEdge *e)
static int pbvh_bmesh_node_vert_use_count_at_most(MutableSpan< BMeshNode > nodes, const int cd_face_node_offset, const BMeshNode *node, BMVert *v, const int count_max)
static bool edge_queue_tri_in_circle(const EdgeQueue *queue, BMFace *f)
Bounds< T > merge(const Bounds< T > &a, const Bounds< T > &b)
T length_squared(const VecBase< T, Size > &a)
VecBase< T, 3 > normal_tri(const VecBase< T, 3 > &v1, const VecBase< T, 3 > &v2, const VecBase< T, 3 > &v3)
T midpoint(const T &a, const T &b)
void min_max(const T &value, T &min, T &max)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T distance_squared(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
int dominant_axis(const VecBase< T, 3 > &a)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
int BM_edge_face_count(const BMEdge *e)
void BM_log_face_added(BMLog *log, BMFace *f)
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BM_edge_in_face(const BMEdge *e, const BMFace *f)
const Set< BMFace *, 0 > & BKE_pbvh_bmesh_node_faces(bke::pbvh::BMeshNode *node)
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BKE_pbvh_node_fully_hidden_set(bke::pbvh::Node &node, int fully_hidden)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
void BM_vert_kill(BMesh *bm, BMVert *v)
void BM_log_vert_added(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
void project_plane_normalized_v3_v3v3(float out[3], const float p[3], const float v_plane[3])
ATTR_WARN_UNUSED_RESULT const BMVert * v
void CustomData_bmesh_copy_block(CustomData &data, void *src_block, void **dst_block)
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
void BM_data_interp_from_edges(BMesh *bm, const BMEdge *e_src_1, const BMEdge *e_src_2, BMEdge *e_dst, const float fac)
Data, Interpolate From Edges.
BLI_INLINE bool BM_edge_is_manifold(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BMFace * BM_face_create(BMesh *bm, BMVert *const *verts, BMEdge *const *edges, const int len, const BMFace *f_example, const eBMCreateFlag create_flag)
BLI_INLINE bool BM_vert_in_edge(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BM_log_vert_removed(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
void BM_vert_normal_update(BMVert *v)
void BLI_mempool_free(BLI_mempool *pool, void *addr) ATTR_NONNULL(1
void BLI_mempool_destroy(BLI_mempool *pool) ATTR_NONNULL(1)
void * BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1)
void BKE_pbvh_bmesh_node_save_orig(BMesh *bm, BMLog *log, bke::pbvh::BMeshNode *node, bool use_original)
VecBase< int32_t, 3 > int3
void BM_face_normal_update(BMFace *f)
void BM_edge_kill(BMesh *bm, BMEdge *e)
BLI_mempool * BLI_mempool_create(unsigned int esize, unsigned int elem_num, unsigned int pchunk, unsigned int flag) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
BMLoop * BM_vert_find_first_loop(BMVert *v)
void BKE_pbvh_bmesh_after_stroke(BMesh &bm, bke::pbvh::Tree &pbvh)
bool BM_vert_in_face(BMVert *v, BMFace *f)
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_other_verts(bke::pbvh::BMeshNode *node)
void BLI_heapsimple_free(HeapSimple *heap, HeapSimpleFreeFP ptrfreefp) ATTR_NONNULL(1)
int BM_vert_face_count_at_most(const BMVert *v, int count_max)
HeapSimple * BLI_heapsimple_new() ATTR_WARN_UNUSED_RESULT
BMFace * BM_face_exists(BMVert *const *varr, int len)
void * BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
BMEdge * BM_edge_exists(BMVert *v_a, BMVert *v_b)
MINLINE float normalize_v3(float n[3])
void BM_face_as_array_vert_tri(BMFace *f, BMVert *r_verts[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
bool BM_edge_loop_pair(BMEdge *e, BMLoop **r_la, BMLoop **r_lb)
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
float BM_edge_calc_length_squared(const BMEdge *e)
void BLI_heapsimple_insert(HeapSimple *heap, float value, void *ptr) ATTR_NONNULL(1)
void BM_log_face_removed(BMLog *log, BMFace *f)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void BM_face_kill(BMesh *bm, BMFace *f)
MINLINE float max_ff(float a, float b)
bool BLI_heapsimple_is_empty(const HeapSimple *heap) ATTR_NONNULL(1)
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
MINLINE float square_f(float a)
double BLI_time_now_seconds()
void * BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1)
void BM_data_interp_from_verts(BMesh *bm, const BMVert *v_src_1, const BMVert *v_src_2, BMVert *v_dst, const float fac)
Data, Interpolate From Verts.
VecBase< float, 3 > float3
void BKE_pbvh_node_mark_topology_update(bke::pbvh::Node &node)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void BM_log_vert_before_modified(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
const float * BM_log_find_original_vert_co(BMLog *log, BMVert *v)
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(bke::pbvh::BMeshNode *node)
BMEdge * BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *e_example, const eBMCreateFlag create_flag)
Main function for creating a new edge.
int BM_iter_as_array(BMesh *bm, const char itype, void *data, void **array, const int len)
Iterator as Array.
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
bool BM_vert_face_check(const BMVert *v)
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
#define BM_LOOPS_OF_VERT_ITER_END
#define BM_FACES_OF_VERT_ITER_BEGIN(f_iter_, v_)
#define pbvh_bmesh_node_vert_use_count_is_equal(nodes, cd_face_node_offset, node, v, n)
#define BM_LOOPS_OF_VERT_ITER_BEGIN(l_iter_radial_, v_)
#define BM_FACES_OF_VERT_ITER_END
#define EDGE_QUEUE_DISABLE(e)
#define EDGE_QUEUE_ENABLE(e)
#define EDGE_QUEUE_TEST(e)
struct BMLoop * radial_next
Set< BMFace *, 0 > bm_faces_
Set< BMVert *, 0 > bm_unique_verts_
Set< BMVert *, 0 > bm_other_verts_
std::optional< float3 > view_normal
bool(*) edge_queue_tri_in_range(const EdgeQueue *q, BMFace *f)
FastNodeBuildInfo * child1
FastNodeBuildInfo * child2