Blender V5.3
extract_mesh_vbo_mesh_analysis.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <algorithm>
10
11#include "MEM_guardedalloc.h"
12
13#include "BLI_jitter_2d.hh"
14#include "BLI_map.hh"
15#include "BLI_math_geom_c.hh"
16#include "BLI_math_matrix_c.hh"
18#include "BLI_math_vector.hh"
19#include "BLI_ordered_edge.hh"
20
21#include "BKE_bvh.hh"
22#include "BKE_bvhutils.hh"
23#include "BKE_editmesh.hh"
24#include "BKE_editmesh_bvh.hh"
25#include "BKE_editmesh_cache.hh"
26
27#include "extract_mesh.hh"
28
29namespace blender::draw {
30
31static void axis_from_enum_v3(float v[3], const char axis)
32{
33 zero_v3(v);
34 if (axis < 3) {
35 v[axis] = 1.0f;
36 }
37 else {
38 v[axis - 3] = -1.0f;
39 }
40}
41
42BLI_INLINE float overhang_remap(float fac, float min, float max, float minmax_irange)
43{
44 if (fac < min) {
45 fac = 1.0f;
46 }
47 else if (fac > max) {
48 fac = -1.0f;
49 }
50 else {
51 fac = (fac - min) * minmax_irange;
52 fac = 1.0f - fac;
53 CLAMP(fac, 0.0f, 1.0f);
54 }
55 return fac;
56}
57
59 const float4x4 &object_to_world,
60 MutableSpan<float> r_overhang)
61{
62 const MeshStatVis *statvis = &mr.toolsettings->statvis;
63 const float min = statvis->overhang_min / float(M_PI);
64 const float max = statvis->overhang_max / float(M_PI);
65 const char axis = statvis->overhang_axis;
66 float dir[3];
67 const float minmax_irange = 1.0f / (max - min);
68
69 BLI_assert(min <= max);
70
71 axis_from_enum_v3(dir, axis);
72
73 /* now convert into global space */
74 mul_transposed_mat3_m4_v3(object_to_world.ptr(), dir);
75 normalize_v3(dir);
76
78 BMIter iter;
79 BMesh *bm = mr.bm;
80 BMFace *f;
81 int l_index = 0;
82 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
83 float fac = angle_normalized_v3v3(bm_face_no_get(mr, f), dir) / float(M_PI);
84 fac = overhang_remap(fac, min, max, minmax_irange);
85 for (int i = 0; i < f->len; i++, l_index++) {
86 r_overhang[l_index] = fac;
87 }
88 }
89 }
90 else {
91 for (const int face_i : mr.faces.index_range()) {
92 float fac = angle_normalized_v3v3(mr.face_normals[face_i], dir) / float(M_PI);
93 fac = overhang_remap(fac, min, max, minmax_irange);
94 for (const int loop_i : mr.faces[face_i]) {
95 r_overhang[loop_i] = fac;
96 }
97 }
98 }
99}
100
104static void uv_from_jitter_v2(float uv[2])
105{
106 uv[0] += 0.5f;
107 uv[1] += 0.5f;
108 if (uv[0] + uv[1] > 1.0f) {
109 uv[0] = 1.0f - uv[0];
110 uv[1] = 1.0f - uv[1];
111 }
112
113 clamp_v2(uv, 0.0f, 1.0f);
114}
115
116BLI_INLINE float thickness_remap(float fac, float min, float max, float minmax_irange)
117{
118 /* important not '<=' */
119 if (fac < max) {
120 fac = (fac - min) * minmax_irange;
121 fac = 1.0f - fac;
122 CLAMP(fac, 0.0f, 1.0f);
123 }
124 else {
125 fac = -1.0f;
126 }
127 return fac;
128}
129
131 const float4x4 &object_to_world,
132 MutableSpan<float> r_thickness)
133{
134 const float eps_offset = 0.00002f; /* values <= 0.00001 give errors */
135 /* cheating to avoid another allocation */
136 float *face_dists = r_thickness.data() + (mr.corners_num - mr.faces_num);
137 const float scale = 1.0f / mat4_to_scale(object_to_world.ptr());
138 const MeshStatVis *statvis = &mr.toolsettings->statvis;
139 const float min = statvis->thickness_min * scale;
140 const float max = statvis->thickness_max * scale;
141 const float minmax_irange = 1.0f / (max - min);
142 const int samples = statvis->thickness_samples;
143 float jit_ofs[32][2];
144 BLI_assert(samples <= 32);
145 BLI_assert(min <= max);
146
147 std::fill_n(face_dists, mr.faces_num, max);
148
149 BLI_jitter_init(jit_ofs, samples);
150 for (int j = 0; j < samples; j++) {
151 uv_from_jitter_v2(jit_ofs[j]);
152 }
153
155 BMEditMesh *em = mr.edit_bmesh;
156 BMesh *bm = mr.bm;
158
159 BMBVHTree *bmtree = BKE_bmbvh_new_from_editmesh(em, bm, 0, nullptr, false);
160 const Span<std::array<BMLoop *, 3>> looptris = em->looptris;
161 for (int i = 0; i < mr.corner_tris_num; i++) {
162 const BMLoop *const *ltri = looptris[i].data();
163 const int index = BM_elem_index_get(ltri[0]->f);
164 const float *cos[3] = {
165 bm_vert_co_get(mr, ltri[0]->v),
166 bm_vert_co_get(mr, ltri[1]->v),
167 bm_vert_co_get(mr, ltri[2]->v),
168 };
169 float ray_co[3];
170 float ray_no[3];
171
172 normal_tri_v3(ray_no, cos[2], cos[1], cos[0]);
173
174 for (int j = 0; j < samples; j++) {
175 float dist = face_dists[index];
176 interp_v3_v3v3v3_uv(ray_co, cos[0], cos[1], cos[2], jit_ofs[j]);
177 madd_v3_v3fl(ray_co, ray_no, eps_offset);
178
179 BMFace *f_hit = BKE_bmbvh_ray_cast(bmtree, ray_co, ray_no, 0.0f, &dist, nullptr, nullptr);
180 if (f_hit && dist < face_dists[index]) {
181 float angle_fac = fabsf(
182 dot_v3v3(bm_face_no_get(mr, ltri[0]->f), bm_face_no_get(mr, f_hit)));
183 angle_fac = 1.0f - angle_fac;
184 angle_fac = angle_fac * angle_fac * angle_fac;
185 angle_fac = 1.0f - angle_fac;
186 dist /= angle_fac;
187 face_dists[index] = std::min(dist, face_dists[index]);
188 }
189 }
190 }
191 BKE_bmbvh_free(bmtree);
192
193 BMIter iter;
194 BMFace *f;
195 int l_index = 0;
196 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
197 float fac = face_dists[BM_elem_index_get(f)];
198 fac = thickness_remap(fac, min, max, minmax_irange);
199 for (int i = 0; i < f->len; i++, l_index++) {
200 r_thickness[l_index] = fac;
201 }
202 }
203 }
204 else {
205 if (mr.mesh->faces_num == 0) {
206 return;
207 }
208 const bke::bvh::Tree &tree = mr.mesh->bvh_tris();
209 const Span<int3> corner_tris = mr.mesh->corner_tris();
210 const Span<int> tri_faces = mr.mesh->corner_tri_faces();
211 for (const int i : corner_tris.index_range()) {
212 const int index = tri_faces[i];
213 const float *cos[3] = {mr.vert_positions[mr.corner_verts[corner_tris[i][0]]],
214 mr.vert_positions[mr.corner_verts[corner_tris[i][1]]],
215 mr.vert_positions[mr.corner_verts[corner_tris[i][2]]]};
216 float ray_co[3];
217 float ray_no[3];
218
219 normal_tri_v3(ray_no, cos[2], cos[1], cos[0]);
220
221 for (int j = 0; j < samples; j++) {
222 interp_v3_v3v3v3_uv(ray_co, cos[0], cos[1], cos[2], jit_ofs[j]);
223 madd_v3_v3fl(ray_co, ray_no, eps_offset);
224
225 const bke::bvh::Ray ray(ray_co, ray_no, face_dists[index]);
226 const std::optional<bke::bvh::RayHit> hit = tree.ray_intersect(ray);
227 if (hit && hit->distance < face_dists[index]) {
228 float angle_fac = fabsf(dot_v3v3(mr.face_normals[index], math::normalize(hit->normal)));
229 angle_fac = 1.0f - angle_fac;
230 angle_fac = angle_fac * angle_fac * angle_fac;
231 angle_fac = 1.0f - angle_fac;
232 face_dists[index] = std::min(hit->distance / angle_fac, face_dists[index]);
233 }
234 }
235 }
236
237 for (const int face_i : mr.faces.index_range()) {
238 float fac = face_dists[face_i];
239 fac = thickness_remap(fac, min, max, minmax_irange);
240 for (const int loop_i : mr.faces[face_i]) {
241 r_thickness[loop_i] = fac;
242 }
243 }
244 }
245}
246
254
255static bool bvh_overlap_cb(void *userdata, int index_a, int index_b, int /*thread*/)
256{
257 BVHTree_OverlapData *data = static_cast<BVHTree_OverlapData *>(userdata);
258
259 if (data->tri_faces[index_a] == data->tri_faces[index_b]) [[unlikely]] {
260 return false;
261 }
262
263 const int3 tri_a = data->corner_tris[index_a];
264 const int3 tri_b = data->corner_tris[index_b];
265
266 const float *tri_a_co[3] = {data->positions[data->corner_verts[tri_a[0]]],
267 data->positions[data->corner_verts[tri_a[1]]],
268 data->positions[data->corner_verts[tri_a[2]]]};
269 const float *tri_b_co[3] = {data->positions[data->corner_verts[tri_b[0]]],
270 data->positions[data->corner_verts[tri_b[1]]],
271 data->positions[data->corner_verts[tri_b[2]]]};
272 float ix_pair[2][3];
273 int verts_shared = 0;
274
275 verts_shared = (ELEM(tri_a_co[0], UNPACK3(tri_b_co)) + ELEM(tri_a_co[1], UNPACK3(tri_b_co)) +
276 ELEM(tri_a_co[2], UNPACK3(tri_b_co)));
277
278 /* if 2 points are shared, bail out */
279 if (verts_shared >= 2) {
280 return false;
281 }
282
283 return (isect_tri_tri_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) &&
284 /* if we share a vertex, check the intersection isn't a 'point' */
285 ((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon)));
286}
287
289{
290 for (int l_index = 0; l_index < mr.corners_num; l_index++) {
291 r_intersect[l_index] = -1.0f;
292 }
293
295 BMEditMesh *em = mr.edit_bmesh;
296 uint overlap_len;
297 BMesh *bm = mr.bm;
298
300
301 BMBVHTree *bmtree = BKE_bmbvh_new_from_editmesh(em, bm, 0, nullptr, false);
302 BVHTreeOverlap *overlap = BKE_bmbvh_overlap_self(bmtree, &overlap_len);
303
304 if (overlap) {
305 for (int i = 0; i < overlap_len; i++) {
306 BMFace *f_hit_pair[2] = {
307 em->looptris[overlap[i].indexA][0]->f,
308 em->looptris[overlap[i].indexB][0]->f,
309 };
310 for (int j = 0; j < 2; j++) {
311 BMFace *f_hit = f_hit_pair[j];
312 BMLoop *l_first = BM_FACE_FIRST_LOOP(f_hit);
313 int l_index = BM_elem_index_get(l_first);
314 for (int k = 0; k < f_hit->len; k++, l_index++) {
315 r_intersect[l_index] = 1.0f;
316 }
317 }
318 }
319 MEM_delete(overlap);
320 }
321
322 BKE_bmbvh_free(bmtree);
323 }
324 else {
325 uint overlap_len;
326 bke::BVHTreeFromMesh treeData = mr.mesh->bvh_corner_tris();
327 const BVHTree *tree = treeData.tree;
328 if (tree == nullptr) {
329 return;
330 }
331
333 data.positions = mr.vert_positions;
334 data.corner_verts = mr.corner_verts;
335 data.corner_tris = mr.mesh->corner_tris();
336 data.tri_faces = mr.mesh->corner_tri_faces();
337 data.epsilon = BLI_bvhtree_get_epsilon(tree);
338
339 BVHTreeOverlap *overlap = BLI_bvhtree_overlap_self(tree, &overlap_len, bvh_overlap_cb, &data);
340 if (overlap) {
341 for (int i = 0; i < overlap_len; i++) {
342
343 for (const IndexRange f_hit : {mr.faces[data.tri_faces[overlap[i].indexA]],
344 mr.faces[data.tri_faces[overlap[i].indexB]]})
345 {
346 int l_index = f_hit.start();
347 for (int k = 0; k < f_hit.size(); k++, l_index++) {
348 r_intersect[l_index] = 1.0f;
349 }
350 }
351 }
352 MEM_delete(overlap);
353 }
354 }
355}
356
357BLI_INLINE float distort_remap(float fac, float min, float /*max*/, float minmax_irange)
358{
359 if (fac >= min) {
360 fac = (fac - min) * minmax_irange;
361 CLAMP(fac, 0.0f, 1.0f);
362 }
363 else {
364 /* fallback */
365 fac = -1.0f;
366 }
367 return fac;
368}
369
371{
372 const MeshStatVis *statvis = &mr.toolsettings->statvis;
373 const float min = statvis->distort_min;
374 const float max = statvis->distort_max;
375 const float minmax_irange = 1.0f / (max - min);
376
378 BMIter iter;
379 BMesh *bm = mr.bm;
380 BMFace *f;
381
382 int l_index = 0;
383 int f_index = 0;
384 BM_ITER_MESH_INDEX (f, &iter, bm, BM_FACES_OF_MESH, f_index) {
385 float fac = -1.0f;
386
387 if (f->len > 3) {
388 BMLoop *l_iter, *l_first;
389
390 fac = 0.0f;
391 l_iter = l_first = BM_FACE_FIRST_LOOP(f);
392 do {
393 const float *no_face;
394 float no_corner[3];
395 if (!mr.bm_vert_coords.is_empty()) {
396 no_face = mr.bm_face_normals[f_index];
398 l_iter,
399 no_face,
400 reinterpret_cast<const float (*)[3]>(mr.bm_vert_coords.data()),
401 no_corner);
402 }
403 else {
404 no_face = f->no;
405 BM_loop_calc_face_normal_safe(l_iter, no_corner);
406 }
407
408 /* simple way to detect (what is most likely) concave */
409 if (dot_v3v3(no_face, no_corner) < 0.0f) {
410 negate_v3(no_corner);
411 }
412 fac = max_ff(fac, angle_normalized_v3v3(no_face, no_corner));
413
414 } while ((l_iter = l_iter->next) != l_first);
415 fac *= 2.0f;
416 }
417
418 fac = distort_remap(fac, min, max, minmax_irange);
419 for (int i = 0; i < f->len; i++, l_index++) {
420 r_distort[l_index] = fac;
421 }
422 }
423 }
424 else {
425 for (const int face_index : mr.faces.index_range()) {
426 const IndexRange face = mr.faces[face_index];
427 float fac = -1.0f;
428
429 if (face.size() > 3) {
430 const float *f_no = mr.face_normals[face_index];
431 fac = 0.0f;
432
433 for (const int corner : face.drop_front(1)) {
434 const int corner_prev = bke::mesh::face_corner_prev(face, corner);
435 const int corner_next = bke::mesh::face_corner_next(face, corner);
436 float no_corner[3];
437 normal_tri_v3(no_corner,
438 mr.vert_positions[mr.corner_verts[corner_prev]],
439 mr.vert_positions[mr.corner_verts[corner]],
440 mr.vert_positions[mr.corner_verts[corner_next]]);
441 /* simple way to detect (what is most likely) concave */
442 if (dot_v3v3(f_no, no_corner) < 0.0f) {
443 negate_v3(no_corner);
444 }
445 fac = max_ff(fac, angle_normalized_v3v3(f_no, no_corner));
446 }
447 fac *= 2.0f;
448 }
449
450 fac = distort_remap(fac, min, max, minmax_irange);
451 for (const int corner : face) {
452 r_distort[corner] = fac;
453 }
454 }
455 }
456}
457
458BLI_INLINE float sharp_remap(float fac, float min, float /*max*/, float minmax_irange)
459{
460 /* important not '>=' */
461 if (fac > min) {
462 fac = (fac - min) * minmax_irange;
463 CLAMP(fac, 0.0f, 1.0f);
464 }
465 else {
466 /* fallback */
467 fac = -1.0f;
468 }
469 return fac;
470}
471
473{
474 const MeshStatVis *statvis = &mr.toolsettings->statvis;
475 const float min = statvis->sharp_min;
476 const float max = statvis->sharp_max;
477 const float minmax_irange = 1.0f / (max - min);
478
479 /* Can we avoid this extra allocation? */
480 float *vert_angles = MEM_new_array_uninitialized<float>(mr.verts_num, __func__);
481 std::fill_n(vert_angles, mr.verts_num, -M_PI);
482
484 BMIter iter;
485 BMesh *bm = mr.bm;
486 BMFace *efa;
487 BMEdge *e;
488 /* first assign float values to verts */
489 BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
491 float *col1 = &vert_angles[BM_elem_index_get(e->v1)];
492 float *col2 = &vert_angles[BM_elem_index_get(e->v2)];
493 *col1 = max_ff(*col1, angle);
494 *col2 = max_ff(*col2, angle);
495 }
496 /* Copy vert value to loops. */
497 BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
498 BMLoop *l_iter, *l_first;
499 l_iter = l_first = BM_FACE_FIRST_LOOP(efa);
500 do {
501 int l_index = BM_elem_index_get(l_iter);
502 int v_index = BM_elem_index_get(l_iter->v);
503 r_sharp[l_index] = sharp_remap(vert_angles[v_index], min, max, minmax_irange);
504 } while ((l_iter = l_iter->next) != l_first);
505 }
506 }
507 else {
508 /* first assign float values to verts */
509
511 eh.reserve(mr.edges_num);
512
513 for (int face_index = 0; face_index < mr.faces_num; face_index++) {
514 const IndexRange face = mr.faces[face_index];
515 for (const int corner : face) {
516 const int vert_curr = mr.corner_verts[corner];
517 const int vert_next = mr.corner_verts[bke::mesh::face_corner_next(face, corner)];
518 float angle;
519 eh.add_or_modify(
520 {vert_curr, vert_next},
521 [&](int *value) { *value = face_index; },
522 [&](int *value) {
523 const int other_face_index = *value;
524 if (other_face_index == -1) {
525 /* non-manifold edge */
526 angle = DEG2RADF(90.0f);
527 return;
528 }
529 const float *f1_no = mr.face_normals[face_index];
530 const float *f2_no = mr.face_normals[other_face_index];
531 angle = angle_normalized_v3v3(f1_no, f2_no);
532 angle = is_edge_convex_v3(mr.vert_positions[vert_curr],
533 mr.vert_positions[vert_next],
534 f1_no,
535 f2_no) ?
536 angle :
537 -angle;
538 /* Tag as manifold. */
539 *value = -1;
540 });
541 float *col1 = &vert_angles[vert_curr];
542 float *col2 = &vert_angles[vert_next];
543 *col1 = max_ff(*col1, angle);
544 *col2 = max_ff(*col2, angle);
545 }
546 }
547 /* Remaining non manifold edges. */
548 for (const OrderedEdge &edge : eh.keys()) {
549 const float angle = DEG2RADF(90.0f);
550 float *col1 = &vert_angles[edge.v_low];
551 float *col2 = &vert_angles[edge.v_high];
552 *col1 = max_ff(*col1, angle);
553 *col2 = max_ff(*col2, angle);
554 }
555
556 for (int l_index = 0; l_index < mr.corners_num; l_index++) {
557 const int vert = mr.corner_verts[l_index];
558 r_sharp[l_index] = sharp_remap(vert_angles[vert], min, max, minmax_irange);
559 }
560 }
561
562 MEM_delete(vert_angles);
563}
564
566{
567 static const GPUVertFormat format = GPU_vertformat_from_attribute("weight",
568 gpu::VertAttrType::SFLOAT_32);
569
570 gpu::VertBufPtr vbo = gpu::VertBufPtr(GPU_vertbuf_create_with_format(format));
572 MutableSpan<float> vbo_data = vbo->data<float>();
573
574 switch (mr.toolsettings->statvis.type) {
576 statvis_calc_overhang(mr, object_to_world, vbo_data);
577 break;
579 statvis_calc_thickness(mr, object_to_world, vbo_data);
580 break;
582 statvis_calc_intersect(mr, vbo_data);
583 break;
585 statvis_calc_distort(mr, vbo_data);
586 break;
588 statvis_calc_sharp(mr, vbo_data);
589 break;
590 }
591 return vbo;
592}
593
594} // namespace blender::draw
#define DEG2RADF(_deg)
#define M_PI
Read Blender memory allocation and freeing.
#define CLAMP(a, b, c)
#define BLI_INLINE
#define UNPACK3(a)
#define ELEM(...)
#define BM_FACE_FIRST_LOOP(p)
#define BM_elem_index_get(ele)
#define BM_ITER_MESH(ele, iter, bm, itype)
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
btScalar max
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition btVector3.h:356
constexpr int64_t size() const
constexpr IndexRange drop_front(int64_t n) const
KeyIterator keys() const &
Definition BLI_map.hh:875
void reserve(int64_t n)
Definition BLI_map.hh:1028
auto add_or_modify(const Key &key, const CreateValueF &create_value, const ModifyValueF &modify_value) -> decltype(create_value(nullptr))
Definition BLI_map.hh:481
constexpr T * data() const
Definition BLI_span.hh:545
constexpr const T * data() const
Definition BLI_span.hh:219
constexpr IndexRange index_range() const
Definition BLI_span.hh:405
std::optional< RayHit > ray_intersect(const Ray &ray) const
Definition bvh.cc:439
Extraction of Mesh data into VBO to feed to GPU.
#define cos
float3x3 scale(float3x3 mat, float2 scale)
int face_corner_prev(const IndexRange face, const int corner)
Definition BKE_mesh.hh:306
int face_corner_next(const IndexRange face, const int corner)
Definition BKE_mesh.hh:315
static void statvis_calc_distort(const MeshRenderData &mr, MutableSpan< float > r_distort)
BLI_INLINE float distort_remap(float fac, float min, float, float minmax_irange)
static bool bvh_overlap_cb(void *userdata, int index_a, int index_b, int)
static void axis_from_enum_v3(float v[3], const char axis)
static void statvis_calc_thickness(const MeshRenderData &mr, const float4x4 &object_to_world, MutableSpan< float > r_thickness)
BLI_INLINE float sharp_remap(float fac, float min, float, float minmax_irange)
static void statvis_calc_overhang(const MeshRenderData &mr, const float4x4 &object_to_world, MutableSpan< float > r_overhang)
BLI_INLINE const float * bm_face_no_get(const MeshRenderData &mr, const BMFace *efa)
static void uv_from_jitter_v2(float uv[2])
static void statvis_calc_sharp(const MeshRenderData &mr, MutableSpan< float > r_sharp)
static void statvis_calc_intersect(const MeshRenderData &mr, MutableSpan< float > r_intersect)
BLI_INLINE float overhang_remap(float fac, float min, float max, float minmax_irange)
BLI_INLINE const float * bm_vert_co_get(const MeshRenderData &mr, const BMVert *eve)
gpu::VertBufPtr extract_mesh_analysis(const MeshRenderData &mr, const float4x4 &object_to_world)
BLI_INLINE float thickness_remap(float fac, float min, float max, float minmax_irange)
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
float BM_loop_calc_face_normal_safe_vcos(const BMLoop *l, const float normal_fallback[3], float const (*vertexCos)[3], float r_normal[3])
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
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
void BKE_bmbvh_free(BMBVHTree *tree)
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
bool isect_tri_tri_v3(const float t_a0[3], const float t_a1[3], const float t_a2[3], const float t_b0[3], const float t_b1[3], const float t_b2[3], float r_i1[3], float r_i2[3])
unsigned int uint
Definition BKE_text.h:55
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
float BLI_bvhtree_get_epsilon(const BVHTree *tree)
struct BMFace * BKE_bmbvh_ray_cast(const BMBVHTree *tree, const float co[3], const float dir[3], float radius, float *r_dist, float r_hitout[3], float r_cagehit[3])
float mat4_to_scale(const float mat[4][4])
GPUVertFormat GPU_vertformat_from_attribute(StringRef name, gpu::VertAttrType type)
ATTR_WARN_UNUSED_RESULT const BMVert * v
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
Definition math_geom.cc:45
MatBase< float, 4, 4 > float4x4
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2])
VecBase< int32_t, 3 > int3
BMesh const char void * data
BMBVHTree * BKE_bmbvh_new_from_editmesh(struct BMEditMesh *em, struct BMesh *bm, int flag, const float3 *cos_cage, bool cos_cage_free)
MINLINE void negate_v3(float r[3])
void BLI_jitter_init(float(*jitarr)[2], int num)
Definition jitter_2d.cc:129
BVHTreeOverlap * BLI_bvhtree_overlap_self(const BVHTree *tree, unsigned int *r_overlap_num, BVHTree_OverlapCallback callback, void *userdata)
MINLINE void zero_v3(float r[3])
float BM_loop_calc_face_normal_safe(const BMLoop *l, float r_normal[3])
MINLINE float normalize_v3(float n[3])
MINLINE void clamp_v2(float vec[2], float min, float max)
MINLINE float max_ff(float a, float b)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
bool is_edge_convex_v3(const float v1[3], const float v2[3], const float f1_no[3], const float f2_no[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
struct BVHTreeOverlap * BKE_bmbvh_overlap_self(const BMBVHTree *bmtree, unsigned int *r_overlap_tot)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
float BM_edge_calc_face_angle_signed(const BMEdge *e)
void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3])
#define fabsf
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define min(a, b)
Definition sort.cc:38
Array< std::array< BMLoop *, 3 > > looptris
struct BMLoop * next
struct BMVert * v
struct MeshStatVis statvis
const ToolSettings * toolsettings
OffsetIndices< int > faces