49 fac = (fac -
min) * minmax_irange;
51 CLAMP(fac, 0.0f, 1.0f);
65 const float minmax_irange = 1.0f / (
max -
min);
84 for (
int i = 0;
i < f->
len;
i++, l_index++) {
85 r_overhang[l_index] = fac;
90 for (
const int face_i : mr.
faces.index_range()) {
93 for (
const int loop_i : mr.
faces[face_i]) {
94 r_overhang[loop_i] = fac;
107 if (uv[0] + uv[1] > 1.0f) {
108 uv[0] = 1.0f - uv[0];
109 uv[1] = 1.0f - uv[1];
119 fac = (fac -
min) * minmax_irange;
121 CLAMP(fac, 0.0f, 1.0f);
133 const float eps_offset = 0.00002f;
140 const float minmax_irange = 1.0f / (
max -
min);
142 float jit_ofs[32][2];
149 for (
int j = 0; j < samples; j++) {
163 const float *
cos[3] = {
173 for (
int j = 0; j < samples; j++) {
174 float dist = face_dists[index];
179 if (f_hit && dist < face_dists[index]) {
180 float angle_fac =
fabsf(
182 angle_fac = 1.0f - angle_fac;
183 angle_fac = angle_fac * angle_fac * angle_fac;
184 angle_fac = 1.0f - angle_fac;
186 face_dists[index] = std::min(dist, face_dists[index]);
198 for (
int i = 0;
i < f->
len;
i++, l_index++) {
199 r_thickness[l_index] = fac;
206 if (
tree ==
nullptr) {
213 const int index = tri_faces[
i];
222 for (
int j = 0; j < samples; j++) {
228 hit.
dist = face_dists[index];
231 hit.
dist < face_dists[index])
234 angle_fac = 1.0f - angle_fac;
235 angle_fac = angle_fac * angle_fac * angle_fac;
236 angle_fac = 1.0f - angle_fac;
237 hit.
dist /= angle_fac;
238 face_dists[index] = std::min(hit.
dist, face_dists[index]);
243 for (
const int face_i : mr.
faces.index_range()) {
244 float fac = face_dists[face_i];
246 for (
const int loop_i : mr.
faces[face_i]) {
247 r_thickness[loop_i] = fac;
269 const int3 tri_a =
data->corner_tris[index_a];
270 const int3 tri_b =
data->corner_tris[index_b];
272 const float *tri_a_co[3] = {
data->positions[
data->corner_verts[tri_a[0]]],
273 data->positions[
data->corner_verts[tri_a[1]]],
274 data->positions[
data->corner_verts[tri_a[2]]]};
275 const float *tri_b_co[3] = {
data->positions[
data->corner_verts[tri_b[0]]],
276 data->positions[
data->corner_verts[tri_b[1]]],
277 data->positions[
data->corner_verts[tri_b[2]]]};
279 int verts_shared = 0;
285 if (verts_shared >= 2) {
296 for (
int l_index = 0; l_index < mr.
corners_num; l_index++) {
297 r_intersect[l_index] = -1.0f;
311 for (
int i = 0;
i < overlap_len;
i++) {
316 for (
int j = 0; j < 2; j++) {
317 BMFace *f_hit = f_hit_pair[j];
320 for (
int k = 0; k < f_hit->
len; k++, l_index++) {
321 r_intersect[l_index] = 1.0f;
334 if (
tree ==
nullptr) {
341 data.corner_tris = mr.
mesh->corner_tris();
342 data.tri_faces = mr.
mesh->corner_tri_faces();
347 for (
int i = 0;
i < overlap_len;
i++) {
352 int l_index = f_hit.start();
353 for (
int k = 0; k < f_hit.size(); k++, l_index++) {
354 r_intersect[l_index] = 1.0f;
366 fac = (fac -
min) * minmax_irange;
367 CLAMP(fac, 0.0f, 1.0f);
381 const float minmax_irange = 1.0f / (
max -
min);
400 const float *no_face;
416 if (
dot_v3v3(no_face, no_corner) < 0.0f) {
421 }
while ((l_iter = l_iter->
next) != l_first);
426 for (
int i = 0;
i < f->
len;
i++, l_index++) {
427 r_distort[l_index] = fac;
432 for (
const int face_index : mr.
faces.index_range()) {
436 if (face.
size() > 3) {
449 if (
dot_v3v3(f_no, no_corner) < 0.0f) {
458 for (
const int corner : face) {
459 r_distort[corner] = fac;
469 fac = (fac -
min) * minmax_irange;
470 CLAMP(fac, 0.0f, 1.0f);
484 const float minmax_irange = 1.0f / (
max -
min);
512 }
while ((l_iter = l_iter->
next) != l_first);
521 for (
int face_index = 0; face_index < mr.
faces_num; face_index++) {
523 for (
const int corner : face) {
528 {vert_curr, vert_next},
529 [&](
int *value) { *value = face_index; },
531 const int other_face_index = *value;
532 if (other_face_index == -1) {
549 float *col1 = &vert_angles[vert_curr];
550 float *col2 = &vert_angles[vert_next];
558 float *col1 = &vert_angles[edge.v_low];
559 float *col2 = &vert_angles[edge.v_high];
564 for (
int l_index = 0; l_index < mr.
corners_num; l_index++) {
576 gpu::VertAttrType::SFLOAT_32);
BMBVHTree * BKE_bmbvh_new_from_editmesh(struct BMEditMesh *em, int flag, const blender::float3 *cos_cage, bool cos_cage_free)
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])
struct BVHTreeOverlap * BKE_bmbvh_overlap_self(const BMBVHTree *bmtree, unsigned int *r_overlap_tot)
void BKE_bmbvh_free(BMBVHTree *tree)
void BLI_jitter_init(float(*jitarr)[2], int num)
BVHTreeOverlap * BLI_bvhtree_overlap_self(const BVHTree *tree, unsigned int *r_overlap_num, BVHTree_OverlapCallback callback, void *userdata)
float BLI_bvhtree_get_epsilon(const BVHTree *tree)
int BLI_bvhtree_ray_cast(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
MINLINE float max_ff(float a, float b)
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])
bool is_edge_convex_v3(const float v1[3], const float v2[3], const float f1_no[3], const float f2_no[3])
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
float mat4_to_scale(const float mat[4][4])
void mul_transposed_mat3_m4_v3(const float M[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void copy_vn_fl(float *array_tar, int size, float val)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void negate_v3(float r[3])
MINLINE void clamp_v2(float vec[2], float min, float max)
MINLINE void zero_v3(float r[3])
float angle_normalized_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2])
MINLINE float normalize_v3(float n[3])
static blender::gpu::VertBuf * GPU_vertbuf_create_with_format(const GPUVertFormat &format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Read Guarded memory(de)allocation.
#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)
BMesh const char void * data
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
float BM_loop_calc_face_normal_safe(const BMLoop *l, float r_normal[3])
float BM_loop_calc_face_normal_safe_vcos(const BMLoop *l, const float normal_fallback[3], float const (*vertexCos)[3], float r_normal[3])
float BM_edge_calc_face_angle_signed(const BMEdge *e)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
constexpr int64_t size() const
constexpr IndexRange drop_front(int64_t n) const
KeyIterator keys() const &
auto add_or_modify(const Key &key, const CreateValueF &create_value, const ModifyValueF &modify_value) -> decltype(create_value(nullptr))
constexpr T * data() const
constexpr const T * data() const
constexpr IndexRange index_range() const
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
int face_corner_prev(const IndexRange face, const int corner)
int face_corner_next(const IndexRange face, const int corner)
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
T cos(const AngleRadianBase< T > &a)
MatBase< T, NumCol, NumRow > scale(const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
T min(const T &a, const T &b)
T max(const T &a, const T &b)
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 3 > int3
blender::Array< std::array< BMLoop *, 3 > > looptris
const c_style_mat & ptr() const
BVHTree_RayCastCallback raycast_callback
Span< float3 > bm_vert_coords
const ToolSettings * toolsettings
Span< float3 > vert_positions
MeshExtractType extract_type
Span< float3 > bm_face_normals
Span< float3 > face_normals
OffsetIndices< int > faces