Cleanup: clarify naming for MLoopTri

The term `looptri` was used ambiguously for both single & arrays.
The term `tri` was also used, causing `tri->tri`.

Use terms:

- `looptris` for an array or when dealing with multiple items.
- `looptri` is used when dealing with a single item.
- `lt` for a single MLoopTri variables & arguments.

This was already a convention but not followed closely.
This commit is contained in:
Campbell Barton 2023-12-14 12:08:21 +11:00
parent 931b2554e2
commit 944e0483a6
118 changed files with 889 additions and 896 deletions

@ -326,13 +326,13 @@ static void attr_create_generic(Scene *scene,
} }
else { else {
for (const int i : looptris.index_range()) { for (const int i : looptris.index_range()) {
const MLoopTri &tri = looptris[i]; const MLoopTri &lt = looptris[i];
data[i * 3 + 0] = make_uchar4( data[i * 3 + 0] = make_uchar4(
src[tri.tri[0]][0], src[tri.tri[0]][1], src[tri.tri[0]][2], src[tri.tri[0]][3]); src[lt.tri[0]][0], src[lt.tri[0]][1], src[lt.tri[0]][2], src[lt.tri[0]][3]);
data[i * 3 + 1] = make_uchar4( data[i * 3 + 1] = make_uchar4(
src[tri.tri[1]][0], src[tri.tri[1]][1], src[tri.tri[1]][2], src[tri.tri[1]][3]); src[lt.tri[1]][0], src[lt.tri[1]][1], src[lt.tri[1]][2], src[lt.tri[1]][3]);
data[i * 3 + 2] = make_uchar4( data[i * 3 + 2] = make_uchar4(
src[tri.tri[2]][0], src[tri.tri[2]][1], src[tri.tri[2]][2], src[tri.tri[2]][3]); src[lt.tri[2]][0], src[lt.tri[2]][1], src[lt.tri[2]][2], src[lt.tri[2]][3]);
} }
} }
return true; return true;
@ -376,10 +376,10 @@ static void attr_create_generic(Scene *scene,
} }
else { else {
for (const int i : looptris.index_range()) { for (const int i : looptris.index_range()) {
const MLoopTri &tri = looptris[i]; const MLoopTri &lt = looptris[i];
data[i * 3 + 0] = Converter::convert(src[tri.tri[0]]); data[i * 3 + 0] = Converter::convert(src[lt.tri[0]]);
data[i * 3 + 1] = Converter::convert(src[tri.tri[1]]); data[i * 3 + 1] = Converter::convert(src[lt.tri[1]]);
data[i * 3 + 2] = Converter::convert(src[tri.tri[2]]); data[i * 3 + 2] = Converter::convert(src[lt.tri[2]]);
} }
} }
break; break;
@ -469,10 +469,10 @@ static void attr_create_uv_map(Scene *scene,
uv_name.c_str(), ATTR_DOMAIN_CORNER); uv_name.c_str(), ATTR_DOMAIN_CORNER);
float2 *fdata = uv_attr->data_float2(); float2 *fdata = uv_attr->data_float2();
for (const int i : looptris.index_range()) { for (const int i : looptris.index_range()) {
const MLoopTri &tri = looptris[i]; const MLoopTri &lt = looptris[i];
fdata[i * 3 + 0] = make_float2(b_uv_map[tri.tri[0]][0], b_uv_map[tri.tri[0]][1]); fdata[i * 3 + 0] = make_float2(b_uv_map[lt.tri[0]][0], b_uv_map[lt.tri[0]][1]);
fdata[i * 3 + 1] = make_float2(b_uv_map[tri.tri[1]][0], b_uv_map[tri.tri[1]][1]); fdata[i * 3 + 1] = make_float2(b_uv_map[lt.tri[1]][0], b_uv_map[lt.tri[1]][1]);
fdata[i * 3 + 2] = make_float2(b_uv_map[tri.tri[2]][0], b_uv_map[tri.tri[2]][1]); fdata[i * 3 + 2] = make_float2(b_uv_map[lt.tri[2]][0], b_uv_map[lt.tri[2]][1]);
} }
} }
@ -915,10 +915,10 @@ static void create_mesh(Scene *scene,
const blender::Span<MLoopTri> looptris = b_mesh.looptris(); const blender::Span<MLoopTri> looptris = b_mesh.looptris();
for (const int i : looptris.index_range()) { for (const int i : looptris.index_range()) {
const MLoopTri &tri = looptris[i]; const MLoopTri &lt = looptris[i];
triangles[i * 3 + 0] = corner_verts[tri.tri[0]]; triangles[i * 3 + 0] = corner_verts[lt.tri[0]];
triangles[i * 3 + 1] = corner_verts[tri.tri[1]]; triangles[i * 3 + 1] = corner_verts[lt.tri[1]];
triangles[i * 3 + 2] = corner_verts[tri.tri[2]]; triangles[i * 3 + 2] = corner_verts[lt.tri[2]];
} }
if (!material_indices.is_empty()) { if (!material_indices.is_empty()) {
@ -944,9 +944,9 @@ static void create_mesh(Scene *scene,
if (use_loop_normals && !corner_normals.is_empty()) { if (use_loop_normals && !corner_normals.is_empty()) {
for (const int i : looptris.index_range()) { for (const int i : looptris.index_range()) {
const MLoopTri &tri = looptris[i]; const MLoopTri &lt = looptris[i];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
const int corner = tri.tri[i]; const int corner = lt.tri[i];
const int vert = corner_verts[corner]; const int vert = corner_verts[corner];
const float *normal = corner_normals[corner]; const float *normal = corner_normals[corner];
N[vert] = make_float3(normal[0], normal[1], normal[2]); N[vert] = make_float3(normal[0], normal[1], normal[2]);

@ -26,7 +26,7 @@ typedef struct DualConInput {
int co_stride; int co_stride;
int totco; int totco;
DualConTri looptri; DualConTri looptris;
int tri_stride; int tri_stride;
int tottri; int tottri;

@ -22,7 +22,7 @@ static void veccopy(float dst[3], const float src[3])
} }
#define GET_TRI(_mesh, _n) \ #define GET_TRI(_mesh, _n) \
(*(DualConTri)(((char *)(_mesh)->looptri) + ((_n) * (_mesh)->tri_stride))) (*(DualConTri)(((char *)(_mesh)->looptris) + ((_n) * (_mesh)->tri_stride)))
#define GET_CO(_mesh, _n) (*(DualConCo)(((char *)(_mesh)->co) + ((_n) * (_mesh)->co_stride))) #define GET_CO(_mesh, _n) (*(DualConCo)(((char *)(_mesh)->co) + ((_n) * (_mesh)->co_stride)))

@ -65,15 +65,15 @@ enum BVHCacheType {
BVHTREE_FROM_VERTS, BVHTREE_FROM_VERTS,
BVHTREE_FROM_EDGES, BVHTREE_FROM_EDGES,
BVHTREE_FROM_FACES, BVHTREE_FROM_FACES,
BVHTREE_FROM_LOOPTRI, BVHTREE_FROM_LOOPTRIS,
BVHTREE_FROM_LOOPTRI_NO_HIDDEN, BVHTREE_FROM_LOOPTRIS_NO_HIDDEN,
BVHTREE_FROM_LOOSEVERTS, BVHTREE_FROM_LOOSEVERTS,
BVHTREE_FROM_LOOSEEDGES, BVHTREE_FROM_LOOSEEDGES,
BVHTREE_FROM_EM_LOOSEVERTS, BVHTREE_FROM_EM_LOOSEVERTS,
BVHTREE_FROM_EM_EDGES, BVHTREE_FROM_EM_EDGES,
BVHTREE_FROM_EM_LOOPTRI, BVHTREE_FROM_EM_LOOPTRIS,
/* Keep `BVHTREE_MAX_ITEM` as last item. */ /* Keep `BVHTREE_MAX_ITEM` as last item. */
BVHTREE_MAX_ITEM, BVHTREE_MAX_ITEM,
@ -150,32 +150,32 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
int tree_type, int tree_type,
int axis); int axis);
BVHTree *bvhtree_from_editmesh_looptri( BVHTree *bvhtree_from_editmesh_looptris(
BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis); BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis);
/** /**
* Builds a BVH-tree where nodes are the `looptri` faces of the given `bm`. * Builds a BVH-tree where nodes are triangles faces (#MLoopTri) of the given `bm`.
*/ */
BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data, BVHTree *bvhtree_from_editmesh_looptris_ex(BVHTreeFromEditMesh *data,
BMEditMesh *em, BMEditMesh *em,
blender::BitSpan mask, blender::BitSpan mask,
int looptri_num_active, int looptris_num_active,
float epsilon, float epsilon,
int tree_type, int tree_type,
int axis); int axis);
/** /**
* Builds a BVH-tree where nodes are the looptri faces of the given mesh. * Builds a BVH-tree where nodes are the triangle faces (#MLoopTri) of the given mesh.
*/ */
BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data, BVHTree *bvhtree_from_mesh_looptris_ex(BVHTreeFromMesh *data,
blender::Span<blender::float3> vert_positions, blender::Span<blender::float3> vert_positions,
blender::Span<int> corner_verts, blender::Span<int> corner_verts,
blender::Span<MLoopTri> looptris, blender::Span<MLoopTri> looptris,
blender::BitSpan mask, blender::BitSpan mask,
int looptri_num_active, int looptris_num_active,
float epsilon, float epsilon,
int tree_type, int tree_type,
int axis); int axis);
/** /**
* Builds or queries a BVH-cache for the cache BVH-tree of the request type. * Builds or queries a BVH-cache for the cache BVH-tree of the request type.

@ -67,23 +67,23 @@ struct BMEditMesh {
/* editmesh.cc */ /* editmesh.cc */
void BKE_editmesh_looptri_calc_ex(BMEditMesh *em, const BMeshCalcTessellation_Params *params); void BKE_editmesh_looptris_calc_ex(BMEditMesh *em, const BMeshCalcTessellation_Params *params);
void BKE_editmesh_looptri_calc(BMEditMesh *em); void BKE_editmesh_looptris_calc(BMEditMesh *em);
void BKE_editmesh_looptri_calc_with_partial_ex(BMEditMesh *em, void BKE_editmesh_looptris_calc_with_partial_ex(BMEditMesh *em,
BMPartialUpdate *bmpinfo, BMPartialUpdate *bmpinfo,
const BMeshCalcTessellation_Params *params); const BMeshCalcTessellation_Params *params);
void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo); void BKE_editmesh_looptris_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo);
void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo); void BKE_editmesh_looptris_and_normals_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo);
/** /**
* Performing the face normal calculation at the same time as tessellation * Performing the face normal calculation at the same time as tessellation
* gives a reasonable performance boost (approx ~20% faster). * gives a reasonable performance boost (approx ~20% faster).
*/ */
void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em); void BKE_editmesh_looptris_and_normals_calc(BMEditMesh *em);
/** /**
* \note The caller is responsible for ensuring triangulation data, * \note The caller is responsible for ensuring triangulation data,
* typically by calling #BKE_editmesh_looptri_calc. * typically by calling #BKE_editmesh_looptris_calc.
*/ */
BMEditMesh *BKE_editmesh_create(BMesh *bm); BMEditMesh *BKE_editmesh_create(BMesh *bm);
BMEditMesh *BKE_editmesh_copy(BMEditMesh *em); BMEditMesh *BKE_editmesh_copy(BMEditMesh *em);

@ -70,14 +70,14 @@ struct BMVert *BKE_bmbvh_find_vert_closest(BMBVHTree *tree, const float co[3], f
struct BMFace *BKE_bmbvh_find_face_closest(BMBVHTree *tree, const float co[3], float dist_max); struct BMFace *BKE_bmbvh_find_face_closest(BMBVHTree *tree, const float co[3], float dist_max);
/** /**
* Overlap indices reference the looptri's. * Overlap indices reference the looptris.
*/ */
struct BVHTreeOverlap *BKE_bmbvh_overlap(const BMBVHTree *bmtree_a, struct BVHTreeOverlap *BKE_bmbvh_overlap(const BMBVHTree *bmtree_a,
const BMBVHTree *bmtree_b, const BMBVHTree *bmtree_b,
unsigned int *r_overlap_tot); unsigned int *r_overlap_tot);
/** /**
* Overlap indices reference the looptri's. * Overlap indices reference the looptris.
*/ */
struct BVHTreeOverlap *BKE_bmbvh_overlap_self(const BMBVHTree *bmtree, struct BVHTreeOverlap *BKE_bmbvh_overlap_self(const BMBVHTree *bmtree,
unsigned int *r_overlap_tot); unsigned int *r_overlap_tot);

@ -414,8 +414,8 @@ bool BKE_mesh_center_of_volume(const struct Mesh *mesh, float r_cent[3]);
*/ */
void BKE_mesh_calc_volume(const float (*vert_positions)[3], void BKE_mesh_calc_volume(const float (*vert_positions)[3],
int mverts_num, int mverts_num,
const struct MLoopTri *mlooptri, const struct MLoopTri *looptris,
int looptri_num, int looptris_num,
const int *corner_verts, const int *corner_verts,
float *r_volume, float *r_volume,
float r_center[3]); float r_center[3]);

@ -55,7 +55,7 @@ void looptris_calc_face_indices(OffsetIndices<int> faces, MutableSpan<int> loopt
int3 looptri_get_real_edges(Span<int2> edges, int3 looptri_get_real_edges(Span<int2> edges,
Span<int> corner_verts, Span<int> corner_verts,
Span<int> corner_edges, Span<int> corner_edges,
const MLoopTri &tri); const MLoopTri &lt);
/** Calculate the average position of the vertices in the face. */ /** Calculate the average position of the vertices in the face. */
float3 face_center_calc(Span<float3> vert_positions, Span<int> face_verts); float3 face_center_calc(Span<float3> vert_positions, Span<int> face_verts);

@ -119,8 +119,8 @@ void BKE_mesh_uv_vert_map_free(UvVertMap *vmap);
void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
int **r_mem, int **r_mem,
int totvert, int totvert,
const MLoopTri *mlooptri, const MLoopTri *looptris,
int totlooptri, int totlooptris,
const int *corner_verts, const int *corner_verts,
int totloop); int totloop);
/** /**
@ -140,14 +140,14 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
void BKE_mesh_origindex_map_create( void BKE_mesh_origindex_map_create(
MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal); MeshElemMap **r_map, int **r_mem, int totsource, const int *final_origindex, int totfinal);
/** /**
* A version of #BKE_mesh_origindex_map_create that takes a looptri array. * A version of #BKE_mesh_origindex_map_create that takes a #MLoopTri array.
* Making a face -> looptri map. * Making a face -> #MLoopTri map.
*/ */
void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map, void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map,
int **r_mem, int **r_mem,
blender::OffsetIndices<int> faces, blender::OffsetIndices<int> faces,
const int *looptri_faces, const int *looptri_faces,
int looptri_num); int looptris_num);
/* islands */ /* islands */
@ -263,7 +263,7 @@ int *BKE_mesh_calc_smoothgroups(int edges_num,
int *r_totgroup, int *r_totgroup,
bool use_bitflags); bool use_bitflags);
/* use on looptri vertex values */ /* Use on #MLoopTri vertex values. */
#define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v) \ #define BKE_MESH_TESSTRI_VINDEX_ORDER(_tri, _v) \
((CHECK_TYPE_ANY( \ ((CHECK_TYPE_ANY( \
_tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \ _tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \

@ -21,7 +21,7 @@ struct Object;
struct Scene; struct Scene;
/** Return the number of derived triangles (looptris). */ /** Return the number of derived triangles (looptris). */
int BKE_mesh_runtime_looptri_len(const Mesh *mesh); int BKE_mesh_runtime_looptris_len(const Mesh *mesh);
void BKE_mesh_runtime_ensure_edit_data(Mesh *mesh); void BKE_mesh_runtime_ensure_edit_data(Mesh *mesh);
@ -48,10 +48,10 @@ void BKE_mesh_runtime_clear_cache(Mesh *mesh);
/** /**
* Convert triangles encoded as face corner indices to triangles encoded as vertex indices. * Convert triangles encoded as face corner indices to triangles encoded as vertex indices.
*/ */
void BKE_mesh_runtime_verttri_from_looptri(MVertTri *r_verttri, void BKE_mesh_runtime_verttris_from_looptris(MVertTri *r_verttri,
const int *corner_verts, const int *corner_verts,
const MLoopTri *looptri, const MLoopTri *looptris,
int looptri_num); int looptris_num);
/* NOTE: the functions below are defined in DerivedMesh.cc, and are intended to be moved /* NOTE: the functions below are defined in DerivedMesh.cc, and are intended to be moved
* to a more suitable location when that file is removed. * to a more suitable location when that file is removed.

@ -114,29 +114,29 @@ int sample_surface_points_projected(
float3 compute_bary_coord_in_triangle(Span<float3> vert_positions, float3 compute_bary_coord_in_triangle(Span<float3> vert_positions,
Span<int> corner_verts, Span<int> corner_verts,
const MLoopTri &looptri, const MLoopTri &lt,
const float3 &position); const float3 &position);
template<typename T> template<typename T>
inline T sample_corner_attribute_with_bary_coords(const float3 &bary_weights, inline T sample_corner_attribute_with_bary_coords(const float3 &bary_weights,
const MLoopTri &looptri, const MLoopTri &lt,
const Span<T> corner_attribute) const Span<T> corner_attribute)
{ {
return attribute_math::mix3(bary_weights, return attribute_math::mix3(bary_weights,
corner_attribute[looptri.tri[0]], corner_attribute[lt.tri[0]],
corner_attribute[looptri.tri[1]], corner_attribute[lt.tri[1]],
corner_attribute[looptri.tri[2]]); corner_attribute[lt.tri[2]]);
} }
template<typename T> template<typename T>
inline T sample_corner_attribute_with_bary_coords(const float3 &bary_weights, inline T sample_corner_attribute_with_bary_coords(const float3 &bary_weights,
const MLoopTri &looptri, const MLoopTri &lt,
const VArray<T> &corner_attribute) const VArray<T> &corner_attribute)
{ {
return attribute_math::mix3(bary_weights, return attribute_math::mix3(bary_weights,
corner_attribute[looptri.tri[0]], corner_attribute[lt.tri[0]],
corner_attribute[looptri.tri[1]], corner_attribute[lt.tri[1]],
corner_attribute[looptri.tri[2]]); corner_attribute[lt.tri[2]]);
} }
/** /**

@ -48,9 +48,9 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3], void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
blender::OffsetIndices<int> faces, blender::OffsetIndices<int> faces,
const int *corner_verts, const int *corner_verts,
const MLoopTri *looptri, const MLoopTri *looptris,
const int *looptri_faces, const int *looptri_faces,
uint looptri_len, uint looptris_len,
const blender::Span<bool> sharp_faces, const blender::Span<bool> sharp_faces,
CustomData *loopdata, CustomData *loopdata,

@ -269,10 +269,10 @@ static void mesh_faces_nearest_point(void *userdata,
} while (t2); } while (t2);
} }
/* copy of function above */ /* copy of function above */
static void mesh_looptri_nearest_point(void *userdata, static void mesh_looptris_nearest_point(void *userdata,
int index, int index,
const float co[3], const float co[3],
BVHTreeNearest *nearest) BVHTreeNearest *nearest)
{ {
const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata; const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
const MLoopTri *lt = &data->looptris[index]; const MLoopTri *lt = &data->looptris[index];
@ -294,10 +294,10 @@ static void mesh_looptri_nearest_point(void *userdata,
} }
} }
/* Copy of function above (warning, should de-duplicate with `editmesh_bvh.cc`). */ /* Copy of function above (warning, should de-duplicate with `editmesh_bvh.cc`). */
static void editmesh_looptri_nearest_point(void *userdata, static void editmesh_looptris_nearest_point(void *userdata,
int index, int index,
const float co[3], const float co[3],
BVHTreeNearest *nearest) BVHTreeNearest *nearest)
{ {
BMEditMesh *em = static_cast<BMEditMesh *>(userdata); BMEditMesh *em = static_cast<BMEditMesh *>(userdata);
const BMLoop **ltri = (const BMLoop **)em->looptris[index]; const BMLoop **ltri = (const BMLoop **)em->looptris[index];
@ -366,10 +366,10 @@ static void mesh_faces_spherecast(void *userdata,
} while (t2); } while (t2);
} }
/* copy of function above */ /* copy of function above */
static void mesh_looptri_spherecast(void *userdata, static void mesh_looptris_spherecast(void *userdata,
int index, int index,
const BVHTreeRay *ray, const BVHTreeRay *ray,
BVHTreeRayHit *hit) BVHTreeRayHit *hit)
{ {
const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata; const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
const Span<float3> positions = data->vert_positions; const Span<float3> positions = data->vert_positions;
@ -397,10 +397,10 @@ static void mesh_looptri_spherecast(void *userdata,
} }
} }
/* Copy of function above (warning, should de-duplicate with `editmesh_bvh.cc`). */ /* Copy of function above (warning, should de-duplicate with `editmesh_bvh.cc`). */
static void editmesh_looptri_spherecast(void *userdata, static void editmesh_looptris_spherecast(void *userdata,
int index, int index,
const BVHTreeRay *ray, const BVHTreeRay *ray,
BVHTreeRayHit *hit) BVHTreeRayHit *hit)
{ {
BMEditMesh *em = static_cast<BMEditMesh *>(userdata); BMEditMesh *em = static_cast<BMEditMesh *>(userdata);
const BMLoop **ltri = (const BMLoop **)em->looptris[index]; const BMLoop **ltri = (const BMLoop **)em->looptris[index];
@ -609,14 +609,14 @@ static void bvhtree_from_mesh_setup_data(BVHTree *tree,
r_data->nearest_callback = mesh_faces_nearest_point; r_data->nearest_callback = mesh_faces_nearest_point;
r_data->raycast_callback = mesh_faces_spherecast; r_data->raycast_callback = mesh_faces_spherecast;
break; break;
case BVHTREE_FROM_LOOPTRI: case BVHTREE_FROM_LOOPTRIS:
case BVHTREE_FROM_LOOPTRI_NO_HIDDEN: case BVHTREE_FROM_LOOPTRIS_NO_HIDDEN:
r_data->nearest_callback = mesh_looptri_nearest_point; r_data->nearest_callback = mesh_looptris_nearest_point;
r_data->raycast_callback = mesh_looptri_spherecast; r_data->raycast_callback = mesh_looptris_spherecast;
break; break;
case BVHTREE_FROM_EM_LOOSEVERTS: case BVHTREE_FROM_EM_LOOSEVERTS:
case BVHTREE_FROM_EM_EDGES: case BVHTREE_FROM_EM_EDGES:
case BVHTREE_FROM_EM_LOOPTRI: case BVHTREE_FROM_EM_LOOPTRIS:
case BVHTREE_MAX_ITEM: case BVHTREE_MAX_ITEM:
BLI_assert(false); BLI_assert(false);
break; break;
@ -640,9 +640,9 @@ static void bvhtree_from_editmesh_setup_data(BVHTree *tree,
r_data->nearest_callback = nullptr; /* TODO */ r_data->nearest_callback = nullptr; /* TODO */
r_data->raycast_callback = nullptr; /* TODO */ r_data->raycast_callback = nullptr; /* TODO */
break; break;
case BVHTREE_FROM_EM_LOOPTRI: case BVHTREE_FROM_EM_LOOPTRIS:
r_data->nearest_callback = editmesh_looptri_nearest_point; r_data->nearest_callback = editmesh_looptris_nearest_point;
r_data->raycast_callback = editmesh_looptri_spherecast; r_data->raycast_callback = editmesh_looptris_spherecast;
break; break;
case BVHTREE_FROM_VERTS: case BVHTREE_FROM_VERTS:
@ -650,8 +650,8 @@ static void bvhtree_from_editmesh_setup_data(BVHTree *tree,
case BVHTREE_FROM_EDGES: case BVHTREE_FROM_EDGES:
case BVHTREE_FROM_LOOSEEDGES: case BVHTREE_FROM_LOOSEEDGES:
case BVHTREE_FROM_FACES: case BVHTREE_FROM_FACES:
case BVHTREE_FROM_LOOPTRI: case BVHTREE_FROM_LOOPTRIS:
case BVHTREE_FROM_LOOPTRI_NO_HIDDEN: case BVHTREE_FROM_LOOPTRIS_NO_HIDDEN:
case BVHTREE_MAX_ITEM: case BVHTREE_MAX_ITEM:
BLI_assert(false); BLI_assert(false);
break; break;
@ -943,16 +943,16 @@ static BVHTree *bvhtree_from_mesh_faces_create_tree(float epsilon,
/** \name LoopTri Face Builder /** \name LoopTri Face Builder
* \{ */ * \{ */
static BVHTree *bvhtree_from_editmesh_looptri_create_tree(float epsilon, static BVHTree *bvhtree_from_editmesh_looptris_create_tree(float epsilon,
int tree_type, int tree_type,
int axis, int axis,
BMEditMesh *em, BMEditMesh *em,
const BitSpan looptri_mask, const BitSpan looptris_mask,
int looptri_num_active) int looptris_num_active)
{ {
const int looptri_num = em->tottri; const int looptris_num = em->tottri;
BVHTree *tree = bvhtree_new_common(epsilon, tree_type, axis, looptri_num, looptri_num_active); BVHTree *tree = bvhtree_new_common(epsilon, tree_type, axis, looptris_num, looptris_num_active);
if (!tree) { if (!tree) {
return nullptr; return nullptr;
} }
@ -963,9 +963,9 @@ static BVHTree *bvhtree_from_editmesh_looptri_create_tree(float epsilon,
* and/or selected. Even if the faces themselves are not selected for the snapped * and/or selected. Even if the faces themselves are not selected for the snapped
* transform, having a vertex selected means the face (and thus it's tessellated * transform, having a vertex selected means the face (and thus it's tessellated
* triangles) will be moving and will not be a good snap targets. */ * triangles) will be moving and will not be a good snap targets. */
for (int i = 0; i < looptri_num; i++) { for (int i = 0; i < looptris_num; i++) {
const BMLoop **ltri = looptris[i]; const BMLoop **ltri = looptris[i];
bool insert = !looptri_mask.is_empty() ? looptri_mask[i] : true; bool insert = !looptris_mask.is_empty() ? looptris_mask[i] : true;
if (insert) { if (insert) {
/* No reason found to block hit-testing the triangle for snap, so insert it now. */ /* No reason found to block hit-testing the triangle for snap, so insert it now. */
@ -977,26 +977,26 @@ static BVHTree *bvhtree_from_editmesh_looptri_create_tree(float epsilon,
BLI_bvhtree_insert(tree, i, co[0], 3); BLI_bvhtree_insert(tree, i, co[0], 3);
} }
} }
BLI_assert(BLI_bvhtree_get_len(tree) == looptri_num_active); BLI_assert(BLI_bvhtree_get_len(tree) == looptris_num_active);
return tree; return tree;
} }
static BVHTree *bvhtree_from_mesh_looptri_create_tree(float epsilon, static BVHTree *bvhtree_from_mesh_looptris_create_tree(float epsilon,
int tree_type, int tree_type,
int axis, int axis,
const Span<float3> positions, const Span<float3> positions,
const Span<int> corner_verts, const Span<int> corner_verts,
const Span<MLoopTri> looptris, const Span<MLoopTri> looptris,
const BitSpan looptri_mask, const BitSpan looptris_mask,
int looptri_num_active) int looptris_num_active)
{ {
if (positions.is_empty()) { if (positions.is_empty()) {
return nullptr; return nullptr;
} }
BVHTree *tree = bvhtree_new_common( BVHTree *tree = bvhtree_new_common(
epsilon, tree_type, axis, looptris.size(), looptri_num_active); epsilon, tree_type, axis, looptris.size(), looptris_num_active);
if (!tree) { if (!tree) {
return nullptr; return nullptr;
@ -1004,7 +1004,7 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(float epsilon,
for (const int i : looptris.index_range()) { for (const int i : looptris.index_range()) {
float co[3][3]; float co[3][3];
if (!looptri_mask.is_empty() && !looptri_mask[i]) { if (!looptris_mask.is_empty() && !looptris_mask[i]) {
continue; continue;
} }
@ -1015,79 +1015,79 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(float epsilon,
BLI_bvhtree_insert(tree, i, co[0], 3); BLI_bvhtree_insert(tree, i, co[0], 3);
} }
BLI_assert(BLI_bvhtree_get_len(tree) == looptri_num_active); BLI_assert(BLI_bvhtree_get_len(tree) == looptris_num_active);
return tree; return tree;
} }
BVHTree *bvhtree_from_editmesh_looptri_ex(BVHTreeFromEditMesh *data, BVHTree *bvhtree_from_editmesh_looptris_ex(BVHTreeFromEditMesh *data,
BMEditMesh *em, BMEditMesh *em,
const BitSpan looptri_mask, const BitSpan looptris_mask,
int looptri_num_active, int looptris_num_active,
float epsilon, float epsilon,
int tree_type, int tree_type,
int axis) int axis)
{ {
/* BMESH specific check that we have tessfaces, /* BMESH specific check that we have tessfaces,
* we _could_ tessellate here but rather not - campbell */ * we _could_ tessellate here but rather not - campbell */
BVHTree *tree = bvhtree_from_editmesh_looptri_create_tree( BVHTree *tree = bvhtree_from_editmesh_looptris_create_tree(
epsilon, tree_type, axis, em, looptri_mask, looptri_num_active); epsilon, tree_type, axis, em, looptris_mask, looptris_num_active);
bvhtree_balance(tree, false); bvhtree_balance(tree, false);
if (data) { if (data) {
bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOPTRI, data); bvhtree_from_editmesh_setup_data(tree, BVHTREE_FROM_EM_LOOPTRIS, data);
} }
return tree; return tree;
} }
BVHTree *bvhtree_from_editmesh_looptri( BVHTree *bvhtree_from_editmesh_looptris(
BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis) BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis)
{ {
return bvhtree_from_editmesh_looptri_ex(data, em, {}, -1, epsilon, tree_type, axis); return bvhtree_from_editmesh_looptris_ex(data, em, {}, -1, epsilon, tree_type, axis);
} }
BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data, BVHTree *bvhtree_from_mesh_looptris_ex(BVHTreeFromMesh *data,
const Span<float3> vert_positions, const Span<float3> vert_positions,
const Span<int> corner_verts, const Span<int> corner_verts,
const Span<MLoopTri> looptris, const Span<MLoopTri> looptris,
const BitSpan looptri_mask, const BitSpan looptris_mask,
int looptri_num_active, int looptris_num_active,
float epsilon, float epsilon,
int tree_type, int tree_type,
int axis) int axis)
{ {
BVHTree *tree = bvhtree_from_mesh_looptri_create_tree(epsilon, BVHTree *tree = bvhtree_from_mesh_looptris_create_tree(epsilon,
tree_type, tree_type,
axis, axis,
vert_positions, vert_positions,
corner_verts, corner_verts,
looptris, looptris,
looptri_mask, looptris_mask,
looptri_num_active); looptris_num_active);
bvhtree_balance(tree, false); bvhtree_balance(tree, false);
if (data) { if (data) {
/* Setup BVHTreeFromMesh */ /* Setup BVHTreeFromMesh */
bvhtree_from_mesh_setup_data( bvhtree_from_mesh_setup_data(
tree, BVHTREE_FROM_LOOPTRI, vert_positions, {}, corner_verts, looptris, nullptr, data); tree, BVHTREE_FROM_LOOPTRIS, vert_positions, {}, corner_verts, looptris, nullptr, data);
} }
return tree; return tree;
} }
static BitVector<> looptri_no_hidden_map_get(const blender::OffsetIndices<int> faces, static BitVector<> looptris_no_hidden_map_get(const blender::OffsetIndices<int> faces,
const VArray<bool> &hide_poly, const VArray<bool> &hide_poly,
const int looptri_len, const int looptris_len,
int *r_looptri_active_len) int *r_looptris_active_len)
{ {
if (hide_poly.is_single() && !hide_poly.get_internal_single()) { if (hide_poly.is_single() && !hide_poly.get_internal_single()) {
return {}; return {};
} }
BitVector<> looptri_mask(looptri_len); BitVector<> looptris_mask(looptris_len);
int looptri_no_hidden_len = 0; int looptris_no_hidden_len = 0;
int looptri_index = 0; int looptri_index = 0;
for (const int64_t i : faces.index_range()) { for (const int64_t i : faces.index_range()) {
const int triangles_num = blender::bke::mesh::face_triangles_num(faces[i].size()); const int triangles_num = blender::bke::mesh::face_triangles_num(faces[i].size());
@ -1097,16 +1097,16 @@ static BitVector<> looptri_no_hidden_map_get(const blender::OffsetIndices<int> f
else { else {
for (const int i : IndexRange(triangles_num)) { for (const int i : IndexRange(triangles_num)) {
UNUSED_VARS(i); UNUSED_VARS(i);
looptri_mask[looptri_index].set(); looptris_mask[looptri_index].set();
looptri_index++; looptri_index++;
looptri_no_hidden_len++; looptris_no_hidden_len++;
} }
} }
} }
*r_looptri_active_len = looptri_no_hidden_len; *r_looptris_active_len = looptris_no_hidden_len;
return looptri_mask; return looptris_mask;
} }
BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data, BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data,
@ -1117,7 +1117,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data,
BVHCache **bvh_cache_p = (BVHCache **)&mesh->runtime->bvh_cache; BVHCache **bvh_cache_p = (BVHCache **)&mesh->runtime->bvh_cache;
Span<MLoopTri> looptris; Span<MLoopTri> looptris;
if (ELEM(bvh_cache_type, BVHTREE_FROM_LOOPTRI, BVHTREE_FROM_LOOPTRI_NO_HIDDEN)) { if (ELEM(bvh_cache_type, BVHTREE_FROM_LOOPTRIS, BVHTREE_FROM_LOOPTRIS_NO_HIDDEN)) {
looptris = mesh->looptris(); looptris = mesh->looptris();
} }
@ -1183,26 +1183,26 @@ BVHTree *BKE_bvhtree_from_mesh_get(BVHTreeFromMesh *data,
-1); -1);
break; break;
} }
case BVHTREE_FROM_LOOPTRI_NO_HIDDEN: { case BVHTREE_FROM_LOOPTRIS_NO_HIDDEN: {
blender::bke::AttributeAccessor attributes = mesh->attributes(); blender::bke::AttributeAccessor attributes = mesh->attributes();
int mask_bits_act_len = -1; int mask_bits_act_len = -1;
const BitVector<> mask = looptri_no_hidden_map_get( const BitVector<> mask = looptris_no_hidden_map_get(
mesh->faces(), mesh->faces(),
*attributes.lookup_or_default(".hide_poly", ATTR_DOMAIN_FACE, false), *attributes.lookup_or_default(".hide_poly", ATTR_DOMAIN_FACE, false),
looptris.size(), looptris.size(),
&mask_bits_act_len); &mask_bits_act_len);
data->tree = bvhtree_from_mesh_looptri_create_tree( data->tree = bvhtree_from_mesh_looptris_create_tree(
0.0f, tree_type, 6, positions, corner_verts, looptris, mask, mask_bits_act_len); 0.0f, tree_type, 6, positions, corner_verts, looptris, mask, mask_bits_act_len);
break; break;
} }
case BVHTREE_FROM_LOOPTRI: { case BVHTREE_FROM_LOOPTRIS: {
data->tree = bvhtree_from_mesh_looptri_create_tree( data->tree = bvhtree_from_mesh_looptris_create_tree(
0.0f, tree_type, 6, positions, corner_verts, looptris, {}, -1); 0.0f, tree_type, 6, positions, corner_verts, looptris, {}, -1);
break; break;
} }
case BVHTREE_FROM_EM_LOOSEVERTS: case BVHTREE_FROM_EM_LOOSEVERTS:
case BVHTREE_FROM_EM_EDGES: case BVHTREE_FROM_EM_EDGES:
case BVHTREE_FROM_EM_LOOPTRI: case BVHTREE_FROM_EM_LOOPTRIS:
case BVHTREE_MAX_ITEM: case BVHTREE_MAX_ITEM:
BLI_assert_unreachable(); BLI_assert_unreachable();
break; break;
@ -1281,14 +1281,14 @@ BVHTree *BKE_bvhtree_from_editmesh_get(BVHTreeFromEditMesh *data,
case BVHTREE_FROM_EM_EDGES: case BVHTREE_FROM_EM_EDGES:
data->tree = bvhtree_from_editmesh_edges_create_tree(0.0f, tree_type, 6, em, {}, -1); data->tree = bvhtree_from_editmesh_edges_create_tree(0.0f, tree_type, 6, em, {}, -1);
break; break;
case BVHTREE_FROM_EM_LOOPTRI: case BVHTREE_FROM_EM_LOOPTRIS:
data->tree = bvhtree_from_editmesh_looptri_create_tree(0.0f, tree_type, 6, em, {}, -1); data->tree = bvhtree_from_editmesh_looptris_create_tree(0.0f, tree_type, 6, em, {}, -1);
break; break;
case BVHTREE_FROM_VERTS: case BVHTREE_FROM_VERTS:
case BVHTREE_FROM_EDGES: case BVHTREE_FROM_EDGES:
case BVHTREE_FROM_FACES: case BVHTREE_FROM_FACES:
case BVHTREE_FROM_LOOPTRI: case BVHTREE_FROM_LOOPTRIS:
case BVHTREE_FROM_LOOPTRI_NO_HIDDEN: case BVHTREE_FROM_LOOPTRIS_NO_HIDDEN:
case BVHTREE_FROM_LOOSEVERTS: case BVHTREE_FROM_LOOSEVERTS:
case BVHTREE_FROM_LOOSEEDGES: case BVHTREE_FROM_LOOSEEDGES:
case BVHTREE_MAX_ITEM: case BVHTREE_MAX_ITEM:

@ -858,7 +858,7 @@ static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mes
printf("cloth_free_modifier clmd->clothObject->looptri\n"); printf("cloth_free_modifier clmd->clothObject->looptri\n");
return; return;
} }
BKE_mesh_runtime_verttri_from_looptri( BKE_mesh_runtime_verttris_from_looptris(
clmd->clothObject->tri, corner_verts.data(), looptris.data(), looptris.size()); clmd->clothObject->tri, corner_verts.data(), looptris.data(), looptris.size());
clmd->clothObject->edges = mesh->edges().data(); clmd->clothObject->edges = mesh->edges().data();
@ -1517,7 +1517,7 @@ static bool cloth_build_springs(ClothModifierData *clmd, Mesh *mesh)
} }
Set<OrderedEdge> existing_vert_pairs; Set<OrderedEdge> existing_vert_pairs;
BKE_bvhtree_from_mesh_get(&treedata, tmp_mesh ? tmp_mesh : mesh, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&treedata, tmp_mesh ? tmp_mesh : mesh, BVHTREE_FROM_LOOPTRIS, 2);
rng = BLI_rng_new_srandom(0); rng = BLI_rng_new_srandom(0);
const blender::Span<blender::float3> vert_normals = tmp_mesh ? tmp_mesh->vert_normals() : const blender::Span<blender::float3> vert_normals = tmp_mesh ? tmp_mesh->vert_normals() :

@ -5077,7 +5077,7 @@ static void followtrack_project_to_depth_object_if_needed(FollowTrackContext *co
normalize_v3(ray_direction); normalize_v3(ray_direction);
BVHTreeFromMesh tree_data = NULL_BVHTreeFromMesh; BVHTreeFromMesh tree_data = NULL_BVHTreeFromMesh;
BKE_bvhtree_from_mesh_get(&tree_data, depth_mesh, BVHTREE_FROM_LOOPTRI, 4); BKE_bvhtree_from_mesh_get(&tree_data, depth_mesh, BVHTREE_FROM_LOOPTRIS, 4);
BVHTreeRayHit hit; BVHTreeRayHit hit;
hit.dist = BVH_RAYCAST_DIST_MAX; hit.dist = BVH_RAYCAST_DIST_MAX;

@ -2403,10 +2403,10 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(void *__restrict userdat
#undef JITTER_SAMPLES #undef JITTER_SAMPLES
static float dist_squared_to_looptri_uv_edges(const blender::Span<MLoopTri> looptris, static float dist_squared_to_looptris_uv_edges(const blender::Span<MLoopTri> looptris,
const float (*mloopuv)[2], const float (*mloopuv)[2],
int tri_index, int tri_index,
const float point[2]) const float point[2])
{ {
BLI_assert(tri_index >= 0); BLI_assert(tri_index >= 0);
@ -2568,7 +2568,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
const int vert1 = corner_verts[loop_idx[(edge_idx + 1) % 3]]; const int vert1 = corner_verts[loop_idx[(edge_idx + 1) % 3]];
/* Use a pre-computed vert-to-looptri mapping, /* Use a pre-computed vert-to-looptri mapping,
* speeds up things a lot compared to looping over all looptri. */ * speeds up things a lot compared to looping over all looptris. */
const MeshElemMap *map = &bdata->vert_to_looptri_map[vert0]; const MeshElemMap *map = &bdata->vert_to_looptri_map[vert0];
bool found_other = false; bool found_other = false;
@ -2687,7 +2687,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
const float final_pt[2] = {((final_index % w) + 0.5f) / w, ((final_index / w) + 0.5f) / h}; const float final_pt[2] = {((final_index % w) + 0.5f) / w, ((final_index / w) + 0.5f) / h};
const float threshold = square_f(0.7f) / (w * h); const float threshold = square_f(0.7f) / (w * h);
if (dist_squared_to_looptri_uv_edges(looptris, mloopuv, final_tri_index, final_pt) > if (dist_squared_to_looptris_uv_edges(looptris, mloopuv, final_tri_index, final_pt) >
threshold) { threshold) {
continue; continue;
} }
@ -4342,7 +4342,7 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph,
/* check bounding box collision */ /* check bounding box collision */
if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius)) { if (grid && meshBrush_boundsIntersect(&grid->grid_bounds, &mesh_bb, brush, brush_radius)) {
/* Build a bvh tree from transformed vertices */ /* Build a bvh tree from transformed vertices */
if (BKE_bvhtree_from_mesh_get(&treeData, mesh, BVHTREE_FROM_LOOPTRI, 4)) { if (BKE_bvhtree_from_mesh_get(&treeData, mesh, BVHTREE_FROM_LOOPTRIS, 4)) {
int c_index; int c_index;
int total_cells = grid->dim[0] * grid->dim[1] * grid->dim[2]; int total_cells = grid->dim[0] * grid->dim[1] * grid->dim[2];

@ -111,31 +111,31 @@ static void editmesh_tessface_calc_intern(BMEditMesh *em,
BM_mesh_calc_tessellation_ex(em->bm, em->looptris, params); BM_mesh_calc_tessellation_ex(em->bm, em->looptris, params);
} }
void BKE_editmesh_looptri_calc_ex(BMEditMesh *em, const BMeshCalcTessellation_Params *params) void BKE_editmesh_looptris_calc_ex(BMEditMesh *em, const BMeshCalcTessellation_Params *params)
{ {
editmesh_tessface_calc_intern(em, params); editmesh_tessface_calc_intern(em, params);
} }
void BKE_editmesh_looptri_calc(BMEditMesh *em) void BKE_editmesh_looptris_calc(BMEditMesh *em)
{ {
BMeshCalcTessellation_Params params{}; BMeshCalcTessellation_Params params{};
params.face_normals = false; params.face_normals = false;
BKE_editmesh_looptri_calc_ex(em, &params); BKE_editmesh_looptris_calc_ex(em, &params);
} }
void BKE_editmesh_looptri_and_normals_calc(BMEditMesh *em) void BKE_editmesh_looptris_and_normals_calc(BMEditMesh *em)
{ {
BMeshCalcTessellation_Params looptri_params{}; BMeshCalcTessellation_Params looptris_params{};
looptri_params.face_normals = true; looptris_params.face_normals = true;
BKE_editmesh_looptri_calc_ex(em, &looptri_params); BKE_editmesh_looptris_calc_ex(em, &looptris_params);
BMeshNormalsUpdate_Params normals_params{}; BMeshNormalsUpdate_Params normals_params{};
normals_params.face_normals = false; normals_params.face_normals = false;
BM_mesh_normals_update_ex(em->bm, &normals_params); BM_mesh_normals_update_ex(em->bm, &normals_params);
} }
void BKE_editmesh_looptri_calc_with_partial_ex(BMEditMesh *em, void BKE_editmesh_looptris_calc_with_partial_ex(BMEditMesh *em,
BMPartialUpdate *bmpinfo, BMPartialUpdate *bmpinfo,
const BMeshCalcTessellation_Params *params) const BMeshCalcTessellation_Params *params)
{ {
BLI_assert(em->tottri == poly_to_tri_count(em->bm->totface, em->bm->totloop)); BLI_assert(em->tottri == poly_to_tri_count(em->bm->totface, em->bm->totloop));
BLI_assert(em->looptris != nullptr); BLI_assert(em->looptris != nullptr);
@ -143,18 +143,18 @@ void BKE_editmesh_looptri_calc_with_partial_ex(BMEditMesh *em,
BM_mesh_calc_tessellation_with_partial_ex(em->bm, em->looptris, bmpinfo, params); BM_mesh_calc_tessellation_with_partial_ex(em->bm, em->looptris, bmpinfo, params);
} }
void BKE_editmesh_looptri_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo) void BKE_editmesh_looptris_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo)
{ {
BMeshCalcTessellation_Params looptri_params{}; BMeshCalcTessellation_Params looptris_params{};
looptri_params.face_normals = false; looptris_params.face_normals = false;
BKE_editmesh_looptri_calc_with_partial_ex(em, bmpinfo, &looptri_params); BKE_editmesh_looptris_calc_with_partial_ex(em, bmpinfo, &looptris_params);
} }
void BKE_editmesh_looptri_and_normals_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo) void BKE_editmesh_looptris_and_normals_calc_with_partial(BMEditMesh *em, BMPartialUpdate *bmpinfo)
{ {
BMeshCalcTessellation_Params looptri_params{}; BMeshCalcTessellation_Params looptris_params{};
looptri_params.face_normals = true; looptris_params.face_normals = true;
BKE_editmesh_looptri_calc_with_partial_ex(em, bmpinfo, &looptri_params); BKE_editmesh_looptris_calc_with_partial_ex(em, bmpinfo, &looptris_params);
BMeshNormalsUpdate_Params normals_params{}; BMeshNormalsUpdate_Params normals_params{};
normals_params.face_normals = false; normals_params.face_normals = false;
BM_mesh_normals_update_with_partial_ex(em->bm, bmpinfo, &normals_params); BM_mesh_normals_update_with_partial_ex(em->bm, bmpinfo, &normals_params);

@ -58,7 +58,7 @@ BMBVHTree *BKE_bmbvh_new_ex(BMesh *bm,
BMFace *f_test, *f_test_prev; BMFace *f_test, *f_test_prev;
bool test_fn_ret; bool test_fn_ret;
/* BKE_editmesh_looptri_calc() must be called already */ /* BKE_editmesh_looptris_calc() must be called already */
BLI_assert(looptris_tot != 0 || bm->totface == 0); BLI_assert(looptris_tot != 0 || bm->totface == 0);
if (cos_cage) { if (cos_cage) {

@ -29,7 +29,7 @@
/** \name Tangent Space Calculation /** \name Tangent Space Calculation
* \{ */ * \{ */
/* Necessary complexity to handle looptri's as quads for correct tangents */ /* Necessary complexity to handle looptris as quads for correct tangents. */
#define USE_LOOPTRI_DETECT_QUADS #define USE_LOOPTRI_DETECT_QUADS
struct SGLSLEditMeshToTangent { struct SGLSLEditMeshToTangent {
@ -137,7 +137,7 @@ struct SGLSLEditMeshToTangent {
int numTessFaces; int numTessFaces;
#ifdef USE_LOOPTRI_DETECT_QUADS #ifdef USE_LOOPTRI_DETECT_QUADS
/* map from 'fake' face index to looptri, /* map from 'fake' face index to looptris,
* quads will point to the first looptri of the quad */ * quads will point to the first looptri of the quad */
const int *face_as_quad_map; const int *face_as_quad_map;
int num_face_as_quad_map; int num_face_as_quad_map;

@ -852,7 +852,7 @@ BLI_INLINE void apply_effector_fields(FluidEffectorSettings * /*fes*/,
static void update_velocities(FluidEffectorSettings *fes, static void update_velocities(FluidEffectorSettings *fes,
const blender::Span<blender::float3> vert_positions, const blender::Span<blender::float3> vert_positions,
const int *corner_verts, const int *corner_verts,
const MLoopTri *mlooptri, const MLoopTri *looptris,
float *velocity_map, float *velocity_map,
int index, int index,
BVHTreeFromMesh *tree_data, BVHTreeFromMesh *tree_data,
@ -876,12 +876,12 @@ static void update_velocities(FluidEffectorSettings *fes,
tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1)
{ {
float weights[3]; float weights[3];
int v1, v2, v3, f_index = nearest.index; int v1, v2, v3, lt_index = nearest.index;
/* Calculate barycentric weights for nearest point. */ /* Calculate barycentric weights for nearest point. */
v1 = corner_verts[mlooptri[f_index].tri[0]]; v1 = corner_verts[looptris[lt_index].tri[0]];
v2 = corner_verts[mlooptri[f_index].tri[1]]; v2 = corner_verts[looptris[lt_index].tri[1]];
v3 = corner_verts[mlooptri[f_index].tri[2]]; v3 = corner_verts[looptris[lt_index].tri[2]];
interp_weights_tri_v3( interp_weights_tri_v3(
weights, vert_positions[v1], vert_positions[v2], vert_positions[v3], nearest.co); weights, vert_positions[v1], vert_positions[v2], vert_positions[v3], nearest.co);
@ -1080,7 +1080,7 @@ static void obstacles_from_mesh(Object *coll_ob,
/* Skip effector sampling loop if object has disabled effector. */ /* Skip effector sampling loop if object has disabled effector. */
bool use_effector = fes->flags & FLUID_EFFECTOR_USE_EFFEC; bool use_effector = fes->flags & FLUID_EFFECTOR_USE_EFFEC;
if (use_effector && BKE_bvhtree_from_mesh_get(&tree_data, mesh, BVHTREE_FROM_LOOPTRI, 4)) { if (use_effector && BKE_bvhtree_from_mesh_get(&tree_data, mesh, BVHTREE_FROM_LOOPTRIS, 4)) {
ObstaclesFromDMData data{}; ObstaclesFromDMData data{};
data.fes = fes; data.fes = fes;
@ -1801,7 +1801,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
blender::Span<blender::float3> vert_positions, blender::Span<blender::float3> vert_positions,
const blender::Span<blender::float3> vert_normals, const blender::Span<blender::float3> vert_normals,
const int *corner_verts, const int *corner_verts,
const MLoopTri *mlooptri, const MLoopTri *looptris,
const float (*mloopuv)[2], const float (*mloopuv)[2],
float *influence_map, float *influence_map,
float *velocity_map, float *velocity_map,
@ -1882,13 +1882,13 @@ static void sample_mesh(FluidFlowSettings *ffs,
tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1) tree_data->tree, ray_start, &nearest, tree_data->nearest_callback, tree_data) != -1)
{ {
float weights[3]; float weights[3];
int v1, v2, v3, f_index = nearest.index; int v1, v2, v3, lt_index = nearest.index;
float hit_normal[3]; float hit_normal[3];
/* Calculate barycentric weights for nearest point. */ /* Calculate barycentric weights for nearest point. */
v1 = corner_verts[mlooptri[f_index].tri[0]]; v1 = corner_verts[looptris[lt_index].tri[0]];
v2 = corner_verts[mlooptri[f_index].tri[1]]; v2 = corner_verts[looptris[lt_index].tri[1]];
v3 = corner_verts[mlooptri[f_index].tri[2]]; v3 = corner_verts[looptris[lt_index].tri[2]];
interp_weights_tri_v3( interp_weights_tri_v3(
weights, vert_positions[v1], vert_positions[v2], vert_positions[v3], nearest.co); weights, vert_positions[v1], vert_positions[v2], vert_positions[v3], nearest.co);
@ -1925,9 +1925,9 @@ static void sample_mesh(FluidFlowSettings *ffs,
} }
else if (mloopuv) { else if (mloopuv) {
const float *uv[3]; const float *uv[3];
uv[0] = mloopuv[mlooptri[f_index].tri[0]]; uv[0] = mloopuv[looptris[lt_index].tri[0]];
uv[1] = mloopuv[mlooptri[f_index].tri[1]]; uv[1] = mloopuv[looptris[lt_index].tri[1]];
uv[2] = mloopuv[mlooptri[f_index].tri[2]]; uv[2] = mloopuv[looptris[lt_index].tri[2]];
interp_v2_v2v2v2(tex_co, UNPACK3(uv), weights); interp_v2_v2v2v2(tex_co, UNPACK3(uv), weights);
@ -2146,7 +2146,7 @@ static void emit_from_mesh(
/* Skip flow sampling loop if object has disabled flow. */ /* Skip flow sampling loop if object has disabled flow. */
bool use_flow = ffs->flags & FLUID_FLOW_USE_INFLOW; bool use_flow = ffs->flags & FLUID_FLOW_USE_INFLOW;
if (use_flow && BKE_bvhtree_from_mesh_get(&tree_data, mesh, BVHTREE_FROM_LOOPTRI, 4)) { if (use_flow && BKE_bvhtree_from_mesh_get(&tree_data, mesh, BVHTREE_FROM_LOOPTRIS, 4)) {
EmitFromDMData data{}; EmitFromDMData data{};
data.fds = fds; data.fds = fds;

@ -359,22 +359,22 @@ bool BKE_mesh_center_of_volume(const Mesh *mesh, float r_cent[3])
static bool mesh_calc_center_centroid_ex(const float (*positions)[3], static bool mesh_calc_center_centroid_ex(const float (*positions)[3],
int /*mverts_num*/, int /*mverts_num*/,
const MLoopTri *looptri, const MLoopTri *looptris,
int looptri_num, int looptris_num,
const int *corner_verts, const int *corner_verts,
float r_center[3]) float r_center[3])
{ {
zero_v3(r_center); zero_v3(r_center);
if (looptri_num == 0) { if (looptris_num == 0) {
return false; return false;
} }
float totweight = 0.0f; float totweight = 0.0f;
const MLoopTri *lt; const MLoopTri *lt;
int i; int i;
for (i = 0, lt = looptri; i < looptri_num; i++, lt++) { for (i = 0, lt = looptris; i < looptris_num; i++, lt++) {
const float *v1 = positions[corner_verts[lt->tri[0]]]; const float *v1 = positions[corner_verts[lt->tri[0]]];
const float *v2 = positions[corner_verts[lt->tri[1]]]; const float *v2 = positions[corner_verts[lt->tri[1]]];
const float *v3 = positions[corner_verts[lt->tri[2]]]; const float *v3 = positions[corner_verts[lt->tri[2]]];
@ -397,8 +397,8 @@ static bool mesh_calc_center_centroid_ex(const float (*positions)[3],
void BKE_mesh_calc_volume(const float (*vert_positions)[3], void BKE_mesh_calc_volume(const float (*vert_positions)[3],
const int mverts_num, const int mverts_num,
const MLoopTri *looptri, const MLoopTri *looptris,
const int looptri_num, const int looptris_num,
const int *corner_verts, const int *corner_verts,
float *r_volume, float *r_volume,
float r_center[3]) float r_center[3])
@ -415,19 +415,19 @@ void BKE_mesh_calc_volume(const float (*vert_positions)[3],
zero_v3(r_center); zero_v3(r_center);
} }
if (looptri_num == 0) { if (looptris_num == 0) {
return; return;
} }
if (!mesh_calc_center_centroid_ex( if (!mesh_calc_center_centroid_ex(
vert_positions, mverts_num, looptri, looptri_num, corner_verts, center)) vert_positions, mverts_num, looptris, looptris_num, corner_verts, center))
{ {
return; return;
} }
totvol = 0.0f; totvol = 0.0f;
for (i = 0, lt = looptri; i < looptri_num; i++, lt++) { for (i = 0, lt = looptris; i < looptris_num; i++, lt++) {
const float *v1 = vert_positions[corner_verts[lt->tri[0]]]; const float *v1 = vert_positions[corner_verts[lt->tri[0]]];
const float *v2 = vert_positions[corner_verts[lt->tri[1]]]; const float *v2 = vert_positions[corner_verts[lt->tri[1]]];
const float *v3 = vert_positions[corner_verts[lt->tri[2]]]; const float *v3 = vert_positions[corner_verts[lt->tri[2]]];

@ -1008,7 +1008,7 @@ static int mesh_tessface_calc(Mesh &mesh,
/* We abuse #MFace.edcode to tag quad faces. See below for details. */ /* We abuse #MFace.edcode to tag quad faces. See below for details. */
#define TESSFACE_IS_QUAD 1 #define TESSFACE_IS_QUAD 1
const int looptri_num = poly_to_tri_count(faces_num, totloop); const int looptris_num = poly_to_tri_count(faces_num, totloop);
MFace *mface, *mf; MFace *mface, *mf;
MemArena *arena = nullptr; MemArena *arena = nullptr;
@ -1028,9 +1028,9 @@ static int mesh_tessface_calc(Mesh &mesh,
* if all faces are triangles it will be correct, `quads == 2x` allocations. */ * if all faces are triangles it will be correct, `quads == 2x` allocations. */
/* Take care since memory is _not_ zeroed so be sure to initialize each field. */ /* Take care since memory is _not_ zeroed so be sure to initialize each field. */
mface_to_poly_map = (int *)MEM_malloc_arrayN( mface_to_poly_map = (int *)MEM_malloc_arrayN(
size_t(looptri_num), sizeof(*mface_to_poly_map), __func__); size_t(looptris_num), sizeof(*mface_to_poly_map), __func__);
mface = (MFace *)MEM_malloc_arrayN(size_t(looptri_num), sizeof(*mface), __func__); mface = (MFace *)MEM_malloc_arrayN(size_t(looptris_num), sizeof(*mface), __func__);
lindices = (uint(*)[4])MEM_malloc_arrayN(size_t(looptri_num), sizeof(*lindices), __func__); lindices = (uint(*)[4])MEM_malloc_arrayN(size_t(looptris_num), sizeof(*lindices), __func__);
mface_index = 0; mface_index = 0;
for (poly_index = 0; poly_index < faces_num; poly_index++) { for (poly_index = 0; poly_index < faces_num; poly_index++) {
@ -1187,10 +1187,10 @@ static int mesh_tessface_calc(Mesh &mesh,
CustomData_free(fdata_legacy, totface); CustomData_free(fdata_legacy, totface);
totface = mface_index; totface = mface_index;
BLI_assert(totface <= looptri_num); BLI_assert(totface <= looptris_num);
/* Not essential but without this we store over-allocated memory in the #CustomData layers. */ /* Not essential but without this we store over-allocated memory in the #CustomData layers. */
if (LIKELY(looptri_num != totface)) { if (LIKELY(looptris_num != totface)) {
mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * size_t(totface)); mface = (MFace *)MEM_reallocN(mface, sizeof(*mface) * size_t(totface));
mface_to_poly_map = (int *)MEM_reallocN(mface_to_poly_map, mface_to_poly_map = (int *)MEM_reallocN(mface_to_poly_map,
sizeof(*mface_to_poly_map) * size_t(totface)); sizeof(*mface_to_poly_map) * size_t(totface));

@ -191,21 +191,21 @@ void BKE_mesh_uv_vert_map_free(UvVertMap *vmap)
void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map, void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
int **r_mem, int **r_mem,
const int totvert, const int totvert,
const MLoopTri *mlooptri, const MLoopTri *looptris,
const int totlooptri, const int totlooptris,
const int *corner_verts, const int *corner_verts,
const int /*totloop*/) const int /*totloop*/)
{ {
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totvert), __func__); MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(totvert), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totlooptri) * 3, __func__)); int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(totlooptris) * 3, __func__));
int *index_step; int *index_step;
const MLoopTri *mlt; const MLoopTri *lt;
int i; int i;
/* count face users */ /* count face users */
for (i = 0, mlt = mlooptri; i < totlooptri; mlt++, i++) { for (i = 0, lt = looptris; i < totlooptris; lt++, i++) {
for (int j = 3; j--;) { for (int j = 3; j--;) {
map[corner_verts[mlt->tri[j]]].count++; map[corner_verts[lt->tri[j]]].count++;
} }
} }
@ -220,9 +220,9 @@ void BKE_mesh_vert_looptri_map_create(MeshElemMap **r_map,
} }
/* assign looptri-edge users */ /* assign looptri-edge users */
for (i = 0, mlt = mlooptri; i < totlooptri; mlt++, i++) { for (i = 0, lt = looptris; i < totlooptris; lt++, i++) {
for (int j = 3; j--;) { for (int j = 3; j--;) {
MeshElemMap *map_ele = &map[corner_verts[mlt->tri[j]]]; MeshElemMap *map_ele = &map[corner_verts[lt->tri[j]]];
map_ele->indices[map_ele->count++] = i; map_ele->indices[map_ele->count++] = i;
} }
} }
@ -276,10 +276,10 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map,
int **r_mem, int **r_mem,
const blender::OffsetIndices<int> faces, const blender::OffsetIndices<int> faces,
const int *looptri_faces, const int *looptri_faces,
const int looptri_num) const int looptris_num)
{ {
MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(faces.size()), __func__); MeshElemMap *map = MEM_cnew_array<MeshElemMap>(size_t(faces.size()), __func__);
int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(looptri_num), __func__)); int *indices = static_cast<int *>(MEM_mallocN(sizeof(int) * size_t(looptris_num), __func__));
int *index_step; int *index_step;
/* create offsets */ /* create offsets */
@ -290,7 +290,7 @@ void BKE_mesh_origindex_map_create_looptri(MeshElemMap **r_map,
} }
/* Assign face-tessellation users. */ /* Assign face-tessellation users. */
for (int i = 0; i < looptri_num; i++) { for (int i = 0; i < looptris_num; i++) {
MeshElemMap *map_ele = &map[looptri_faces[i]]; MeshElemMap *map_ele = &map[looptri_faces[i]];
map_ele->indices[map_ele->count++] = i; map_ele->indices[map_ele->count++] = i;
} }

@ -568,7 +568,7 @@ void BKE_mesh_remap_calc_verts_from_mesh(const int mode,
float *weights = static_cast<float *>( float *weights = static_cast<float *>(
MEM_mallocN(sizeof(*weights) * tmp_buff_size, __func__)); MEM_mallocN(sizeof(*weights) * tmp_buff_size, __func__));
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRIS, 2);
if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) { if (mode == MREMAP_MODE_VERT_POLYINTERP_VNORPROJ) {
for (i = 0; i < numverts_dst; i++) { for (i = 0; i < numverts_dst; i++) {
@ -860,7 +860,7 @@ void BKE_mesh_remap_calc_edges_from_mesh(const int mode,
const blender::Span<blender::float3> positions_src = me_src->vert_positions(); const blender::Span<blender::float3> positions_src = me_src->vert_positions();
const blender::Span<int> looptri_faces = me_src->looptri_faces(); const blender::Span<int> looptri_faces = me_src->looptri_faces();
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRIS, 2);
for (i = 0; i < numedges_dst; i++) { for (i = 0; i < numedges_dst; i++) {
interp_v3_v3v3(tmp_co, interp_v3_v3v3(tmp_co,
@ -1444,32 +1444,32 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
if (use_islands) { if (use_islands) {
looptris_src = me_src->looptris(); looptris_src = me_src->looptris();
looptri_faces_src = me_src->looptri_faces(); looptri_faces_src = me_src->looptri_faces();
blender::BitVector<> looptri_active(looptris_src.size()); blender::BitVector<> looptris_active(looptris_src.size());
for (tindex = 0; tindex < num_trees; tindex++) { for (tindex = 0; tindex < num_trees; tindex++) {
int num_looptri_active = 0; int looptris_num_active = 0;
looptri_active.fill(false); looptris_active.fill(false);
for (const int64_t i : looptris_src.index_range()) { for (const int64_t i : looptris_src.index_range()) {
const blender::IndexRange face = faces_src[looptri_faces_src[i]]; const blender::IndexRange face = faces_src[looptri_faces_src[i]];
if (island_store.items_to_islands[face.start()] == tindex) { if (island_store.items_to_islands[face.start()] == tindex) {
looptri_active[i].set(); looptris_active[i].set();
num_looptri_active++; looptris_num_active++;
} }
} }
bvhtree_from_mesh_looptri_ex(&treedata[tindex], bvhtree_from_mesh_looptris_ex(&treedata[tindex],
positions_src, positions_src,
corner_verts_src, corner_verts_src,
looptris_src, looptris_src,
looptri_active, looptris_active,
num_looptri_active, looptris_num_active,
0.0, 0.0,
2, 2,
6); 6);
} }
} }
else { else {
BLI_assert(num_trees == 1); BLI_assert(num_trees == 1);
BKE_bvhtree_from_mesh_get(&treedata[0], me_src, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&treedata[0], me_src, BVHTREE_FROM_LOOPTRIS, 2);
} }
} }
@ -2069,7 +2069,7 @@ void BKE_mesh_remap_calc_faces_from_mesh(const int mode,
float hit_dist; float hit_dist;
const blender::Span<int> looptri_faces = me_src->looptri_faces(); const blender::Span<int> looptri_faces = me_src->looptri_faces();
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_LOOPTRIS, 2);
if (mode == MREMAP_MODE_POLY_NEAREST) { if (mode == MREMAP_MODE_POLY_NEAREST) {
nearest.index = -1; nearest.index = -1;

@ -73,7 +73,7 @@ static Mesh *remesh_quadriflow(const Mesh *input_mesh,
/* Gather the required data for export to the internal quadriflow mesh format. */ /* Gather the required data for export to the internal quadriflow mesh format. */
Array<MVertTri> verttri(looptris.size()); Array<MVertTri> verttri(looptris.size());
BKE_mesh_runtime_verttri_from_looptri( BKE_mesh_runtime_verttris_from_looptris(
verttri.data(), input_corner_verts.data(), looptris.data(), looptris.size()); verttri.data(), input_corner_verts.data(), looptris.data(), looptris.size());
const int totfaces = looptris.size(); const int totfaces = looptris.size();
@ -199,10 +199,9 @@ static openvdb::FloatGrid::Ptr remesh_voxel_level_set_create(const Mesh *mesh,
} }
for (const int i : IndexRange(looptris.size())) { for (const int i : IndexRange(looptris.size())) {
const MLoopTri &loop_tri = looptris[i]; const MLoopTri &lt = looptris[i];
triangles[i] = openvdb::Vec3I(corner_verts[loop_tri.tri[0]], triangles[i] = openvdb::Vec3I(
corner_verts[loop_tri.tri[1]], corner_verts[lt.tri[0]], corner_verts[lt.tri[1]], corner_verts[lt.tri[2]]);
corner_verts[loop_tri.tri[2]]);
} }
openvdb::math::Transform::Ptr transform = openvdb::math::Transform::createLinearTransform( openvdb::math::Transform::Ptr transform = openvdb::math::Transform::createLinearTransform(
@ -324,7 +323,7 @@ static void find_nearest_tris_parallel(const Span<float3> positions,
static void find_nearest_verts(const Span<float3> positions, static void find_nearest_verts(const Span<float3> positions,
const Span<int> corner_verts, const Span<int> corner_verts,
const Span<MLoopTri> src_tris, const Span<MLoopTri> src_looptris,
const Span<float3> dst_positions, const Span<float3> dst_positions,
const Span<int> nearest_vert_tris, const Span<int> nearest_vert_tris,
MutableSpan<int> nearest_verts) MutableSpan<int> nearest_verts)
@ -332,16 +331,16 @@ static void find_nearest_verts(const Span<float3> positions,
threading::parallel_for(dst_positions.index_range(), 512, [&](const IndexRange range) { threading::parallel_for(dst_positions.index_range(), 512, [&](const IndexRange range) {
for (const int dst_vert : range) { for (const int dst_vert : range) {
const float3 &dst_position = dst_positions[dst_vert]; const float3 &dst_position = dst_positions[dst_vert];
const MLoopTri &src_tri = src_tris[nearest_vert_tris[dst_vert]]; const MLoopTri &src_lt = src_looptris[nearest_vert_tris[dst_vert]];
std::array<float, 3> distances; std::array<float, 3> distances;
for (const int i : IndexRange(3)) { for (const int i : IndexRange(3)) {
const int src_vert = corner_verts[src_tri.tri[i]]; const int src_vert = corner_verts[src_lt.tri[i]];
distances[i] = math::distance_squared(positions[src_vert], dst_position); distances[i] = math::distance_squared(positions[src_vert], dst_position);
} }
const int min = std::min_element(distances.begin(), distances.end()) - distances.begin(); const int min = std::min_element(distances.begin(), distances.end()) - distances.begin();
nearest_verts[dst_vert] = corner_verts[src_tri.tri[min]]; nearest_verts[dst_vert] = corner_verts[src_lt.tri[min]];
} }
}); });
} }
@ -516,7 +515,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
const Span<float3> src_positions = src.vert_positions(); const Span<float3> src_positions = src.vert_positions();
const OffsetIndices src_faces = src.faces(); const OffsetIndices src_faces = src.faces();
const Span<int> src_corner_verts = src.corner_verts(); const Span<int> src_corner_verts = src.corner_verts();
const Span<MLoopTri> src_tris = src.looptris(); const Span<MLoopTri> src_looptris = src.looptris();
/* The main idea in the following code is to trade some complexity in sampling for the benefit of /* The main idea in the following code is to trade some complexity in sampling for the benefit of
* only using and building a single BVH tree. Since sculpt mode doesn't generally deal with loose * only using and building a single BVH tree. Since sculpt mode doesn't generally deal with loose
@ -530,7 +529,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
* possibly improved performance from lower cache usage in the "complex" sampling part of the * possibly improved performance from lower cache usage in the "complex" sampling part of the
* algorithm and the copying itself. */ * algorithm and the copying itself. */
BVHTreeFromMesh bvhtree{}; BVHTreeFromMesh bvhtree{};
BKE_bvhtree_from_mesh_get(&bvhtree, &src, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&bvhtree, &src, BVHTREE_FROM_LOOPTRIS, 2);
const Span<float3> dst_positions = dst.vert_positions(); const Span<float3> dst_positions = dst.vert_positions();
const OffsetIndices dst_faces = dst.faces(); const OffsetIndices dst_faces = dst.faces();
@ -545,7 +544,7 @@ void mesh_remesh_reproject_attributes(const Mesh &src, Mesh &dst)
if (!point_ids.is_empty()) { if (!point_ids.is_empty()) {
Array<int> map(dst.totvert); Array<int> map(dst.totvert);
find_nearest_verts( find_nearest_verts(
src_positions, src_corner_verts, src_tris, dst_positions, vert_nearest_tris, map); src_positions, src_corner_verts, src_looptris, dst_positions, vert_nearest_tris, map);
gather_attributes(point_ids, src_attributes, ATTR_DOMAIN_POINT, map, dst_attributes); gather_attributes(point_ids, src_attributes, ATTR_DOMAIN_POINT, map, dst_attributes);
} }

@ -262,21 +262,21 @@ blender::Span<int> Mesh::looptri_faces() const
return this->runtime->looptri_faces_cache.data(); return this->runtime->looptri_faces_cache.data();
} }
int BKE_mesh_runtime_looptri_len(const Mesh *mesh) int BKE_mesh_runtime_looptris_len(const Mesh *mesh)
{ {
/* Allow returning the size without calculating the cache. */ /* Allow returning the size without calculating the cache. */
return poly_to_tri_count(mesh->faces_num, mesh->totloop); return poly_to_tri_count(mesh->faces_num, mesh->totloop);
} }
void BKE_mesh_runtime_verttri_from_looptri(MVertTri *r_verttri, void BKE_mesh_runtime_verttris_from_looptris(MVertTri *r_verttri,
const int *corner_verts, const int *corner_verts,
const MLoopTri *looptri, const MLoopTri *looptris,
int looptri_num) int looptris_num)
{ {
for (int i = 0; i < looptri_num; i++) { for (int i = 0; i < looptris_num; i++) {
r_verttri[i].tri[0] = corner_verts[looptri[i].tri[0]]; r_verttri[i].tri[0] = corner_verts[looptris[i].tri[0]];
r_verttri[i].tri[1] = corner_verts[looptri[i].tri[1]]; r_verttri[i].tri[1] = corner_verts[looptris[i].tri[1]];
r_verttri[i].tri[2] = corner_verts[looptri[i].tri[2]]; r_verttri[i].tri[2] = corner_verts[looptris[i].tri[2]];
} }
} }

@ -27,11 +27,11 @@ BLI_NOINLINE static void sample_point_attribute(const Span<int> corner_verts,
const MutableSpan<T> dst) const MutableSpan<T> dst)
{ {
mask.foreach_index([&](const int i) { mask.foreach_index([&](const int i) {
const MLoopTri &tri = looptris[looptri_indices[i]]; const MLoopTri &lt = looptris[looptri_indices[i]];
dst[i] = attribute_math::mix3(bary_coords[i], dst[i] = attribute_math::mix3(bary_coords[i],
src[corner_verts[tri.tri[0]]], src[corner_verts[lt.tri[0]]],
src[corner_verts[tri.tri[1]]], src[corner_verts[lt.tri[1]]],
src[corner_verts[tri.tri[2]]]); src[corner_verts[lt.tri[2]]]);
}); });
} }
@ -44,11 +44,11 @@ void sample_point_normals(const Span<int> corner_verts,
const MutableSpan<float3> dst) const MutableSpan<float3> dst)
{ {
mask.foreach_index([&](const int i) { mask.foreach_index([&](const int i) {
const MLoopTri &tri = looptris[looptri_indices[i]]; const MLoopTri &lt = looptris[looptri_indices[i]];
const float3 value = attribute_math::mix3(bary_coords[i], const float3 value = attribute_math::mix3(bary_coords[i],
src[corner_verts[tri.tri[0]]], src[corner_verts[lt.tri[0]]],
src[corner_verts[tri.tri[1]]], src[corner_verts[lt.tri[1]]],
src[corner_verts[tri.tri[2]]]); src[corner_verts[lt.tri[2]]]);
dst[i] = math::normalize(value); dst[i] = math::normalize(value);
}); });
} }
@ -91,8 +91,8 @@ BLI_NOINLINE static void sample_corner_attribute(const Span<MLoopTri> looptris,
return; return;
} }
} }
const MLoopTri &tri = looptris[looptri_indices[i]]; const MLoopTri &lt = looptris[looptri_indices[i]];
dst[i] = sample_corner_attribute_with_bary_coords(bary_coords[i], tri, src); dst[i] = sample_corner_attribute_with_bary_coords(bary_coords[i], lt, src);
}); });
} }
@ -104,8 +104,8 @@ void sample_corner_normals(const Span<MLoopTri> looptris,
const MutableSpan<float3> dst) const MutableSpan<float3> dst)
{ {
mask.foreach_index([&](const int i) { mask.foreach_index([&](const int i) {
const MLoopTri &tri = looptris[looptri_indices[i]]; const MLoopTri &lt = looptris[looptri_indices[i]];
const float3 value = sample_corner_attribute_with_bary_coords(bary_coords[i], tri, src); const float3 value = sample_corner_attribute_with_bary_coords(bary_coords[i], lt, src);
dst[i] = math::normalize(value); dst[i] = math::normalize(value);
}); });
} }
@ -172,9 +172,9 @@ static void sample_barycentric_weights(const Span<float3> vert_positions,
return; return;
} }
} }
const MLoopTri &tri = looptris[looptri_indices[i]]; const MLoopTri &lt = looptris[looptri_indices[i]];
bary_coords[i] = compute_bary_coord_in_triangle( bary_coords[i] = compute_bary_coord_in_triangle(
vert_positions, corner_verts, tri, sample_positions[i]); vert_positions, corner_verts, lt, sample_positions[i]);
}); });
} }
@ -194,11 +194,11 @@ static void sample_nearest_weights(const Span<float3> vert_positions,
return; return;
} }
} }
const MLoopTri &tri = looptris[looptri_indices[i]]; const MLoopTri &lt = looptris[looptri_indices[i]];
bary_coords[i] = MIN3_PAIR( bary_coords[i] = MIN3_PAIR(
math::distance_squared(sample_positions[i], vert_positions[corner_verts[tri.tri[0]]]), math::distance_squared(sample_positions[i], vert_positions[corner_verts[lt.tri[0]]]),
math::distance_squared(sample_positions[i], vert_positions[corner_verts[tri.tri[1]]]), math::distance_squared(sample_positions[i], vert_positions[corner_verts[lt.tri[1]]]),
math::distance_squared(sample_positions[i], vert_positions[corner_verts[tri.tri[2]]]), math::distance_squared(sample_positions[i], vert_positions[corner_verts[lt.tri[2]]]),
float3(1, 0, 0), float3(1, 0, 0),
float3(0, 1, 0), float3(0, 1, 0),
float3(0, 0, 1)); float3(0, 0, 1));
@ -227,11 +227,11 @@ int sample_surface_points_spherical(RandomNumberGenerator &rng,
const int old_num = r_bary_coords.size(); const int old_num = r_bary_coords.size();
for (const int looptri_index : looptri_indices_to_sample) { for (const int looptri_index : looptri_indices_to_sample) {
const MLoopTri &looptri = looptris[looptri_index]; const MLoopTri &lt = looptris[looptri_index];
const float3 &v0 = positions[corner_verts[looptri.tri[0]]]; const float3 &v0 = positions[corner_verts[lt.tri[0]]];
const float3 &v1 = positions[corner_verts[looptri.tri[1]]]; const float3 &v1 = positions[corner_verts[lt.tri[1]]];
const float3 &v2 = positions[corner_verts[looptri.tri[2]]]; const float3 &v2 = positions[corner_verts[lt.tri[2]]];
const float looptri_area = area_tri_v3(v0, v1, v2); const float looptri_area = area_tri_v3(v0, v1, v2);
@ -367,12 +367,12 @@ int sample_surface_points_projected(
float3 compute_bary_coord_in_triangle(const Span<float3> vert_positions, float3 compute_bary_coord_in_triangle(const Span<float3> vert_positions,
const Span<int> corner_verts, const Span<int> corner_verts,
const MLoopTri &looptri, const MLoopTri &lt,
const float3 &position) const float3 &position)
{ {
const float3 &v0 = vert_positions[corner_verts[looptri.tri[0]]]; const float3 &v0 = vert_positions[corner_verts[lt.tri[0]]];
const float3 &v1 = vert_positions[corner_verts[looptri.tri[1]]]; const float3 &v1 = vert_positions[corner_verts[lt.tri[1]]];
const float3 &v2 = vert_positions[corner_verts[looptri.tri[2]]]; const float3 &v2 = vert_positions[corner_verts[lt.tri[2]]];
float3 bary_coords; float3 bary_coords;
interp_weights_tri_v3(bary_coords, v0, v1, v2, position); interp_weights_tri_v3(bary_coords, v0, v1, v2, position);
return bary_coords; return bary_coords;

@ -156,7 +156,7 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
/** \name Mesh Tangent Calculations (All Layers) /** \name Mesh Tangent Calculations (All Layers)
* \{ */ * \{ */
/* Necessary complexity to handle looptri's as quads for correct tangents */ /* Necessary complexity to handle looptris as quads for correct tangents. */
#define USE_LOOPTRI_DETECT_QUADS #define USE_LOOPTRI_DETECT_QUADS
struct SGLSLMeshToTangent { struct SGLSLMeshToTangent {
@ -189,7 +189,7 @@ struct SGLSLMeshToTangent {
{ {
#ifdef USE_LOOPTRI_DETECT_QUADS #ifdef USE_LOOPTRI_DETECT_QUADS
if (face_as_quad_map) { if (face_as_quad_map) {
lt = looptri[face_as_quad_map[face_num]]; lt = looptris[face_as_quad_map[face_num]];
face_index = looptri_faces[face_as_quad_map[face_num]]; face_index = looptri_faces[face_as_quad_map[face_num]];
if (faces[face_index].size() == 4) { if (faces[face_index].size() == 4) {
return uint(faces[face_index][vert_num]); return uint(faces[face_index][vert_num]);
@ -197,11 +197,11 @@ struct SGLSLMeshToTangent {
/* fall through to regular triangle */ /* fall through to regular triangle */
} }
else { else {
lt = looptri[face_num]; lt = looptris[face_num];
face_index = looptri_faces[face_num]; face_index = looptri_faces[face_num];
} }
#else #else
lt = &looptri[face_num]; lt = &looptris[face_num];
#endif #endif
return lt.tri[vert_num]; return lt.tri[vert_num];
} }
@ -275,7 +275,7 @@ struct SGLSLMeshToTangent {
const float (*precomputedFaceNormals)[3]; const float (*precomputedFaceNormals)[3];
const float (*precomputedLoopNormals)[3]; const float (*precomputedLoopNormals)[3];
const MLoopTri *looptri; const MLoopTri *looptris;
const int *looptri_faces; const int *looptri_faces;
const float2 *mloopuv; /* texture coordinates */ const float2 *mloopuv; /* texture coordinates */
blender::OffsetIndices<int> faces; blender::OffsetIndices<int> faces;
@ -288,8 +288,8 @@ struct SGLSLMeshToTangent {
int numTessFaces; int numTessFaces;
#ifdef USE_LOOPTRI_DETECT_QUADS #ifdef USE_LOOPTRI_DETECT_QUADS
/* map from 'fake' face index to looptri, /* map from 'fake' face index to looptris,
* quads will point to the first looptri of the quad */ * quads will point to the first looptris of the quad */
const int *face_as_quad_map; const int *face_as_quad_map;
int num_face_as_quad_map; int num_face_as_quad_map;
#endif #endif
@ -394,9 +394,9 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3], void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
const blender::OffsetIndices<int> faces, const blender::OffsetIndices<int> faces,
const int *corner_verts, const int *corner_verts,
const MLoopTri *looptri, const MLoopTri *looptris,
const int *looptri_faces, const int *looptri_faces,
const uint looptri_len, const uint looptris_len,
const blender::Span<bool> sharp_faces, const blender::Span<bool> sharp_faces,
CustomData *loopdata, CustomData *loopdata,
@ -461,13 +461,13 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
int *face_as_quad_map = nullptr; int *face_as_quad_map = nullptr;
/* map faces to quads */ /* map faces to quads */
if (looptri_len != uint(faces.size())) { if (looptris_len != uint(faces.size())) {
/* Over allocate, since we don't know how many ngon or quads we have. */ /* Over allocate, since we don't know how many ngon or quads we have. */
/* map fake face index to looptri */ /* Map fake face index to looptris. */
face_as_quad_map = static_cast<int *>(MEM_mallocN(sizeof(int) * looptri_len, __func__)); face_as_quad_map = static_cast<int *>(MEM_mallocN(sizeof(int) * looptris_len, __func__));
int k, j; int k, j;
for (k = 0, j = 0; j < int(looptri_len); k++, j++) { for (k = 0, j = 0; j < int(looptris_len); k++, j++) {
face_as_quad_map[k] = j; face_as_quad_map[k] = j;
/* step over all quads */ /* step over all quads */
if (faces[looptri_faces[j]].size() == 4) { if (faces[looptri_faces[j]].size() == 4) {
@ -477,12 +477,12 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
num_face_as_quad_map = k; num_face_as_quad_map = k;
} }
else { else {
num_face_as_quad_map = int(looptri_len); num_face_as_quad_map = int(looptris_len);
} }
#endif #endif
/* Calculation */ /* Calculation */
if (looptri_len != 0) { if (looptris_len != 0) {
TaskPool *task_pool = BLI_task_pool_create(nullptr, TASK_PRIORITY_HIGH); TaskPool *task_pool = BLI_task_pool_create(nullptr, TASK_PRIORITY_HIGH);
tangent_mask_curr = 0; tangent_mask_curr = 0;
@ -493,7 +493,7 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
int index = CustomData_get_layer_index_n(loopdata_out, CD_TANGENT, n); int index = CustomData_get_layer_index_n(loopdata_out, CD_TANGENT, n);
BLI_assert(n < MAX_MTFACE); BLI_assert(n < MAX_MTFACE);
SGLSLMeshToTangent *mesh2tangent = &data_array[n]; SGLSLMeshToTangent *mesh2tangent = &data_array[n];
mesh2tangent->numTessFaces = int(looptri_len); mesh2tangent->numTessFaces = int(looptris_len);
#ifdef USE_LOOPTRI_DETECT_QUADS #ifdef USE_LOOPTRI_DETECT_QUADS
mesh2tangent->face_as_quad_map = face_as_quad_map; mesh2tangent->face_as_quad_map = face_as_quad_map;
mesh2tangent->num_face_as_quad_map = num_face_as_quad_map; mesh2tangent->num_face_as_quad_map = num_face_as_quad_map;
@ -502,7 +502,7 @@ void BKE_mesh_calc_loop_tangent_ex(const float (*vert_positions)[3],
mesh2tangent->vert_normals = vert_normals; mesh2tangent->vert_normals = vert_normals;
mesh2tangent->faces = faces; mesh2tangent->faces = faces;
mesh2tangent->corner_verts = corner_verts; mesh2tangent->corner_verts = corner_verts;
mesh2tangent->looptri = looptri; mesh2tangent->looptris = looptris;
mesh2tangent->looptri_faces = looptri_faces; mesh2tangent->looptri_faces = looptri_faces;
mesh2tangent->sharp_faces = sharp_faces; mesh2tangent->sharp_faces = sharp_faces;
/* NOTE: we assume we do have tessellated loop normals at this point /* NOTE: we assume we do have tessellated loop normals at this point

@ -42,7 +42,7 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const Span<int> corner_vert
const blender::OffsetIndices<int> faces, const blender::OffsetIndices<int> faces,
const Span<float3> positions, const Span<float3> positions,
uint face_index, uint face_index,
MLoopTri *mlt, MLoopTri *lt,
MemArena **pf_arena_p, MemArena **pf_arena_p,
const bool face_normal, const bool face_normal,
const float normal_precalc[3]) const float normal_precalc[3])
@ -51,9 +51,9 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const Span<int> corner_vert
const uint mp_totloop = uint(faces[face_index].size()); const uint mp_totloop = uint(faces[face_index].size());
auto create_tri = [&](uint i1, uint i2, uint i3) { auto create_tri = [&](uint i1, uint i2, uint i3) {
mlt->tri[0] = mp_loopstart + i1; lt->tri[0] = mp_loopstart + i1;
mlt->tri[1] = mp_loopstart + i2; lt->tri[1] = mp_loopstart + i2;
mlt->tri[2] = mp_loopstart + i3; lt->tri[2] = mp_loopstart + i3;
}; };
switch (mp_totloop) { switch (mp_totloop) {
@ -63,17 +63,17 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const Span<int> corner_vert
} }
case 4: { case 4: {
create_tri(0, 1, 2); create_tri(0, 1, 2);
MLoopTri *mlt_a = mlt++; MLoopTri *lt_a = lt++;
create_tri(0, 2, 3); create_tri(0, 2, 3);
MLoopTri *mlt_b = mlt; MLoopTri *lt_b = lt;
if (UNLIKELY(is_quad_flip_v3_first_third_fast(positions[corner_verts[mlt_a->tri[0]]], if (UNLIKELY(is_quad_flip_v3_first_third_fast(positions[corner_verts[lt_a->tri[0]]],
positions[corner_verts[mlt_a->tri[1]]], positions[corner_verts[lt_a->tri[1]]],
positions[corner_verts[mlt_a->tri[2]]], positions[corner_verts[lt_a->tri[2]]],
positions[corner_verts[mlt_b->tri[2]]]))) positions[corner_verts[lt_b->tri[2]]])))
{ {
/* Flip out of degenerate 0-2 state. */ /* Flip out of degenerate 0-2 state. */
mlt_a->tri[2] = mlt_b->tri[2]; lt_a->tri[2] = lt_b->tri[2];
mlt_b->tri[0] = mlt_a->tri[1]; lt_b->tri[0] = lt_a->tri[1];
} }
break; break;
} }
@ -122,7 +122,7 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const Span<int> corner_vert
BLI_polyfill_calc_arena(projverts, mp_totloop, 1, tris, pf_arena); BLI_polyfill_calc_arena(projverts, mp_totloop, 1, tris, pf_arena);
/* Apply fill. */ /* Apply fill. */
for (uint j = 0; j < totfilltri; j++, mlt++) { for (uint j = 0; j < totfilltri; j++, lt++) {
const uint *tri = tris[j]; const uint *tri = tris[j];
create_tri(tri[0], tri[1], tri[2]); create_tri(tri[0], tri[1], tri[2]);
} }
@ -139,30 +139,30 @@ static void mesh_calc_tessellation_for_face(const Span<int> corner_verts,
const blender::OffsetIndices<int> faces, const blender::OffsetIndices<int> faces,
const Span<float3> positions, const Span<float3> positions,
uint face_index, uint face_index,
MLoopTri *mlt, MLoopTri *lt,
MemArena **pf_arena_p) MemArena **pf_arena_p)
{ {
mesh_calc_tessellation_for_face_impl( mesh_calc_tessellation_for_face_impl(
corner_verts, faces, positions, face_index, mlt, pf_arena_p, false, nullptr); corner_verts, faces, positions, face_index, lt, pf_arena_p, false, nullptr);
} }
static void mesh_calc_tessellation_for_face_with_normal(const Span<int> corner_verts, static void mesh_calc_tessellation_for_face_with_normal(const Span<int> corner_verts,
const blender::OffsetIndices<int> faces, const blender::OffsetIndices<int> faces,
const Span<float3> positions, const Span<float3> positions,
uint face_index, uint face_index,
MLoopTri *mlt, MLoopTri *lt,
MemArena **pf_arena_p, MemArena **pf_arena_p,
const float normal_precalc[3]) const float normal_precalc[3])
{ {
mesh_calc_tessellation_for_face_impl( mesh_calc_tessellation_for_face_impl(
corner_verts, faces, positions, face_index, mlt, pf_arena_p, true, normal_precalc); corner_verts, faces, positions, face_index, lt, pf_arena_p, true, normal_precalc);
} }
static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts, static void mesh_recalc_looptris__single_threaded(const Span<int> corner_verts,
const blender::OffsetIndices<int> faces, const blender::OffsetIndices<int> faces,
const Span<float3> positions, const Span<float3> positions,
MLoopTri *mlooptri, MLoopTri *looptris,
const float (*face_normals)[3]) const float (*face_normals)[3])
{ {
MemArena *pf_arena = nullptr; MemArena *pf_arena = nullptr;
uint looptri_i = 0; uint looptri_i = 0;
@ -173,7 +173,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
faces, faces,
positions, positions,
uint(i), uint(i),
&mlooptri[looptri_i], &looptris[looptri_i],
&pf_arena, &pf_arena,
face_normals[i]); face_normals[i]);
looptri_i += uint(faces[i].size() - 2); looptri_i += uint(faces[i].size() - 2);
@ -182,7 +182,7 @@ static void mesh_recalc_looptri__single_threaded(const Span<int> corner_verts,
else { else {
for (const int64_t i : faces.index_range()) { for (const int64_t i : faces.index_range()) {
mesh_calc_tessellation_for_face( mesh_calc_tessellation_for_face(
corner_verts, faces, positions, uint(i), &mlooptri[looptri_i], &pf_arena); corner_verts, faces, positions, uint(i), &looptris[looptri_i], &pf_arena);
looptri_i += uint(faces[i].size() - 2); looptri_i += uint(faces[i].size() - 2);
} }
} }
@ -200,7 +200,7 @@ struct TessellationUserData {
Span<float3> positions; Span<float3> positions;
/** Output array. */ /** Output array. */
MutableSpan<MLoopTri> mlooptri; MutableSpan<MLoopTri> looptris;
/** Optional pre-calculated face normals array. */ /** Optional pre-calculated face normals array. */
const float (*face_normals)[3]; const float (*face_normals)[3];
@ -221,7 +221,7 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata,
data->faces, data->faces,
data->positions, data->positions,
uint(index), uint(index),
&data->mlooptri[looptri_i], &data->looptris[looptri_i],
&tls_data->pf_arena, &tls_data->pf_arena,
false, false,
nullptr); nullptr);
@ -238,7 +238,7 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user
data->faces, data->faces,
data->positions, data->positions,
uint(index), uint(index),
&data->mlooptri[looptri_i], &data->looptris[looptri_i],
&tls_data->pf_arena, &tls_data->pf_arena,
true, true,
data->face_normals[index]); data->face_normals[index]);
@ -260,11 +260,12 @@ static void looptris_calc_all(const Span<float3> positions,
MutableSpan<MLoopTri> looptris) MutableSpan<MLoopTri> looptris)
{ {
if (corner_verts.size() < MESH_FACE_TESSELLATE_THREADED_LIMIT) { if (corner_verts.size() < MESH_FACE_TESSELLATE_THREADED_LIMIT) {
mesh_recalc_looptri__single_threaded(corner_verts, mesh_recalc_looptris__single_threaded(
faces, corner_verts,
positions, faces,
looptris.data(), positions,
reinterpret_cast<const float(*)[3]>(face_normals.data())); looptris.data(),
reinterpret_cast<const float(*)[3]>(face_normals.data()));
return; return;
} }
TessellationUserTLS tls_data_dummy = {nullptr}; TessellationUserTLS tls_data_dummy = {nullptr};
@ -273,7 +274,7 @@ static void looptris_calc_all(const Span<float3> positions,
data.corner_verts = corner_verts; data.corner_verts = corner_verts;
data.faces = faces; data.faces = faces;
data.positions = positions; data.positions = positions;
data.mlooptri = looptris; data.looptris = looptris;
data.face_normals = reinterpret_cast<const float(*)[3]>(face_normals.data()); data.face_normals = reinterpret_cast<const float(*)[3]>(face_normals.data());
TaskParallelSettings settings; TaskParallelSettings settings;
@ -327,12 +328,12 @@ void looptris_calc_with_normals(const Span<float3> vert_positions,
int3 looptri_get_real_edges(const Span<int2> edges, int3 looptri_get_real_edges(const Span<int2> edges,
const Span<int> corner_verts, const Span<int> corner_verts,
const Span<int> corner_edges, const Span<int> corner_edges,
const MLoopTri &tri) const MLoopTri &lt)
{ {
int3 real_edges; int3 real_edges;
for (int i = 2, i_next = 0; i_next < 3; i = i_next++) { for (int i = 2, i_next = 0; i_next < 3; i = i_next++) {
const int corner_1 = int(tri.tri[i]); const int corner_1 = int(lt.tri[i]);
const int corner_2 = int(tri.tri[i_next]); const int corner_2 = int(lt.tri[i_next]);
const int vert_1 = corner_verts[corner_1]; const int vert_1 = corner_verts[corner_1];
const int vert_2 = corner_verts[corner_2]; const int vert_2 = corner_verts[corner_2];
const int edge_i = corner_edges[corner_1]; const int edge_i = corner_edges[corner_1];

@ -278,10 +278,10 @@ static void build_mesh_leaf_node(const Span<int> corner_verts,
node->face_vert_indices.reinitialize(prim_indices.size()); node->face_vert_indices.reinitialize(prim_indices.size());
for (const int i : prim_indices.index_range()) { for (const int i : prim_indices.index_range()) {
const MLoopTri &tri = looptris[prim_indices[i]]; const MLoopTri &lt = looptris[prim_indices[i]];
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
node->face_vert_indices[i][j] = map_insert_vert( node->face_vert_indices[i][j] = map_insert_vert(
map, vert_bitmap, &node->face_verts, &node->uniq_verts, corner_verts[tri.tri[j]]); map, vert_bitmap, &node->face_verts, &node->uniq_verts, corner_verts[lt.tri[j]]);
} }
} }
@ -392,7 +392,7 @@ static void build_leaf(PBVH *pbvh,
/* Still need vb for searches */ /* Still need vb for searches */
update_vb(pbvh->prim_indices, &node, prim_bounds, offset, count); update_vb(pbvh->prim_indices, &node, prim_bounds, offset, count);
if (!pbvh->looptri.is_empty()) { if (!pbvh->looptris.is_empty()) {
build_mesh_leaf_node( build_mesh_leaf_node(
corner_verts, looptris, looptri_faces, hide_poly, pbvh->vert_bitmap, &node); corner_verts, looptris, looptri_faces, hide_poly, pbvh->vert_bitmap, &node);
} }
@ -733,14 +733,14 @@ void BKE_pbvh_build_mesh(PBVH *pbvh, Mesh *mesh)
using namespace blender; using namespace blender;
using namespace blender::bke; using namespace blender::bke;
const int totvert = mesh->totvert; const int totvert = mesh->totvert;
const int looptri_num = poly_to_tri_count(mesh->faces_num, mesh->totloop); const int looptris_num = poly_to_tri_count(mesh->faces_num, mesh->totloop);
MutableSpan<float3> vert_positions = mesh->vert_positions_for_write(); MutableSpan<float3> vert_positions = mesh->vert_positions_for_write();
const blender::OffsetIndices<int> faces = mesh->faces(); const blender::OffsetIndices<int> faces = mesh->faces();
const Span<int> corner_verts = mesh->corner_verts(); const Span<int> corner_verts = mesh->corner_verts();
pbvh->looptri.reinitialize(looptri_num); pbvh->looptris.reinitialize(looptris_num);
blender::bke::mesh::looptris_calc(vert_positions, faces, corner_verts, pbvh->looptri); blender::bke::mesh::looptris_calc(vert_positions, faces, corner_verts, pbvh->looptris);
const Span<MLoopTri> looptris = pbvh->looptri; const Span<MLoopTri> looptris = pbvh->looptris;
pbvh->mesh = mesh; pbvh->mesh = mesh;
pbvh->header.type = PBVH_FACES; pbvh->header.type = PBVH_FACES;
@ -764,7 +764,7 @@ void BKE_pbvh_build_mesh(PBVH *pbvh, Mesh *mesh)
pbvh->faces_num = mesh->faces_num; pbvh->faces_num = mesh->faces_num;
/* For each face, store the AABB and the AABB centroid */ /* For each face, store the AABB and the AABB centroid */
Array<Bounds<float3>> prim_bounds(looptri_num); Array<Bounds<float3>> prim_bounds(looptris_num);
const Bounds<float3> cb = threading::parallel_reduce( const Bounds<float3> cb = threading::parallel_reduce(
looptris.index_range(), looptris.index_range(),
1024, 1024,
@ -784,7 +784,7 @@ void BKE_pbvh_build_mesh(PBVH *pbvh, Mesh *mesh)
}, },
[](const Bounds<float3> &a, const Bounds<float3> &b) { return bounds::merge(a, b); }); [](const Bounds<float3> &a, const Bounds<float3> &b) { return bounds::merge(a, b); });
if (looptri_num) { if (looptris_num) {
const AttributeAccessor attributes = mesh->attributes(); const AttributeAccessor attributes = mesh->attributes();
const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE); const VArraySpan hide_poly = *attributes.lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE);
const VArraySpan material_index = *attributes.lookup<int>("material_index", ATTR_DOMAIN_FACE); const VArraySpan material_index = *attributes.lookup<int>("material_index", ATTR_DOMAIN_FACE);
@ -798,7 +798,7 @@ void BKE_pbvh_build_mesh(PBVH *pbvh, Mesh *mesh)
sharp_face, sharp_face,
&cb, &cb,
prim_bounds, prim_bounds,
looptri_num); looptris_num);
#ifdef TEST_PBVH_FACE_SPLIT #ifdef TEST_PBVH_FACE_SPLIT
test_face_boundaries(pbvh, looptri_faces); test_face_boundaries(pbvh, looptri_faces);
@ -2073,7 +2073,7 @@ static bool pbvh_faces_node_raycast(PBVH *pbvh,
for (const int i : node->prim_indices.index_range()) { for (const int i : node->prim_indices.index_range()) {
const int looptri_i = node->prim_indices[i]; const int looptri_i = node->prim_indices[i];
const MLoopTri *lt = &pbvh->looptri[looptri_i]; const MLoopTri *lt = &pbvh->looptris[looptri_i];
const blender::int3 face_verts = node->face_vert_indices[i]; const blender::int3 face_verts = node->face_vert_indices[i];
if (!hide_poly.is_empty() && hide_poly[pbvh->looptri_faces[looptri_i]]) { if (!hide_poly.is_empty() && hide_poly[pbvh->looptri_faces[looptri_i]]) {
@ -2424,7 +2424,7 @@ static bool pbvh_faces_node_nearest_to_ray(PBVH *pbvh,
for (const int i : node->prim_indices.index_range()) { for (const int i : node->prim_indices.index_range()) {
const int looptri_i = node->prim_indices[i]; const int looptri_i = node->prim_indices[i];
const MLoopTri *lt = &pbvh->looptri[looptri_i]; const MLoopTri *lt = &pbvh->looptris[looptri_i];
const blender::int3 face_verts = node->face_vert_indices[i]; const blender::int3 face_verts = node->face_vert_indices[i];
if (!hide_poly.is_empty() && hide_poly[pbvh->looptri_faces[looptri_i]]) { if (!hide_poly.is_empty() && hide_poly[pbvh->looptri_faces[looptri_i]]) {
@ -2652,7 +2652,7 @@ static blender::draw::pbvh::PBVH_GPU_Args pbvh_draw_args_init(const Mesh &mesh,
args.vert_positions = pbvh.vert_positions; args.vert_positions = pbvh.vert_positions;
args.corner_verts = mesh.corner_verts(); args.corner_verts = mesh.corner_verts();
args.corner_edges = mesh.corner_edges(); args.corner_edges = mesh.corner_edges();
args.mlooptri = pbvh.looptri; args.looptris = pbvh.looptris;
args.vert_normals = pbvh.vert_normals; args.vert_normals = pbvh.vert_normals;
args.face_normals = pbvh.face_normals; args.face_normals = pbvh.face_normals;
/* Retrieve data from the original mesh. Ideally that would be passed to this function to /* Retrieve data from the original mesh. Ideally that would be passed to this function to
@ -3147,12 +3147,12 @@ void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
loop_indices.clear(); loop_indices.clear();
for (const int i : node.prim_indices) { for (const int i : node.prim_indices) {
const MLoopTri &mlt = pbvh->looptri[i]; const MLoopTri &lt = pbvh->looptris[i];
for (int k = 0; k < 3; k++) { for (int k = 0; k < 3; k++) {
if (!BLI_BITMAP_TEST(visit, mlt.tri[k])) { if (!BLI_BITMAP_TEST(visit, lt.tri[k])) {
loop_indices.append(mlt.tri[k]); loop_indices.append(lt.tri[k]);
BLI_BITMAP_ENABLE(visit, mlt.tri[k]); BLI_BITMAP_ENABLE(visit, lt.tri[k]);
} }
} }
} }

@ -43,7 +43,7 @@ struct PBVHNode {
/* List of primitives for this node. Semantics depends on /* List of primitives for this node. Semantics depends on
* PBVH type: * PBVH type:
* *
* - PBVH_FACES: Indices into the PBVH.looptri array. * - PBVH_FACES: Indices into the #PBVH::looptris array.
* - PBVH_GRIDS: Multires grid indices. * - PBVH_GRIDS: Multires grid indices.
* - PBVH_BMESH: Unused. See PBVHNode.bm_faces. * - PBVH_BMESH: Unused. See PBVHNode.bm_faces.
* *
@ -163,7 +163,7 @@ struct PBVH {
blender::OffsetIndices<int> faces; blender::OffsetIndices<int> faces;
blender::Span<int> corner_verts; blender::Span<int> corner_verts;
/* Owned by the #PBVH, because after deformations they have to be recomputed. */ /* Owned by the #PBVH, because after deformations they have to be recomputed. */
blender::Array<MLoopTri> looptri; blender::Array<MLoopTri> looptris;
blender::Span<int> looptri_faces; blender::Span<int> looptri_faces;
/* Grid Data */ /* Grid Data */

@ -418,10 +418,10 @@ static void update_geom_primitives(PBVH &pbvh, const uv_islands::MeshData &mesh_
{ {
PBVHData &pbvh_data = BKE_pbvh_pixels_data_get(pbvh); PBVHData &pbvh_data = BKE_pbvh_pixels_data_get(pbvh);
pbvh_data.clear_data(); pbvh_data.clear_data();
for (const MLoopTri &looptri : mesh_data.looptris) { for (const MLoopTri &lt : mesh_data.looptris) {
pbvh_data.geom_primitives.append(int3(mesh_data.corner_verts[looptri.tri[0]], pbvh_data.geom_primitives.append(int3(mesh_data.corner_verts[lt.tri[0]],
mesh_data.corner_verts[looptri.tri[1]], mesh_data.corner_verts[lt.tri[1]],
mesh_data.corner_verts[looptri.tri[2]])); mesh_data.corner_verts[lt.tri[2]]));
} }
} }
@ -676,7 +676,7 @@ static bool update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image
const VArraySpan uv_map = *attributes.lookup<float2>(active_uv_name, ATTR_DOMAIN_CORNER); const VArraySpan uv_map = *attributes.lookup<float2>(active_uv_name, ATTR_DOMAIN_CORNER);
uv_islands::MeshData mesh_data( uv_islands::MeshData mesh_data(
pbvh->looptri, mesh->corner_verts(), uv_map, pbvh->vert_positions); pbvh->looptris, mesh->corner_verts(), uv_map, pbvh->vert_positions);
uv_islands::UVIslands islands(mesh_data); uv_islands::UVIslands islands(mesh_data);
uv_islands::UVIslandsMask uv_masks; uv_islands::UVIslandsMask uv_masks;

@ -109,12 +109,12 @@ class NonManifoldUVEdges : public Vector<Edge<CoordSpace::UV>> {
if (is_manifold(mesh_data, edge_id)) { if (is_manifold(mesh_data, edge_id)) {
continue; continue;
} }
const MLoopTri &loop_tri = mesh_data.looptris[primitive_id]; const MLoopTri &lt = mesh_data.looptris[primitive_id];
const uv_islands::MeshEdge &mesh_edge = mesh_data.edges[edge_id]; const uv_islands::MeshEdge &mesh_edge = mesh_data.edges[edge_id];
Edge<CoordSpace::UV> edge; Edge<CoordSpace::UV> edge;
edge.vertex_1.coordinate = find_uv(mesh_data, loop_tri, mesh_edge.vert1); edge.vertex_1.coordinate = find_uv(mesh_data, lt, mesh_edge.vert1);
edge.vertex_2.coordinate = find_uv(mesh_data, loop_tri, mesh_edge.vert2); edge.vertex_2.coordinate = find_uv(mesh_data, lt, mesh_edge.vert2);
append(edge); append(edge);
} }
} }
@ -154,12 +154,10 @@ class NonManifoldUVEdges : public Vector<Edge<CoordSpace::UV>> {
return mesh_data.edge_to_primitive_map[edge_id].size() == 2; return mesh_data.edge_to_primitive_map[edge_id].size() == 2;
} }
static float2 find_uv(const uv_islands::MeshData &mesh_data, static float2 find_uv(const uv_islands::MeshData &mesh_data, const MLoopTri &lt, int vertex_i)
const MLoopTri &loop_tri,
int vertex_i)
{ {
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
const int loop_i = loop_tri.tri[i]; const int loop_i = lt.tri[i];
const int vert = mesh_data.corner_verts[loop_i]; const int vert = mesh_data.corner_verts[loop_i];
if (vert == vertex_i) { if (vert == vertex_i) {
return mesh_data.uv_map[loop_i]; return mesh_data.uv_map[loop_i];

@ -42,20 +42,14 @@ static void uv_primitive_append_to_uv_vertices(UVPrimitive &uv_primitive)
* \{ */ * \{ */
static int primitive_get_other_uv_vertex(const MeshData &mesh_data, static int primitive_get_other_uv_vertex(const MeshData &mesh_data,
const MLoopTri &looptri, const MLoopTri &lt,
const int v1, const int v1,
const int v2) const int v2)
{ {
const Span<int> corner_verts = mesh_data.corner_verts; const Span<int> corner_verts = mesh_data.corner_verts;
BLI_assert(ELEM(v1, BLI_assert(ELEM(v1, corner_verts[lt.tri[0]], corner_verts[lt.tri[1]], corner_verts[lt.tri[2]]));
corner_verts[looptri.tri[0]], BLI_assert(ELEM(v2, corner_verts[lt.tri[0]], corner_verts[lt.tri[1]], corner_verts[lt.tri[2]]));
corner_verts[looptri.tri[1]], for (const int loop : lt.tri) {
corner_verts[looptri.tri[2]]));
BLI_assert(ELEM(v2,
corner_verts[looptri.tri[0]],
corner_verts[looptri.tri[1]],
corner_verts[looptri.tri[2]]));
for (const int loop : looptri.tri) {
const int vert = corner_verts[loop]; const int vert = corner_verts[loop];
if (!ELEM(vert, v1, v2)) { if (!ELEM(vert, v1, v2)) {
return vert; return vert;
@ -65,12 +59,12 @@ static int primitive_get_other_uv_vertex(const MeshData &mesh_data,
} }
static bool primitive_has_shared_uv_edge(const Span<float2> uv_map, static bool primitive_has_shared_uv_edge(const Span<float2> uv_map,
const MLoopTri &looptri, const MLoopTri &lt,
const MLoopTri &other) const MLoopTri &lt_other)
{ {
int shared_uv_verts = 0; int shared_uv_verts = 0;
for (const int loop : looptri.tri) { for (const int loop : lt.tri) {
for (const int other_loop : other.tri) { for (const int other_loop : lt_other.tri) {
if (uv_map[loop] == uv_map[other_loop]) { if (uv_map[loop] == uv_map[other_loop]) {
shared_uv_verts += 1; shared_uv_verts += 1;
} }
@ -79,22 +73,22 @@ static bool primitive_has_shared_uv_edge(const Span<float2> uv_map,
return shared_uv_verts >= 2; return shared_uv_verts >= 2;
} }
static int get_uv_loop(const MeshData &mesh_data, const MLoopTri &looptri, const int vert) static int get_uv_loop(const MeshData &mesh_data, const MLoopTri &lt, const int vert)
{ {
for (const int loop : looptri.tri) { for (const int loop : lt.tri) {
if (mesh_data.corner_verts[loop] == vert) { if (mesh_data.corner_verts[loop] == vert) {
return loop; return loop;
} }
} }
BLI_assert_unreachable(); BLI_assert_unreachable();
return looptri.tri[0]; return lt.tri[0];
} }
static rctf primitive_uv_bounds(const MLoopTri &looptri, const Span<float2> uv_map) static rctf primitive_uv_bounds(const MLoopTri &lt, const Span<float2> uv_map)
{ {
rctf result; rctf result;
BLI_rctf_init_minmax(&result); BLI_rctf_init_minmax(&result);
for (const int loop : looptri.tri) { for (const int loop : lt.tri) {
BLI_rctf_do_minmax_v(&result, uv_map[loop]); BLI_rctf_do_minmax_v(&result, uv_map[loop]);
} }
return result; return result;
@ -112,11 +106,11 @@ static void mesh_data_init_edges(MeshData &mesh_data)
Map<OrderedEdge, int> eh; Map<OrderedEdge, int> eh;
eh.reserve(mesh_data.looptris.size() * 3); eh.reserve(mesh_data.looptris.size() * 3);
for (int64_t i = 0; i < mesh_data.looptris.size(); i++) { for (int64_t i = 0; i < mesh_data.looptris.size(); i++) {
const MLoopTri &tri = mesh_data.looptris[i]; const MLoopTri &lt = mesh_data.looptris[i];
Vector<int, 3> edges; Vector<int, 3> edges;
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
int v1 = mesh_data.corner_verts[tri.tri[j]]; int v1 = mesh_data.corner_verts[lt.tri[j]];
int v2 = mesh_data.corner_verts[tri.tri[(j + 1) % 3]]; int v2 = mesh_data.corner_verts[lt.tri[(j + 1) % 3]];
int64_t edge_index; int64_t edge_index;
eh.add_or_modify( eh.add_or_modify(
@ -426,13 +420,13 @@ static UVPrimitive *add_primitive(const MeshData &mesh_data,
const int primitive_i) const int primitive_i)
{ {
UVPrimitive uv_primitive(primitive_i); UVPrimitive uv_primitive(primitive_i);
const MLoopTri &primitive = mesh_data.looptris[primitive_i]; const MLoopTri &lt_primitive = mesh_data.looptris[primitive_i];
uv_island.uv_primitives.append(uv_primitive); uv_island.uv_primitives.append(uv_primitive);
UVPrimitive *uv_primitive_ptr = &uv_island.uv_primitives.last(); UVPrimitive *uv_primitive_ptr = &uv_island.uv_primitives.last();
for (const int edge_i : mesh_data.primitive_to_edge_map[primitive_i]) { for (const int edge_i : mesh_data.primitive_to_edge_map[primitive_i]) {
const MeshEdge &edge = mesh_data.edges[edge_i]; const MeshEdge &edge = mesh_data.edges[edge_i];
const int loop_1 = get_uv_loop(mesh_data, primitive, edge.vert1); const int loop_1 = get_uv_loop(mesh_data, lt_primitive, edge.vert1);
const int loop_2 = get_uv_loop(mesh_data, primitive, edge.vert2); const int loop_2 = get_uv_loop(mesh_data, lt_primitive, edge.vert2);
UVEdge uv_edge_template; UVEdge uv_edge_template;
uv_edge_template.vertices[0] = uv_island.lookup_or_create(UVVertex(mesh_data, loop_1)); uv_edge_template.vertices[0] = uv_island.lookup_or_create(UVVertex(mesh_data, loop_1));
uv_edge_template.vertices[1] = uv_island.lookup_or_create(UVVertex(mesh_data, loop_2)); uv_edge_template.vertices[1] = uv_island.lookup_or_create(UVVertex(mesh_data, loop_2));
@ -508,7 +502,7 @@ static std::optional<UVBorderCorner> sharpest_border_corner(UVIsland &island)
/** The inner edge of a fan. */ /** The inner edge of a fan. */
struct FanSegment { struct FanSegment {
const int primitive_index; const int primitive_index;
const MLoopTri *primitive; const MLoopTri *lt_primitive;
/* UVs order are already applied. So `uvs[0]` matches `primitive->vertices[vert_order[0]]`. */ /* UVs order are already applied. So `uvs[0]` matches `primitive->vertices[vert_order[0]]`. */
float2 uvs[3]; float2 uvs[3];
int vert_order[3]; int vert_order[3];
@ -519,25 +513,25 @@ struct FanSegment {
FanSegment(const MeshData &mesh_data, FanSegment(const MeshData &mesh_data,
const int primitive_index, const int primitive_index,
const MLoopTri *primitive, const MLoopTri *lt_primitive,
int vertex) int vertex)
: primitive_index(primitive_index), primitive(primitive) : primitive_index(primitive_index), lt_primitive(lt_primitive)
{ {
flags.found = false; flags.found = false;
/* Reorder so the first edge starts with the given vertex. */ /* Reorder so the first edge starts with the given vertex. */
if (mesh_data.corner_verts[primitive->tri[1]] == vertex) { if (mesh_data.corner_verts[lt_primitive->tri[1]] == vertex) {
vert_order[0] = 1; vert_order[0] = 1;
vert_order[1] = 2; vert_order[1] = 2;
vert_order[2] = 0; vert_order[2] = 0;
} }
else if (mesh_data.corner_verts[primitive->tri[2]] == vertex) { else if (mesh_data.corner_verts[lt_primitive->tri[2]] == vertex) {
vert_order[0] = 2; vert_order[0] = 2;
vert_order[1] = 0; vert_order[1] = 0;
vert_order[2] = 1; vert_order[2] = 1;
} }
else { else {
BLI_assert(mesh_data.corner_verts[primitive->tri[0]] == vertex); BLI_assert(mesh_data.corner_verts[lt_primitive->tri[0]] == vertex);
vert_order[0] = 0; vert_order[0] = 0;
vert_order[1] = 1; vert_order[1] = 1;
vert_order[2] = 2; vert_order[2] = 2;
@ -547,9 +541,9 @@ struct FanSegment {
void print_debug(const MeshData &mesh_data) const void print_debug(const MeshData &mesh_data) const
{ {
std::stringstream ss; std::stringstream ss;
ss << " v1:" << mesh_data.corner_verts[primitive->tri[vert_order[0]]]; ss << " v1:" << mesh_data.corner_verts[lt_primitive->tri[vert_order[0]]];
ss << " v2:" << mesh_data.corner_verts[primitive->tri[vert_order[1]]]; ss << " v2:" << mesh_data.corner_verts[lt_primitive->tri[vert_order[1]]];
ss << " v3:" << mesh_data.corner_verts[primitive->tri[vert_order[2]]]; ss << " v3:" << mesh_data.corner_verts[lt_primitive->tri[vert_order[2]]];
ss << " uv1:" << uvs[0]; ss << " uv1:" << uvs[0];
ss << " uv2:" << uvs[1]; ss << " uv2:" << uvs[1];
ss << " uv3:" << uvs[2]; ss << " uv3:" << uvs[2];
@ -590,14 +584,14 @@ struct Fan {
continue; continue;
} }
const MLoopTri &other_looptri = mesh_data.looptris[other_primitive_i]; const MLoopTri &other_lt = mesh_data.looptris[other_primitive_i];
for (const int edge_i : mesh_data.primitive_to_edge_map[other_primitive_i]) { for (const int edge_i : mesh_data.primitive_to_edge_map[other_primitive_i]) {
const MeshEdge &edge = mesh_data.edges[edge_i]; const MeshEdge &edge = mesh_data.edges[edge_i];
if (edge_i == current_edge || (edge.vert1 != vertex && edge.vert2 != vertex)) { if (edge_i == current_edge || (edge.vert1 != vertex && edge.vert2 != vertex)) {
continue; continue;
} }
segments.append(FanSegment(mesh_data, other_primitive_i, &other_looptri, vertex)); segments.append(FanSegment(mesh_data, other_primitive_i, &other_lt, vertex));
current_edge = edge_i; current_edge = edge_i;
previous_primitive = other_primitive_i; previous_primitive = other_primitive_i;
stop = true; stop = true;
@ -638,9 +632,9 @@ struct Fan {
void init_uv_coordinates(const MeshData &mesh_data, UVVertex &uv_vertex) void init_uv_coordinates(const MeshData &mesh_data, UVVertex &uv_vertex)
{ {
for (FanSegment &fan_edge : segments) { for (FanSegment &fan_edge : segments) {
int other_v = mesh_data.corner_verts[fan_edge.primitive->tri[fan_edge.vert_order[0]]]; int other_v = mesh_data.corner_verts[fan_edge.lt_primitive->tri[fan_edge.vert_order[0]]];
if (other_v == uv_vertex.vertex) { if (other_v == uv_vertex.vertex) {
other_v = mesh_data.corner_verts[fan_edge.primitive->tri[fan_edge.vert_order[1]]]; other_v = mesh_data.corner_verts[fan_edge.lt_primitive->tri[fan_edge.vert_order[1]]];
} }
for (UVEdge *edge : uv_vertex.uv_edges) { for (UVEdge *edge : uv_vertex.uv_edges) {
@ -668,7 +662,7 @@ struct Fan {
bool contains_vertex_on_outside(const MeshData &mesh_data, const int vertex_index) const bool contains_vertex_on_outside(const MeshData &mesh_data, const int vertex_index) const
{ {
for (const FanSegment &segment : segments) { for (const FanSegment &segment : segments) {
int v2 = mesh_data.corner_verts[segment.primitive->tri[segment.vert_order[1]]]; int v2 = mesh_data.corner_verts[segment.lt_primitive->tri[segment.vert_order[1]]];
if (vertex_index == v2) { if (vertex_index == v2) {
return true; return true;
} }
@ -685,8 +679,8 @@ struct Fan {
{ {
int current_vert = from_vertex; int current_vert = from_vertex;
for (FanSegment *segment : path) { for (FanSegment *segment : path) {
int v1 = mesh_data.corner_verts[segment->primitive->tri[segment->vert_order[1]]]; int v1 = mesh_data.corner_verts[segment->lt_primitive->tri[segment->vert_order[1]]];
int v2 = mesh_data.corner_verts[segment->primitive->tri[segment->vert_order[2]]]; int v2 = mesh_data.corner_verts[segment->lt_primitive->tri[segment->vert_order[2]]];
if (!ELEM(current_vert, v1, v2)) { if (!ELEM(current_vert, v1, v2)) {
return false; return false;
} }
@ -717,7 +711,7 @@ struct Fan {
while (true) { while (true) {
FanSegment *segment = edge_order[index]; FanSegment *segment = edge_order[index];
int v2 = int v2 =
mesh_data.corner_verts[segment->primitive->tri[segment->vert_order[from_vert_order]]]; mesh_data.corner_verts[segment->lt_primitive->tri[segment->vert_order[from_vert_order]]];
if (v2 == from_vertex) { if (v2 == from_vertex) {
break; break;
} }
@ -728,7 +722,8 @@ struct Fan {
FanSegment *segment = edge_order[index]; FanSegment *segment = edge_order[index];
result.append(segment); result.append(segment);
int v3 = mesh_data.corner_verts[segment->primitive->tri[segment->vert_order[to_vert_order]]]; int v3 =
mesh_data.corner_verts[segment->lt_primitive->tri[segment->vert_order[to_vert_order]]];
if (v3 == to_vertex) { if (v3 == to_vertex) {
break; break;
} }
@ -812,21 +807,21 @@ static void add_uv_primitive_shared_uv_edge(const MeshData &mesh_data,
const int mesh_primitive_i) const int mesh_primitive_i)
{ {
UVPrimitive prim1(mesh_primitive_i); UVPrimitive prim1(mesh_primitive_i);
const MLoopTri &looptri = mesh_data.looptris[mesh_primitive_i]; const MLoopTri &lt = mesh_data.looptris[mesh_primitive_i];
const int other_vert_i = primitive_get_other_uv_vertex( const int other_vert_i = primitive_get_other_uv_vertex(
mesh_data, looptri, connected_vert_1->vertex, connected_vert_2->vertex); mesh_data, lt, connected_vert_1->vertex, connected_vert_2->vertex);
UVVertex vert_template; UVVertex vert_template;
vert_template.uv = uv_unconnected; vert_template.uv = uv_unconnected;
vert_template.vertex = other_vert_i; vert_template.vertex = other_vert_i;
UVVertex *vert_ptr = island.lookup_or_create(vert_template); UVVertex *vert_ptr = island.lookup_or_create(vert_template);
const int loop_1 = get_uv_loop(mesh_data, looptri, connected_vert_1->vertex); const int loop_1 = get_uv_loop(mesh_data, lt, connected_vert_1->vertex);
vert_template.uv = connected_vert_1->uv; vert_template.uv = connected_vert_1->uv;
vert_template.vertex = mesh_data.corner_verts[loop_1]; vert_template.vertex = mesh_data.corner_verts[loop_1];
UVVertex *vert_1_ptr = island.lookup_or_create(vert_template); UVVertex *vert_1_ptr = island.lookup_or_create(vert_template);
const int loop_2 = get_uv_loop(mesh_data, looptri, connected_vert_2->vertex); const int loop_2 = get_uv_loop(mesh_data, lt, connected_vert_2->vertex);
vert_template.uv = connected_vert_2->uv; vert_template.uv = connected_vert_2->uv;
vert_template.vertex = mesh_data.corner_verts[loop_2]; vert_template.vertex = mesh_data.corner_verts[loop_2];
UVVertex *vert_2_ptr = island.lookup_or_create(vert_template); UVVertex *vert_2_ptr = island.lookup_or_create(vert_template);
@ -862,9 +857,9 @@ static int find_fill_primitive(const MeshData &mesh_data, UVBorderCorner &corner
const MeshEdge &edge = mesh_data.edges[edge_i]; const MeshEdge &edge = mesh_data.edges[edge_i];
if (corner.first->edge->has_same_vertices(edge)) { if (corner.first->edge->has_same_vertices(edge)) {
for (const int primitive_i : mesh_data.edge_to_primitive_map[edge_i]) { for (const int primitive_i : mesh_data.edge_to_primitive_map[edge_i]) {
const MLoopTri &looptri = mesh_data.looptris[primitive_i]; const MLoopTri &lt = mesh_data.looptris[primitive_i];
const int other_vert = primitive_get_other_uv_vertex( const int other_vert = primitive_get_other_uv_vertex(
mesh_data, looptri, edge.vert1, edge.vert2); mesh_data, lt, edge.vert1, edge.vert2);
if (other_vert == corner.second->get_uv_vertex(1)->vertex) { if (other_vert == corner.second->get_uv_vertex(1)->vertex) {
return primitive_i; return primitive_i;
} }
@ -927,7 +922,7 @@ static void extend_at_vert(const MeshData &mesh_data,
* When all edges are already added and its winding solution contains one segment to be added, * When all edges are already added and its winding solution contains one segment to be added,
* the segment should be split into two segments in order one for both sides. * the segment should be split into two segments in order one for both sides.
* *
* Although the fill_primitive can fill the missing segment it could lead to a squashed * Although the lt_fill_primitive can fill the missing segment it could lead to a squashed
* triangle when the corner angle is near 180 degrees. In order to fix this we will * triangle when the corner angle is near 180 degrees. In order to fix this we will
* always add two segments both using the same fill primitive. * always add two segments both using the same fill primitive.
*/ */
@ -992,9 +987,9 @@ static void extend_at_vert(const MeshData &mesh_data,
FanSegment &segment = *winding_solution[segment_index]; FanSegment &segment = *winding_solution[segment_index];
const int fill_primitive_i = segment.primitive_index; const int fill_primitive_i = segment.primitive_index;
const MLoopTri &fill_primitive = mesh_data.looptris[fill_primitive_i]; const MLoopTri &lt_fill_primitive = mesh_data.looptris[fill_primitive_i];
const int other_prim_vertex = primitive_get_other_uv_vertex( const int other_prim_vertex = primitive_get_other_uv_vertex(
mesh_data, fill_primitive, uv_vertex->vertex, shared_edge_vertex); mesh_data, lt_fill_primitive, uv_vertex->vertex, shared_edge_vertex);
UVVertex uv_vertex_template; UVVertex uv_vertex_template;
uv_vertex_template.vertex = uv_vertex->vertex; uv_vertex_template.vertex = uv_vertex->vertex;
@ -1321,10 +1316,10 @@ bool UVPrimitive::has_shared_edge(const UVPrimitive &other) const
bool UVPrimitive::has_shared_edge(const MeshData &mesh_data, const int primitive_i) const bool UVPrimitive::has_shared_edge(const MeshData &mesh_data, const int primitive_i) const
{ {
for (const UVEdge *uv_edge : edges) { for (const UVEdge *uv_edge : edges) {
const MLoopTri &primitive = mesh_data.looptris[primitive_i]; const MLoopTri &lt_primitive = mesh_data.looptris[primitive_i];
int loop_1 = primitive.tri[2]; int loop_1 = lt_primitive.tri[2];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
int loop_2 = primitive.tri[i]; int loop_2 = lt_primitive.tri[i];
if (uv_edge->has_shared_edge(mesh_data.uv_map, loop_1, loop_2)) { if (uv_edge->has_shared_edge(mesh_data.uv_map, loop_1, loop_2)) {
return true; return true;
} }
@ -1337,8 +1332,8 @@ bool UVPrimitive::has_shared_edge(const MeshData &mesh_data, const int primitive
const UVVertex *UVPrimitive::get_uv_vertex(const MeshData &mesh_data, const UVVertex *UVPrimitive::get_uv_vertex(const MeshData &mesh_data,
const uint8_t mesh_vert_index) const const uint8_t mesh_vert_index) const
{ {
const MLoopTri &looptri = mesh_data.looptris[this->primitive_i]; const MLoopTri &lt = mesh_data.looptris[this->primitive_i];
const int mesh_vertex = mesh_data.corner_verts[looptri.tri[mesh_vert_index]]; const int mesh_vertex = mesh_data.corner_verts[lt.tri[mesh_vert_index]];
for (const UVEdge *uv_edge : edges) { for (const UVEdge *uv_edge : edges) {
for (const UVVertex *uv_vert : uv_edge->vertices) { for (const UVVertex *uv_vert : uv_edge->vertices) {
if (uv_vert->vertex == mesh_vertex) { if (uv_vert->vertex == mesh_vertex) {
@ -1528,9 +1523,9 @@ static void add_uv_island(const MeshData &mesh_data,
{ {
for (const VectorList<UVPrimitive>::UsedVector &uv_primitives : uv_island.uv_primitives) { for (const VectorList<UVPrimitive>::UsedVector &uv_primitives : uv_island.uv_primitives) {
for (const UVPrimitive &uv_primitive : uv_primitives) { for (const UVPrimitive &uv_primitive : uv_primitives) {
const MLoopTri &looptri = mesh_data.looptris[uv_primitive.primitive_i]; const MLoopTri &lt = mesh_data.looptris[uv_primitive.primitive_i];
rctf uv_bounds = primitive_uv_bounds(looptri, mesh_data.uv_map); rctf uv_bounds = primitive_uv_bounds(lt, mesh_data.uv_map);
rcti buffer_bounds; rcti buffer_bounds;
buffer_bounds.xmin = max_ii( buffer_bounds.xmin = max_ii(
floor((uv_bounds.xmin - tile.udim_offset.x) * tile.mask_resolution.x), 0); floor((uv_bounds.xmin - tile.udim_offset.x) * tile.mask_resolution.x), 0);
@ -1547,9 +1542,9 @@ static void add_uv_island(const MeshData &mesh_data,
for (int x = buffer_bounds.xmin; x < buffer_bounds.xmax + 1; x++) { for (int x = buffer_bounds.xmin; x < buffer_bounds.xmax + 1; x++) {
float2 uv(float(x) / tile.mask_resolution.x, float(y) / tile.mask_resolution.y); float2 uv(float(x) / tile.mask_resolution.x, float(y) / tile.mask_resolution.y);
float3 weights; float3 weights;
barycentric_weights_v2(mesh_data.uv_map[looptri.tri[0]], barycentric_weights_v2(mesh_data.uv_map[lt.tri[0]],
mesh_data.uv_map[looptri.tri[1]], mesh_data.uv_map[lt.tri[1]],
mesh_data.uv_map[looptri.tri[2]], mesh_data.uv_map[lt.tri[2]],
uv + tile.udim_offset, uv + tile.udim_offset,
weights); weights);
if (!barycentric_inside_triangle_v2(weights)) { if (!barycentric_inside_triangle_v2(weights)) {

@ -133,7 +133,7 @@ bool BKE_shrinkwrap_init_tree(
return false; return false;
} }
data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, BVHTREE_FROM_LOOPTRI, 4); data->bvh = BKE_bvhtree_from_mesh_get(&data->treeData, mesh, BVHTREE_FROM_LOOPTRIS, 4);
if (data->bvh == nullptr) { if (data->bvh == nullptr) {
return false; return false;
@ -226,7 +226,7 @@ static std::unique_ptr<ShrinkwrapBoundaryData> shrinkwrap_build_boundary_data(Me
data->edge_is_boundary = std::move(edge_is_boundary); data->edge_is_boundary = std::move(edge_is_boundary);
/* Build the boundary looptri bitmask. */ /* Build the boundary looptris bit-mask. */
const blender::Span<MLoopTri> looptris = mesh->looptris(); const blender::Span<MLoopTri> looptris = mesh->looptris();
blender::BitVector<> looptri_has_boundary(looptris.size(), false); blender::BitVector<> looptri_has_boundary(looptris.size(), false);
@ -995,21 +995,25 @@ static void target_project_edge(const ShrinkwrapTreeData *tree,
} }
/* Target normal projection BVH callback - based on mesh_looptri_nearest_point. */ /* Target normal projection BVH callback - based on mesh_looptri_nearest_point. */
static void mesh_looptri_target_project(void *userdata, static void mesh_looptris_target_project(void *userdata,
int index, int index,
const float co[3], const float co[3],
BVHTreeNearest *nearest) BVHTreeNearest *nearest)
{ {
using namespace blender; using namespace blender;
const ShrinkwrapTreeData *tree = (ShrinkwrapTreeData *)userdata; const ShrinkwrapTreeData *tree = (ShrinkwrapTreeData *)userdata;
const BVHTreeFromMesh *data = &tree->treeData; const BVHTreeFromMesh *data = &tree->treeData;
const MLoopTri *lt = &data->looptris[index]; const MLoopTri *lt = &data->looptris[index];
const int tri_verts[3] = {data->corner_verts[lt->tri[0]], const int tri_verts[3] = {
data->corner_verts[lt->tri[1]], data->corner_verts[lt->tri[0]],
data->corner_verts[lt->tri[2]]}; data->corner_verts[lt->tri[1]],
const float *vtri_co[3] = {data->vert_positions[tri_verts[0]], data->corner_verts[lt->tri[2]],
data->vert_positions[tri_verts[1]], };
data->vert_positions[tri_verts[2]]}; const float *vtri_co[3] = {
data->vert_positions[tri_verts[0]],
data->vert_positions[tri_verts[1]],
data->vert_positions[tri_verts[2]],
};
float raw_hit_co[3], hit_co[3], hit_no[3], dist_sq, vtri_no[3][3]; float raw_hit_co[3], hit_co[3], hit_no[3], dist_sq, vtri_no[3][3];
/* First find the closest point and bail out if it's worse than the current solution. */ /* First find the closest point and bail out if it's worse than the current solution. */
@ -1066,7 +1070,7 @@ void BKE_shrinkwrap_find_nearest_surface(ShrinkwrapTreeData *tree,
#endif #endif
BLI_bvhtree_find_nearest_ex( BLI_bvhtree_find_nearest_ex(
tree->bvh, co, nearest, mesh_looptri_target_project, tree, BVH_NEAREST_OPTIMAL_ORDER); tree->bvh, co, nearest, mesh_looptris_target_project, tree, BVH_NEAREST_OPTIMAL_ORDER);
#ifdef TRACE_TARGET_PROJECT #ifdef TRACE_TARGET_PROJECT
printf("====== TARGET PROJECT END: %d %g ======\n\n", nearest->index, nearest->dist_sq); printf("====== TARGET PROJECT END: %d %g ======\n\n", nearest->index, nearest->dist_sq);
@ -1165,21 +1169,21 @@ void BKE_shrinkwrap_compute_smooth_normal(const ShrinkwrapTreeData *tree,
float r_no[3]) float r_no[3])
{ {
const BVHTreeFromMesh *treeData = &tree->treeData; const BVHTreeFromMesh *treeData = &tree->treeData;
const MLoopTri *tri = &treeData->looptris[looptri_idx]; const MLoopTri *lt = &treeData->looptris[looptri_idx];
const int face_i = tree->mesh->looptri_faces()[looptri_idx]; const int face_i = tree->mesh->looptri_faces()[looptri_idx];
/* Interpolate smooth normals if enabled. */ /* Interpolate smooth normals if enabled. */
if (!(tree->sharp_faces && tree->sharp_faces[face_i])) { if (!(tree->sharp_faces && tree->sharp_faces[face_i])) {
const int vert_indices[3] = {treeData->corner_verts[tri->tri[0]], const int vert_indices[3] = {treeData->corner_verts[lt->tri[0]],
treeData->corner_verts[tri->tri[1]], treeData->corner_verts[lt->tri[1]],
treeData->corner_verts[tri->tri[2]]}; treeData->corner_verts[lt->tri[2]]};
float w[3], no[3][3], tmp_co[3]; float w[3], no[3][3], tmp_co[3];
/* Custom and auto smooth split normals. */ /* Custom and auto smooth split normals. */
if (!tree->corner_normals.is_empty()) { if (!tree->corner_normals.is_empty()) {
copy_v3_v3(no[0], tree->corner_normals[tri->tri[0]]); copy_v3_v3(no[0], tree->corner_normals[lt->tri[0]]);
copy_v3_v3(no[1], tree->corner_normals[tri->tri[1]]); copy_v3_v3(no[1], tree->corner_normals[lt->tri[1]]);
copy_v3_v3(no[2], tree->corner_normals[tri->tri[2]]); copy_v3_v3(no[2], tree->corner_normals[lt->tri[2]]);
} }
/* Ordinary vertex normals. */ /* Ordinary vertex normals. */
else { else {
@ -1215,7 +1219,7 @@ void BKE_shrinkwrap_compute_smooth_normal(const ShrinkwrapTreeData *tree,
else if (!tree->face_normals.is_empty()) { else if (!tree->face_normals.is_empty()) {
copy_v3_v3(r_no, tree->face_normals[face_i]); copy_v3_v3(r_no, tree->face_normals[face_i]);
} }
/* Finally fallback to the looptri normal. */ /* Finally fallback to the looptris normal. */
else { else {
copy_v3_v3(r_no, hit_no); copy_v3_v3(r_no, hit_no);
} }

@ -2777,11 +2777,11 @@ static void mesh_faces_to_scratch(Object *ob)
/* Allocate and copy faces. */ /* Allocate and copy faces. */
sb->scratch->bodyface_num = poly_to_tri_count(mesh->faces_num, mesh->totloop); sb->scratch->bodyface_num = poly_to_tri_count(mesh->faces_num, mesh->totloop);
blender::Array<MLoopTri> looptri(sb->scratch->bodyface_num); blender::Array<MLoopTri> looptris(sb->scratch->bodyface_num);
blender::bke::mesh::looptris_calc( blender::bke::mesh::looptris_calc(
mesh->vert_positions(), mesh->faces(), mesh->corner_verts(), looptri); mesh->vert_positions(), mesh->faces(), mesh->corner_verts(), looptris);
lt = looptri.data(); lt = looptris.data();
bodyface = sb->scratch->bodyface = static_cast<BodyFace *>( bodyface = sb->scratch->bodyface = static_cast<BodyFace *>(
MEM_mallocN(sizeof(BodyFace) * sb->scratch->bodyface_num, "SB_body_Faces")); MEM_mallocN(sizeof(BodyFace) * sb->scratch->bodyface_num, "SB_body_Faces"));

@ -82,7 +82,7 @@ struct PBVH_GPU_Args {
VArraySpan<bool> hide_poly; VArraySpan<bool> hide_poly;
Span<MLoopTri> mlooptri; Span<MLoopTri> looptris;
Span<int> looptri_faces; Span<int> looptri_faces;
/* BMesh. */ /* BMesh. */

@ -287,10 +287,10 @@ static void extract_range_iter_looptri_mesh(void *__restrict userdata,
const ExtractorIterData *data = static_cast<ExtractorIterData *>(userdata); const ExtractorIterData *data = static_cast<ExtractorIterData *>(userdata);
const MeshRenderData &mr = *data->mr; const MeshRenderData &mr = *data->mr;
const MLoopTri *mlt = &((const MLoopTri *)data->elems)[iter]; const MLoopTri *lt = &((const MLoopTri *)data->elems)[iter];
for (const ExtractorRunData &run_data : data->extractors) { for (const ExtractorRunData &run_data : data->extractors) {
run_data.extractor->iter_looptri_mesh( run_data.extractor->iter_looptri_mesh(
mr, mlt, iter, POINTER_OFFSET(extract_data, run_data.data_offset)); mr, lt, iter, POINTER_OFFSET(extract_data, run_data.data_offset));
} }
} }

@ -592,7 +592,7 @@ static void mesh_batch_cache_init(Object *object, Mesh *mesh)
if (cache->is_editmode == false) { if (cache->is_editmode == false) {
// cache->edge_len = mesh_render_edges_len_get(mesh); // cache->edge_len = mesh_render_edges_len_get(mesh);
// cache->tri_len = mesh_render_looptri_len_get(mesh); // cache->tri_len = mesh_render_looptris_len_get(mesh);
// cache->face_len = mesh_render_faces_len_get(mesh); // cache->face_len = mesh_render_faces_len_get(mesh);
// cache->vert_len = mesh_render_verts_len_get(mesh); // cache->vert_len = mesh_render_verts_len_get(mesh);
} }

@ -425,13 +425,13 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region,
* without having to add an extra loop. */ * without having to add an extra loop. */
int looptri_index = 0; int looptri_index = 0;
BM_ITER_MESH_INDEX (f, &iter, em->bm, BM_FACES_OF_MESH, i) { BM_ITER_MESH_INDEX (f, &iter, em->bm, BM_FACES_OF_MESH, i) {
const int f_looptri_len = f->len - 2; const int f_looptris_len = f->len - 2;
if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { if (BM_elem_flag_test(f, BM_ELEM_SELECT)) {
n = 0; n = 0;
area = 0; area = 0;
zero_v3(vmid); zero_v3(vmid);
BMLoop *(*l)[3] = &em->looptris[looptri_index]; BMLoop *(*l)[3] = &em->looptris[looptri_index];
for (int j = 0; j < f_looptri_len; j++) { for (int j = 0; j < f_looptris_len; j++) {
if (use_coords) { if (use_coords) {
copy_v3_v3(v1, vert_coords[BM_elem_index_get(l[j][0]->v)]); copy_v3_v3(v1, vert_coords[BM_elem_index_get(l[j][0]->v)]);
@ -477,7 +477,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region,
DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col); DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col);
} }
looptri_index += f_looptri_len; looptri_index += f_looptris_len;
} }
} }

@ -127,7 +127,7 @@ void extract_data_vert_faces(const PBVH_GPU_Args &args, const Span<T> attribute,
using Converter = AttributeConverter<T>; using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType; using VBOType = typename Converter::VBOType;
const Span<int> corner_verts = args.corner_verts; const Span<int> corner_verts = args.corner_verts;
const Span<MLoopTri> looptris = args.mlooptri; const Span<MLoopTri> looptris = args.looptris;
const Span<int> looptri_faces = args.looptri_faces; const Span<int> looptri_faces = args.looptri_faces;
const Span<bool> hide_poly = args.hide_poly; const Span<bool> hide_poly = args.hide_poly;
@ -170,7 +170,7 @@ void extract_data_corner_faces(const PBVH_GPU_Args &args, const Span<T> attribut
using Converter = AttributeConverter<T>; using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType; using VBOType = typename Converter::VBOType;
const Span<MLoopTri> looptris = args.mlooptri; const Span<MLoopTri> looptris = args.looptris;
const Span<int> looptri_faces = args.looptri_faces; const Span<int> looptri_faces = args.looptri_faces;
const Span<bool> hide_poly = args.hide_poly; const Span<bool> hide_poly = args.hide_poly;
@ -460,7 +460,7 @@ struct PBVHBatches {
} }
else { else {
for (const int i : IndexRange(3)) { for (const int i : IndexRange(3)) {
const int vert = args.corner_verts[args.mlooptri[looptri_i].tri[i]]; const int vert = args.corner_verts[args.looptris[looptri_i].tri[i]];
*data = normal_float_to_short(args.vert_normals[vert]); *data = normal_float_to_short(args.vert_normals[vert]);
data++; data++;
} }
@ -685,7 +685,7 @@ struct PBVHBatches {
ATTR_DOMAIN_POINT)) { ATTR_DOMAIN_POINT)) {
const VArraySpan<float> mask_span(mask); const VArraySpan<float> mask_span(mask);
const Span<int> corner_verts = args.corner_verts; const Span<int> corner_verts = args.corner_verts;
const Span<MLoopTri> looptris = args.mlooptri; const Span<MLoopTri> looptris = args.looptris;
const Span<int> looptri_faces = args.looptri_faces; const Span<int> looptri_faces = args.looptri_faces;
const Span<bool> hide_poly = args.hide_poly; const Span<bool> hide_poly = args.hide_poly;
@ -1045,7 +1045,7 @@ struct PBVHBatches {
} }
const int3 real_edges = bke::mesh::looptri_get_real_edges( const int3 real_edges = bke::mesh::looptri_get_real_edges(
edges, args.corner_verts, args.corner_edges, args.mlooptri[looptri_i]); edges, args.corner_verts, args.corner_edges, args.looptris[looptri_i]);
if (real_edges[0] != -1) { if (real_edges[0] != -1) {
edge_count++; edge_count++;
@ -1069,7 +1069,7 @@ struct PBVHBatches {
} }
const int3 real_edges = bke::mesh::looptri_get_real_edges( const int3 real_edges = bke::mesh::looptri_get_real_edges(
edges, args.corner_verts, args.corner_edges, args.mlooptri[looptri_i]); edges, args.corner_verts, args.corner_edges, args.looptris[looptri_i]);
if (real_edges[0] != -1) { if (real_edges[0] != -1) {
GPU_indexbuf_add_line_verts(&elb_lines, vertex_i, vertex_i + 1); GPU_indexbuf_add_line_verts(&elb_lines, vertex_i, vertex_i + 1);

@ -178,7 +178,7 @@ BLI_INLINE const float *bm_face_no_get(const MeshRenderData &mr, const BMFace *e
using ExtractTriBMeshFn = void(const MeshRenderData &mr, BMLoop **elt, int elt_index, void *data); using ExtractTriBMeshFn = void(const MeshRenderData &mr, BMLoop **elt, int elt_index, void *data);
using ExtractTriMeshFn = void(const MeshRenderData &mr, using ExtractTriMeshFn = void(const MeshRenderData &mr,
const MLoopTri *mlt, const MLoopTri *lt,
int elt_index, int elt_index,
void *data); void *data);
using ExtractFaceBMeshFn = void(const MeshRenderData &mr, using ExtractFaceBMeshFn = void(const MeshRenderData &mr,

@ -55,7 +55,7 @@ static void extract_edituv_tris_iter_looptri_bm(const MeshRenderData & /*mr*/,
} }
static void extract_edituv_tris_iter_looptri_mesh(const MeshRenderData &mr, static void extract_edituv_tris_iter_looptri_mesh(const MeshRenderData &mr,
const MLoopTri *mlt, const MLoopTri *lt,
const int elt_index, const int elt_index,
void *_data) void *_data)
{ {
@ -65,7 +65,7 @@ static void extract_edituv_tris_iter_looptri_mesh(const MeshRenderData &mr,
const bool mp_hidden = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) : true; const bool mp_hidden = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) : true;
const bool mp_select = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) : false; const bool mp_select = (efa) ? BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) : false;
edituv_tri_add(data, mp_hidden, mp_select, mlt->tri[0], mlt->tri[1], mlt->tri[2]); edituv_tri_add(data, mp_hidden, mp_select, lt->tri[0], lt->tri[1], lt->tri[2]);
} }
static void extract_edituv_tris_finish(const MeshRenderData & /*mr*/, static void extract_edituv_tris_finish(const MeshRenderData & /*mr*/,

@ -126,7 +126,7 @@ static void extract_lines_adjacency_iter_looptri_bm(const MeshRenderData & /*mr*
} }
static void extract_lines_adjacency_iter_looptri_mesh(const MeshRenderData &mr, static void extract_lines_adjacency_iter_looptri_mesh(const MeshRenderData &mr,
const MLoopTri *mlt, const MLoopTri *lt,
const int elt_index, const int elt_index,
void *_data) void *_data)
{ {
@ -136,12 +136,12 @@ static void extract_lines_adjacency_iter_looptri_mesh(const MeshRenderData &mr,
if (hidden) { if (hidden) {
return; return;
} }
lines_adjacency_triangle(mr.corner_verts[mlt->tri[0]], lines_adjacency_triangle(mr.corner_verts[lt->tri[0]],
mr.corner_verts[mlt->tri[1]], mr.corner_verts[lt->tri[1]],
mr.corner_verts[mlt->tri[2]], mr.corner_verts[lt->tri[2]],
mlt->tri[0], lt->tri[0],
mlt->tri[1], lt->tri[1],
mlt->tri[2], lt->tri[2],
data); data);
} }

@ -78,9 +78,9 @@ static void extract_tris_iter_face_mesh(const MeshRenderData &mr,
int tri_len = face.size() - 2; int tri_len = face.size() - 2;
for (int offs = 0; offs < tri_len; offs++) { for (int offs = 0; offs < tri_len; offs++) {
const MLoopTri *mlt = &mr.looptris[tri_first_index_real + offs]; const MLoopTri *lt = &mr.looptris[tri_first_index_real + offs];
int tri_index = tri_first_index + offs; int tri_index = tri_first_index + offs;
GPU_indexbuf_set_tri_verts(elb, tri_index, mlt->tri[0], mlt->tri[1], mlt->tri[2]); GPU_indexbuf_set_tri_verts(elb, tri_index, lt->tri[0], lt->tri[1], lt->tri[2]);
} }
} }
@ -188,18 +188,18 @@ static void extract_tris_single_mat_iter_looptri_bm(const MeshRenderData & /*mr*
} }
static void extract_tris_single_mat_iter_looptri_mesh(const MeshRenderData &mr, static void extract_tris_single_mat_iter_looptri_mesh(const MeshRenderData &mr,
const MLoopTri *mlt, const MLoopTri *lt,
const int mlt_index, const int lt_index,
void *_data) void *_data)
{ {
GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(_data); GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(_data);
const int face_i = mr.looptri_faces[mlt_index]; const int face_i = mr.looptri_faces[lt_index];
const bool hidden = mr.use_hide && !mr.hide_poly.is_empty() && mr.hide_poly[face_i]; const bool hidden = mr.use_hide && !mr.hide_poly.is_empty() && mr.hide_poly[face_i];
if (hidden) { if (hidden) {
GPU_indexbuf_set_tri_restart(elb, mlt_index); GPU_indexbuf_set_tri_restart(elb, lt_index);
} }
else { else {
GPU_indexbuf_set_tri_verts(elb, mlt_index, mlt->tri[0], mlt->tri[1], mlt->tri[2]); GPU_indexbuf_set_tri_verts(elb, lt_index, lt->tri[0], lt->tri[1], lt->tri[2]);
} }
} }

@ -216,7 +216,7 @@ static void statvis_calc_thickness(const MeshRenderData &mr, float *r_thickness)
else { else {
BVHTreeFromMesh treeData = {nullptr}; BVHTreeFromMesh treeData = {nullptr};
BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr.mesh, BVHTREE_FROM_LOOPTRI, 4); BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr.mesh, BVHTREE_FROM_LOOPTRIS, 4);
const Span<MLoopTri> looptris = mr.looptris; const Span<MLoopTri> looptris = mr.looptris;
const Span<int> looptri_faces = mr.looptri_faces; const Span<int> looptri_faces = mr.looptri_faces;
for (const int i : looptris.index_range()) { for (const int i : looptris.index_range()) {
@ -278,15 +278,15 @@ static bool bvh_overlap_cb(void *userdata, int index_a, int index_b, int /*threa
return false; return false;
} }
const MLoopTri *tri_a = &data->looptris[index_a]; const MLoopTri *lt_a = &data->looptris[index_a];
const MLoopTri *tri_b = &data->looptris[index_b]; const MLoopTri *lt_b = &data->looptris[index_b];
const float *tri_a_co[3] = {data->positions[data->corner_verts[tri_a->tri[0]]], const float *tri_a_co[3] = {data->positions[data->corner_verts[lt_a->tri[0]]],
data->positions[data->corner_verts[tri_a->tri[1]]], data->positions[data->corner_verts[lt_a->tri[1]]],
data->positions[data->corner_verts[tri_a->tri[2]]]}; data->positions[data->corner_verts[lt_a->tri[2]]]};
const float *tri_b_co[3] = {data->positions[data->corner_verts[tri_b->tri[0]]], const float *tri_b_co[3] = {data->positions[data->corner_verts[lt_b->tri[0]]],
data->positions[data->corner_verts[tri_b->tri[1]]], data->positions[data->corner_verts[lt_b->tri[1]]],
data->positions[data->corner_verts[tri_b->tri[2]]]}; data->positions[data->corner_verts[lt_b->tri[2]]]};
float ix_pair[2][3]; float ix_pair[2][3];
int verts_shared = 0; int verts_shared = 0;
@ -344,7 +344,7 @@ static void statvis_calc_intersect(const MeshRenderData &mr, float *r_intersect)
uint overlap_len; uint overlap_len;
BVHTreeFromMesh treeData = {nullptr}; BVHTreeFromMesh treeData = {nullptr};
BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr.mesh, BVHTREE_FROM_LOOPTRI, 4); BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr.mesh, BVHTREE_FROM_LOOPTRIS, 4);
BVHTree_OverlapData data = {}; BVHTree_OverlapData data = {};
data.positions = mr.vert_positions; data.positions = mr.vert_positions;

@ -71,7 +71,7 @@ struct LaplacianSystem {
blender::Map<blender::OrderedEdge, int> edgehash; /* edge hash for construction */ blender::Map<blender::OrderedEdge, int> edgehash; /* edge hash for construction */
struct HeatWeighting { struct HeatWeighting {
const MLoopTri *mlooptri; const MLoopTri *looptris;
blender::Span<int> corner_verts; /* needed to find vertices by index */ blender::Span<int> corner_verts; /* needed to find vertices by index */
int verts_num; int verts_num;
int tris_num; int tris_num;
@ -373,7 +373,7 @@ struct BVHCallbackUserData {
static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
{ {
BVHCallbackUserData *data = (BVHCallbackUserData *)userdata; BVHCallbackUserData *data = (BVHCallbackUserData *)userdata;
const MLoopTri *lt = &data->sys->heat.mlooptri[index]; const MLoopTri *lt = &data->sys->heat.looptris[index];
const blender::Span<int> corner_verts = data->sys->heat.corner_verts; const blender::Span<int> corner_verts = data->sys->heat.corner_verts;
float(*verts)[3] = data->sys->heat.verts; float(*verts)[3] = data->sys->heat.verts;
const float *vtri_co[3]; const float *vtri_co[3];
@ -405,7 +405,7 @@ static void bvh_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTr
/* Ray-tracing for vertex to bone/vertex visibility. */ /* Ray-tracing for vertex to bone/vertex visibility. */
static void heat_ray_tree_create(LaplacianSystem *sys) static void heat_ray_tree_create(LaplacianSystem *sys)
{ {
const MLoopTri *looptri = sys->heat.mlooptri; const MLoopTri *looptris = sys->heat.looptris;
const blender::Span<int> corner_verts = sys->heat.corner_verts; const blender::Span<int> corner_verts = sys->heat.corner_verts;
float(*verts)[3] = sys->heat.verts; float(*verts)[3] = sys->heat.verts;
int tris_num = sys->heat.tris_num; int tris_num = sys->heat.tris_num;
@ -417,7 +417,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys)
MEM_callocN(sizeof(MLoopTri *) * verts_num, "HeatVFaces")); MEM_callocN(sizeof(MLoopTri *) * verts_num, "HeatVFaces"));
for (a = 0; a < tris_num; a++) { for (a = 0; a < tris_num; a++) {
const MLoopTri *lt = &looptri[a]; const MLoopTri *lt = &looptris[a];
float bb[6]; float bb[6];
int vtri[3]; int vtri[3];
@ -572,7 +572,7 @@ static void heat_calc_vnormals(LaplacianSystem *sys)
static void heat_laplacian_create(LaplacianSystem *sys) static void heat_laplacian_create(LaplacianSystem *sys)
{ {
const MLoopTri *mlooptri = sys->heat.mlooptri, *lt; const MLoopTri *looptris = sys->heat.looptris, *lt;
const blender::Span<int> corner_verts = sys->heat.corner_verts; const blender::Span<int> corner_verts = sys->heat.corner_verts;
int tris_num = sys->heat.tris_num; int tris_num = sys->heat.tris_num;
int verts_num = sys->heat.verts_num; int verts_num = sys->heat.verts_num;
@ -588,7 +588,7 @@ static void heat_laplacian_create(LaplacianSystem *sys)
laplacian_add_vertex(sys, sys->heat.verts[a], 0); laplacian_add_vertex(sys, sys->heat.verts[a], 0);
} }
for (a = 0, lt = mlooptri; a < tris_num; a++, lt++) { for (a = 0, lt = looptris; a < tris_num; a++, lt++) {
int vtri[3]; int vtri[3];
vtri[0] = corner_verts[lt->tri[0]]; vtri[0] = corner_verts[lt->tri[0]];
vtri[1] = corner_verts[lt->tri[1]]; vtri[1] = corner_verts[lt->tri[1]];
@ -608,7 +608,7 @@ static void heat_system_free(LaplacianSystem *sys)
{ {
BLI_bvhtree_free(sys->heat.bvhtree); BLI_bvhtree_free(sys->heat.bvhtree);
MEM_freeN((void *)sys->heat.vltree); MEM_freeN((void *)sys->heat.vltree);
MEM_freeN((void *)sys->heat.mlooptri); MEM_freeN((void *)sys->heat.looptris);
MEM_freeN(sys->heat.mindist); MEM_freeN(sys->heat.mindist);
MEM_freeN(sys->heat.H); MEM_freeN(sys->heat.H);
@ -642,7 +642,7 @@ void heat_bone_weighting(Object *ob,
const char **error_str) const char **error_str)
{ {
LaplacianSystem *sys; LaplacianSystem *sys;
MLoopTri *mlooptri; MLoopTri *looptris;
float solution, weight; float solution, weight;
int *vertsflipped = nullptr, *mask = nullptr; int *vertsflipped = nullptr, *mask = nullptr;
int a, tris_num, j, bbone, firstsegment, lastsegment; int a, tris_num, j, bbone, firstsegment, lastsegment;
@ -695,13 +695,13 @@ void heat_bone_weighting(Object *ob,
sys = laplacian_system_construct_begin(mesh->totvert, tris_num, 1); sys = laplacian_system_construct_begin(mesh->totvert, tris_num, 1);
sys->heat.tris_num = poly_to_tri_count(mesh->faces_num, mesh->totloop); sys->heat.tris_num = poly_to_tri_count(mesh->faces_num, mesh->totloop);
mlooptri = static_cast<MLoopTri *>( looptris = static_cast<MLoopTri *>(
MEM_mallocN(sizeof(*sys->heat.mlooptri) * sys->heat.tris_num, __func__)); MEM_mallocN(sizeof(*sys->heat.looptris) * sys->heat.tris_num, __func__));
blender::bke::mesh::looptris_calc( blender::bke::mesh::looptris_calc(
vert_positions, faces, corner_verts, {mlooptri, sys->heat.tris_num}); vert_positions, faces, corner_verts, {looptris, sys->heat.tris_num});
sys->heat.mlooptri = mlooptri; sys->heat.looptris = looptris;
sys->heat.corner_verts = corner_verts; sys->heat.corner_verts = corner_verts;
sys->heat.verts_num = mesh->totvert; sys->heat.verts_num = mesh->totvert;
sys->heat.verts = verts; sys->heat.verts = verts;
@ -1603,7 +1603,7 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
mdb->boundisect = static_cast<MDefBoundIsect *(*)[6]>( mdb->boundisect = static_cast<MDefBoundIsect *(*)[6]>(
MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect")); MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect"));
mdb->semibound = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound")); mdb->semibound = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound"));
mdb->bvhtree = BKE_bvhtree_from_mesh_get(&mdb->bvhdata, mdb->cagemesh, BVHTREE_FROM_LOOPTRI, 4); mdb->bvhtree = BKE_bvhtree_from_mesh_get(&mdb->bvhdata, mdb->cagemesh, BVHTREE_FROM_LOOPTRIS, 4);
mdb->inside = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->verts_num, "MDefInside")); mdb->inside = static_cast<int *>(MEM_callocN(sizeof(int) * mdb->verts_num, "MDefInside"));
if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) {

@ -269,7 +269,7 @@ static void try_convert_single_object(Object &curves_ob,
Mesh &surface_me = *static_cast<Mesh *>(surface_ob.data); Mesh &surface_me = *static_cast<Mesh *>(surface_ob.data);
BVHTreeFromMesh surface_bvh; BVHTreeFromMesh surface_bvh;
BKE_bvhtree_from_mesh_get(&surface_bvh, &surface_me, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh, &surface_me, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); });
const Span<float3> positions_cu = curves.positions(); const Span<float3> positions_cu = curves.positions();
@ -605,7 +605,7 @@ static void snap_curves_to_surface_exec_object(Object &curves_ob,
switch (attach_mode) { switch (attach_mode) {
case AttachMode::Nearest: { case AttachMode::Nearest: {
BVHTreeFromMesh surface_bvh; BVHTreeFromMesh surface_bvh;
BKE_bvhtree_from_mesh_get(&surface_bvh, &surface_mesh, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh, &surface_mesh, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); });
threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange curves_range) { threading::parallel_for(curves.curves_range(), 256, [&](const IndexRange curves_range) {
@ -639,11 +639,11 @@ static void snap_curves_to_surface_exec_object(Object &curves_ob,
} }
if (!surface_uv_map.is_empty()) { if (!surface_uv_map.is_empty()) {
const MLoopTri &tri = surface_looptris[looptri_index]; const MLoopTri &lt = surface_looptris[looptri_index];
const float3 bary_coords = bke::mesh_surface_sample::compute_bary_coord_in_triangle( const float3 bary_coords = bke::mesh_surface_sample::compute_bary_coord_in_triangle(
surface_positions, corner_verts, tri, new_first_point_pos_su); surface_positions, corner_verts, lt, new_first_point_pos_su);
const float2 uv = bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords( const float2 uv = bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords(
bary_coords, tri, surface_uv_map); bary_coords, lt, surface_uv_map);
surface_uv_coords[curve_i] = uv; surface_uv_coords[curve_i] = uv;
} }
} }
@ -671,12 +671,12 @@ static void snap_curves_to_surface_exec_object(Object &curves_ob,
continue; continue;
} }
const MLoopTri &looptri = surface_looptris[lookup_result.looptri_index]; const MLoopTri &lt = surface_looptris[lookup_result.looptri_index];
const float3 &bary_coords = lookup_result.bary_weights; const float3 &bary_coords = lookup_result.bary_weights;
const float3 &p0_su = surface_positions[corner_verts[looptri.tri[0]]]; const float3 &p0_su = surface_positions[corner_verts[lt.tri[0]]];
const float3 &p1_su = surface_positions[corner_verts[looptri.tri[1]]]; const float3 &p1_su = surface_positions[corner_verts[lt.tri[1]]];
const float3 &p2_su = surface_positions[corner_verts[looptri.tri[2]]]; const float3 &p2_su = surface_positions[corner_verts[lt.tri[2]]];
float3 new_first_point_pos_su; float3 new_first_point_pos_su;
interp_v3_v3v3v3(new_first_point_pos_su, p0_su, p1_su, p2_su, bary_coords); interp_v3_v3v3v3(new_first_point_pos_su, p0_su, p1_su, p2_su, bary_coords);

@ -225,7 +225,7 @@ static void store_result_geometry(
if (object.mode == OB_MODE_EDIT) { if (object.mode == OB_MODE_EDIT) {
EDBM_mesh_make(&object, scene.toolsettings->selectmode, true); EDBM_mesh_make(&object, scene.toolsettings->selectmode, true);
BKE_editmesh_looptri_and_normals_calc(mesh.edit_mesh); BKE_editmesh_looptris_and_normals_calc(mesh.edit_mesh);
} }
else if (object.mode == OB_MODE_SCULPT) { else if (object.mode == OB_MODE_SCULPT) {
sculpt_paint::undo::geometry_end(&object); sculpt_paint::undo::geometry_end(&object);

@ -112,7 +112,7 @@ bool EDBM_mesh_hide(BMEditMesh *em, bool swap);
bool EDBM_mesh_reveal(BMEditMesh *em, bool select); bool EDBM_mesh_reveal(BMEditMesh *em, bool select);
struct EDBMUpdate_Params { struct EDBMUpdate_Params {
uint calc_looptri : 1; uint calc_looptris : 1;
uint calc_normals : 1; uint calc_normals : 1;
uint is_destructive : 1; uint is_destructive : 1;
}; };
@ -577,12 +577,12 @@ BMBackup EDBM_redo_state_store(BMEditMesh *em);
/** /**
* Restore a BMesh from backup. * Restore a BMesh from backup.
*/ */
void EDBM_redo_state_restore(BMBackup *backup, BMEditMesh *em, bool recalc_looptri) void EDBM_redo_state_restore(BMBackup *backup, BMEditMesh *em, bool recalc_looptris)
ATTR_NONNULL(1, 2); ATTR_NONNULL(1, 2);
/** /**
* Delete the backup, flushing it to an edit-mesh. * Delete the backup, flushing it to an edit-mesh.
*/ */
void EDBM_redo_state_restore_and_free(BMBackup *backup, BMEditMesh *em, bool recalc_looptri) void EDBM_redo_state_restore_and_free(BMBackup *backup, BMEditMesh *em, bool recalc_looptris)
ATTR_NONNULL(1, 2); ATTR_NONNULL(1, 2);
void EDBM_redo_state_free(BMBackup *backup) ATTR_NONNULL(1); void EDBM_redo_state_free(BMBackup *backup) ATTR_NONNULL(1);

@ -78,7 +78,7 @@ static void make_prim_finish(bContext *C,
/* Only recalculate edit-mode tessellation if we are staying in edit-mode. */ /* Only recalculate edit-mode tessellation if we are staying in edit-mode. */
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = !exit_editmode; params.calc_looptris = !exit_editmode;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -347,7 +347,7 @@ static int add_primitive_cube_gizmo_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -210,7 +210,7 @@ static int mesh_set_attribute_exec(bContext *C, wmOperator *op)
changed = true; changed = true;
EDBMUpdate_Params update{}; EDBMUpdate_Params update{};
update.calc_looptri = false; update.calc_looptris = false;
update.calc_normals = false; update.calc_normals = false;
update.is_destructive = false; update.is_destructive = false;
EDBM_update(mesh, &update); EDBM_update(mesh, &update);

@ -61,7 +61,7 @@ void EDBM_automerge(Object *obedit, bool update, const char hflag, const float d
BMO_op_finish(bm, &weldop); BMO_op_finish(bm, &weldop);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
if ((totvert_prev != bm->totvert) && update) { if ((totvert_prev != bm->totvert) && update) {
@ -124,7 +124,7 @@ void EDBM_automerge_and_split(Object *obedit,
if (LIKELY(ok) && update) { if (LIKELY(ok) && update) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -380,7 +380,7 @@ static bool edbm_bevel_calc(wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -430,7 +430,7 @@ static void edbm_bevel_cancel(bContext *C, wmOperator *op)
EDBM_redo_state_restore_and_free(&opdata->ob_store[ob_index].mesh_backup, em, true); EDBM_redo_state_restore_and_free(&opdata->ob_store[ob_index].mesh_backup, em, true);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -386,7 +386,7 @@ static int mesh_bisect_exec(bContext *C, wmOperator *op)
if (EDBM_op_finish(em, &bmop, op, true)) { if (EDBM_op_finish(em, &bmop, op, true)) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -308,7 +308,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -449,7 +449,7 @@ static int edbm_extrude_region_exec(bContext *C, wmOperator *op)
/* This normally happens when pushing undo but modal operators /* This normally happens when pushing undo but modal operators
* like this one don't push undo data until after modal mode is done. */ * like this one don't push undo data until after modal mode is done. */
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -507,7 +507,7 @@ static int edbm_extrude_context_exec(bContext *C, wmOperator *op)
/* This normally happens when pushing undo but modal operators /* This normally happens when pushing undo but modal operators
* like this one don't push undo data until after modal mode is done. */ * like this one don't push undo data until after modal mode is done. */
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -559,7 +559,7 @@ static int edbm_extrude_verts_exec(bContext *C, wmOperator *op)
edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT); edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -612,7 +612,7 @@ static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, use_normal_flip); edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, use_normal_flip);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -665,7 +665,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op)
edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT); edbm_extrude_discrete_faces(em, op, BM_ELEM_SELECT);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -904,7 +904,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w
/* This normally happens when pushing undo but modal operators /* This normally happens when pushing undo but modal operators
* like this one don't push undo data until after modal mode is done. */ * like this one don't push undo data until after modal mode is done. */
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params); EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params);

@ -145,7 +145,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -97,7 +97,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -217,7 +217,7 @@ static void edbm_inset_cancel(bContext *C, wmOperator *op)
BMEditMesh *em = BKE_editmesh_from_object(obedit); BMEditMesh *em = BKE_editmesh_from_object(obedit);
EDBM_redo_state_restore_and_free(&opdata->ob_store[ob_index].mesh_backup, em, true); EDBM_redo_state_restore_and_free(&opdata->ob_store[ob_index].mesh_backup, em, true);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -311,7 +311,7 @@ static bool edbm_inset_calc(wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -107,7 +107,7 @@ static void edbm_intersect_select(BMEditMesh *em, Mesh *mesh, bool do_select)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);
@ -968,7 +968,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator * /*op*/)
#endif #endif
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1076,7 +1076,7 @@ static int edbm_face_split_by_edges_exec(bContext *C, wmOperator * /*op*/)
BLI_ghash_free(face_edge_map, nullptr, nullptr); BLI_ghash_free(face_edge_map, nullptr, nullptr);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -186,7 +186,7 @@ struct KnifeUndoFrame {
struct KnifeBVH { struct KnifeBVH {
BVHTree *tree; /* Knife Custom BVH Tree. */ BVHTree *tree; /* Knife Custom BVH Tree. */
BMLoop *(*looptris)[3]; /* Used by #knife_bvh_raycast_cb to store the intersecting looptri. */ BMLoop *(*looptris)[3]; /* Used by #knife_bvh_raycast_cb to store the intersecting triangles. */
float uv[2]; /* Used by #knife_bvh_raycast_cb to store the intersecting uv. */ float uv[2]; /* Used by #knife_bvh_raycast_cb to store the intersecting uv. */
uint ob_index; uint ob_index;
@ -4297,7 +4297,7 @@ static void knifetool_finish_single_post(KnifeTool_OpData * /*kcd*/, Object *ob)
BMEditMesh *em = BKE_editmesh_from_object(ob); BMEditMesh *em = BKE_editmesh_from_object(ob);
EDBM_selectmode_flush(em); EDBM_selectmode_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);

@ -198,7 +198,7 @@ static void ringsel_finish(bContext *C, wmOperator *op)
/* When used in a macro the tessellation will be recalculated anyway, /* When used in a macro the tessellation will be recalculated anyway,
* this is needed here because modifiers depend on updated tessellation, see #45920 */ * this is needed here because modifiers depend on updated tessellation, see #45920 */
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(lcd->ob->data), &params); EDBM_update(static_cast<Mesh *>(lcd->ob->data), &params);

@ -273,7 +273,7 @@ static void mouse_mesh_shortest_path_vert(Scene * /*scene*/,
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -494,7 +494,7 @@ static void mouse_mesh_shortest_path_edge(
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -628,7 +628,7 @@ static void mouse_mesh_shortest_path_face(Scene * /*scene*/,
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -148,7 +148,7 @@ static int edbm_polybuild_transform_at_cursor_invoke(bContext *C,
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params); EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params);
@ -234,7 +234,7 @@ static int edbm_polybuild_delete_at_cursor_invoke(bContext *C,
if (changed) { if (changed) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params); EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params);
@ -401,7 +401,7 @@ static int edbm_polybuild_face_at_cursor_invoke(bContext *C, wmOperator *op, con
if (changed) { if (changed) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params); EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params);
@ -492,7 +492,7 @@ static int edbm_polybuild_split_at_cursor_invoke(bContext *C,
if (changed) { if (changed) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params); EDBM_update(static_cast<Mesh *>(vc.obedit->data), &params);

@ -1103,7 +1103,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, const wmEvent *event)
error_rip_failed = false; error_rip_failed = false;
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -211,7 +211,7 @@ static int edbm_rip_edge_invoke(bContext *C, wmOperator * /*op*/, const wmEvent
BM_mesh_select_mode_flush(bm); BM_mesh_select_mode_flush(bm);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -4350,7 +4350,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op)
if (edbm_deselect_nth(em, &op_params) == true) { if (edbm_deselect_nth(em, &op_params) == true) {
found_active_elt = true; found_active_elt = true;
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -458,7 +458,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
if (changed) { if (changed) {
EDBM_selectmode_flush(em); EDBM_selectmode_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);
@ -484,7 +484,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
} }
EDBM_selectmode_flush(em); EDBM_selectmode_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);
@ -899,7 +899,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
if (changed) { if (changed) {
EDBM_selectmode_flush(em); EDBM_selectmode_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);
@ -925,7 +925,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
} }
EDBM_selectmode_flush(em); EDBM_selectmode_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);
@ -1259,7 +1259,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
if (changed) { if (changed) {
EDBM_selectmode_flush(em); EDBM_selectmode_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);

@ -128,7 +128,7 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op)
seed); seed);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -326,7 +326,7 @@ static int edbm_subdivide_edge_ring_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -391,7 +391,7 @@ static int edbm_unsubdivide_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush(em); EDBM_selectmode_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -521,7 +521,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -655,7 +655,7 @@ static int edbm_delete_loose_exec(bContext *C, wmOperator *op)
EDBM_flag_disable_all(em, BM_ELEM_SELECT); EDBM_flag_disable_all(em, BM_ELEM_SELECT);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -718,7 +718,7 @@ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1013,7 +1013,7 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1093,7 +1093,7 @@ static int edbm_mark_seam_exec(bContext *C, wmOperator *op)
for (uint ob_index = 0; ob_index < objects_len; ob_index++) { for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index]; Object *obedit = objects[ob_index];
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1168,7 +1168,7 @@ static int edbm_mark_sharp_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1304,7 +1304,7 @@ static bool edbm_connect_vert_pair(BMEditMesh *em, Mesh *mesh, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(bm, false); BM_custom_loop_normals_from_vector_layer(bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);
@ -1615,7 +1615,7 @@ static int edbm_vert_connect_path_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(bm, false); BM_custom_loop_normals_from_vector_layer(bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1686,7 +1686,7 @@ static int edbm_vert_connect_concave_exec(bContext *C, wmOperator *op)
continue; continue;
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1746,7 +1746,7 @@ static int edbm_vert_connect_nonplaner_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1817,7 +1817,7 @@ static int edbm_face_make_planar_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1870,7 +1870,7 @@ static bool edbm_edge_split_selected_edges(wmOperator *op, Object *obedit, BMEdi
EDBM_select_flush(em); EDBM_select_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -1945,7 +1945,7 @@ static bool edbm_edge_split_selected_verts(wmOperator *op, Object *obedit, BMEdi
EDBM_select_flush(em); EDBM_select_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2066,7 +2066,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
continue; continue;
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2217,7 +2217,7 @@ static void edbm_flip_normals_custom_loop_normals(Object *obedit, BMEditMesh *em
} }
BM_loop_normal_editdata_array_free(lnors_ed_arr); BM_loop_normal_editdata_array_free(lnors_ed_arr);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2227,7 +2227,7 @@ static void edbm_flip_quad_tessellation(wmOperator *op, Object *obedit, BMEditMe
{ {
if (EDBM_op_callf(em, op, "flip_quad_tessellation faces=%hf", BM_ELEM_SELECT)) { if (EDBM_op_callf(em, op, "flip_quad_tessellation faces=%hf", BM_ELEM_SELECT)) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2248,7 +2248,7 @@ static void edbm_flip_normals_face_winding(wmOperator *op, Object *obedit, BMEdi
if (flip_custom_normals(em->bm, lnors_ed_arr) || has_flipped_faces) { if (flip_custom_normals(em->bm, lnors_ed_arr) || has_flipped_faces) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2423,7 +2423,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2514,7 +2514,7 @@ static int edbm_hide_exec(bContext *C, wmOperator *op)
if (EDBM_mesh_hide(em, unselected)) { if (EDBM_mesh_hide(em, unselected)) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2570,7 +2570,7 @@ static int edbm_reveal_exec(bContext *C, wmOperator *op)
if (EDBM_mesh_reveal(em, select)) { if (EDBM_mesh_reveal(em, select)) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2641,7 +2641,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2759,7 +2759,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2870,7 +2870,7 @@ static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -2964,7 +2964,7 @@ static int edbm_faces_shade_smooth_exec(bContext *C, wmOperator * /*op*/)
mesh_set_smooth_faces(em, 1); mesh_set_smooth_faces(em, 1);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -3012,7 +3012,7 @@ static int edbm_faces_shade_flat_exec(bContext *C, wmOperator * /*op*/)
mesh_set_smooth_faces(em, 0); mesh_set_smooth_faces(em, 0);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -3072,7 +3072,7 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -3107,7 +3107,7 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op)
continue; continue;
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -3162,7 +3162,7 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */ /* dependencies graph and notification stuff */
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);
@ -3210,7 +3210,7 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -3464,7 +3464,7 @@ static int edbm_merge_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -3649,7 +3649,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
if (count) { if (count) {
count_multi += count; count_multi += count;
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -3772,7 +3772,7 @@ static int edbm_shape_propagate_to_all_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);
@ -3911,7 +3911,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);
@ -4053,7 +4053,7 @@ static int edbm_solidify_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -4391,7 +4391,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(bm, false); BM_custom_loop_normals_from_vector_layer(bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -4792,7 +4792,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
if (changed) { if (changed) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(base->object->data), &params); EDBM_update(static_cast<Mesh *>(base->object->data), &params);
@ -4944,7 +4944,7 @@ static int edbm_fill_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -5251,7 +5251,7 @@ static int edbm_fill_grid_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -5329,7 +5329,7 @@ static int edbm_fill_holes_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -5413,7 +5413,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -5502,7 +5502,7 @@ static int edbm_poke_face_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -5609,7 +5609,7 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -5730,7 +5730,7 @@ static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -5920,7 +5920,7 @@ static int edbm_decimate_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush_ex(em, selectmode); EDBM_selectmode_flush_ex(em, selectmode);
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -6065,7 +6065,7 @@ static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -6132,7 +6132,7 @@ static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -6199,7 +6199,7 @@ static int edbm_dissolve_faces_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -6349,7 +6349,7 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
BM_custom_loop_normals_from_vector_layer(em->bm, false); BM_custom_loop_normals_from_vector_layer(em->bm, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -6441,7 +6441,7 @@ static int edbm_dissolve_degenerate_exec(bContext *C, wmOperator *op)
EDBM_select_flush(em); EDBM_select_flush(em);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -6538,7 +6538,7 @@ static int edbm_delete_edgeloop_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX); EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -6605,7 +6605,7 @@ static int edbm_split_exec(bContext *C, wmOperator *op)
/* Geometry has changed, need to recalculate normals and tessellation. */ /* Geometry has changed, need to recalculate normals and tessellation. */
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -7127,7 +7127,7 @@ static void sort_bmelem_flag(bContext *C,
BM_mesh_remap(em->bm, map[0], map[1], map[2]); BM_mesh_remap(em->bm, map[0], map[1], map[2]);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = (totelem[2] != 0); params.calc_looptris = (totelem[2] != 0);
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(ob->data), &params); EDBM_update(static_cast<Mesh *>(ob->data), &params);
@ -7471,7 +7471,7 @@ static int edbm_bridge_edge_loops_for_single_editmesh(wmOperator *op,
if (EDBM_op_finish(em, &bmop, op, true)) { if (EDBM_op_finish(em, &bmop, op, true)) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);
@ -7618,7 +7618,7 @@ static int edbm_wireframe_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -7713,7 +7713,7 @@ static int edbm_offset_edgeloop_exec(bContext *C, wmOperator *op)
if (EDBM_op_finish(em, &bmop, op, true)) { if (EDBM_op_finish(em, &bmop, op, true)) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -7849,7 +7849,7 @@ static int edbm_convex_hull_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -7942,7 +7942,7 @@ static int mesh_symmetrize_exec(bContext *C, wmOperator *op)
continue; continue;
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = true; params.is_destructive = true;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -8090,7 +8090,7 @@ static int mesh_symmetry_snap_exec(bContext *C, wmOperator *op)
} }
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -8776,7 +8776,7 @@ static int edbm_point_normals_modal(bContext *C, wmOperator *op, const wmEvent *
if (point_normals_ensure(C, op)) { if (point_normals_ensure(C, op)) {
point_normals_apply(C, op, target, do_reset); point_normals_apply(C, op, target, do_reset);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
/* Recheck booleans. */ /* Recheck booleans. */
@ -8839,7 +8839,7 @@ static int edbm_point_normals_exec(bContext *C, wmOperator *op)
point_normals_apply(C, op, target, false); point_normals_apply(C, op, target, false);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -9106,7 +9106,7 @@ static int normals_split_merge(bContext *C, const bool do_merge)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -9322,7 +9322,7 @@ static int edbm_average_normals_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -9585,7 +9585,7 @@ static int edbm_normals_tools_exec(bContext *C, wmOperator *op)
BM_loop_normal_editdata_array_free(lnors_ed_arr); BM_loop_normal_editdata_array_free(lnors_ed_arr);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -9744,7 +9744,7 @@ static int edbm_set_normals_from_faces_exec(bContext *C, wmOperator *op)
MEM_freeN(loop_set); MEM_freeN(loop_set);
MEM_freeN(vert_normals); MEM_freeN(vert_normals);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -9858,7 +9858,7 @@ static int edbm_smooth_normals_exec(bContext *C, wmOperator *op)
MEM_freeN(smooth_normal); MEM_freeN(smooth_normal);
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);
@ -9952,7 +9952,7 @@ static int edbm_mod_weighted_strength_exec(bContext *C, wmOperator *op)
} }
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = false; params.calc_looptris = false;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(static_cast<Mesh *>(obedit->data), &params); EDBM_update(static_cast<Mesh *>(obedit->data), &params);

@ -831,7 +831,7 @@ static void undomesh_to_editmesh(UndoMesh *um, Object *ob, BMEditMesh *em)
*em = *em_tmp; *em = *em_tmp;
/* Calculate face normals and tessellation at once since it's multi-threaded. */ /* Calculate face normals and tessellation at once since it's multi-threaded. */
BKE_editmesh_looptri_and_normals_calc(em); BKE_editmesh_looptris_and_normals_calc(em);
em->selectmode = um->selectmode; em->selectmode = um->selectmode;
bm->selectmode = um->selectmode; bm->selectmode = um->selectmode;

@ -61,7 +61,7 @@ BMBackup EDBM_redo_state_store(BMEditMesh *em)
return backup; return backup;
} }
void EDBM_redo_state_restore(BMBackup *backup, BMEditMesh *em, bool recalc_looptri) void EDBM_redo_state_restore(BMBackup *backup, BMEditMesh *em, bool recalc_looptris)
{ {
BM_mesh_data_free(em->bm); BM_mesh_data_free(em->bm);
BMesh *tmpbm = BM_mesh_copy(backup->bmcopy); BMesh *tmpbm = BM_mesh_copy(backup->bmcopy);
@ -69,19 +69,19 @@ void EDBM_redo_state_restore(BMBackup *backup, BMEditMesh *em, bool recalc_loopt
MEM_freeN(tmpbm); MEM_freeN(tmpbm);
tmpbm = nullptr; tmpbm = nullptr;
if (recalc_looptri) { if (recalc_looptris) {
BKE_editmesh_looptri_calc(em); BKE_editmesh_looptris_calc(em);
} }
} }
void EDBM_redo_state_restore_and_free(BMBackup *backup, BMEditMesh *em, bool recalc_looptri) void EDBM_redo_state_restore_and_free(BMBackup *backup, BMEditMesh *em, bool recalc_looptris)
{ {
BM_mesh_data_free(em->bm); BM_mesh_data_free(em->bm);
*em->bm = *backup->bmcopy; *em->bm = *backup->bmcopy;
MEM_freeN(backup->bmcopy); MEM_freeN(backup->bmcopy);
backup->bmcopy = nullptr; backup->bmcopy = nullptr;
if (recalc_looptri) { if (recalc_looptris) {
BKE_editmesh_looptri_calc(em); BKE_editmesh_looptris_calc(em);
} }
} }
@ -1662,17 +1662,17 @@ void EDBM_update(Mesh *mesh, const EDBMUpdate_Params *params)
DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY); DEG_id_tag_update(&mesh->id, ID_RECALC_GEOMETRY);
WM_main_add_notifier(NC_GEOM | ND_DATA, &mesh->id); WM_main_add_notifier(NC_GEOM | ND_DATA, &mesh->id);
if (params->calc_normals && params->calc_looptri) { if (params->calc_normals && params->calc_looptris) {
/* Calculating both has some performance gains. */ /* Calculating both has some performance gains. */
BKE_editmesh_looptri_and_normals_calc(em); BKE_editmesh_looptris_and_normals_calc(em);
} }
else { else {
if (params->calc_normals) { if (params->calc_normals) {
EDBM_mesh_normals_update(em); EDBM_mesh_normals_update(em);
} }
if (params->calc_looptri) { if (params->calc_looptris) {
BKE_editmesh_looptri_calc(em); BKE_editmesh_looptris_calc(em);
} }
} }
@ -1701,7 +1701,7 @@ void EDBM_update(Mesh *mesh, const EDBMUpdate_Params *params)
void EDBM_update_extern(Mesh *mesh, const bool do_tessellation, const bool is_destructive) void EDBM_update_extern(Mesh *mesh, const bool do_tessellation, const bool is_destructive)
{ {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = do_tessellation; params.calc_looptris = do_tessellation;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = is_destructive; params.is_destructive = is_destructive;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);

@ -1076,11 +1076,11 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
/* Populate through adjacent triangles, first triangle wins. */ /* Populate through adjacent triangles, first triangle wins. */
const int tottri = poly_to_tri_count(me_eval->faces_num, me_eval->totloop); const int tottri = poly_to_tri_count(me_eval->faces_num, me_eval->totloop);
MLoopTri *looptri = static_cast<MLoopTri *>(MEM_mallocN(sizeof(*looptri) * tottri, __func__)); MLoopTri *looptris = static_cast<MLoopTri *>(MEM_mallocN(sizeof(*looptris) * tottri, __func__));
const blender::Span<int> corner_verts = me_eval->corner_verts(); const blender::Span<int> corner_verts = me_eval->corner_verts();
blender::bke::mesh::looptris_calc( blender::bke::mesh::looptris_calc(
me_eval->vert_positions(), me_eval->faces(), corner_verts, {looptri, tottri}); me_eval->vert_positions(), me_eval->faces(), corner_verts, {looptris, tottri});
const blender::Span<int> looptri_faces = me_eval->looptri_faces(); const blender::Span<int> looptri_faces = me_eval->looptri_faces();
/* For mapping back to original mesh in case there are modifiers. */ /* For mapping back to original mesh in case there are modifiers. */
@ -1092,7 +1092,7 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
const blender::Span<int> orig_corner_verts = mesh->corner_verts(); const blender::Span<int> orig_corner_verts = mesh->corner_verts();
for (int i = 0; i < tottri; i++) { for (int i = 0; i < tottri; i++) {
const MLoopTri *lt = &looptri[i]; const MLoopTri *lt = &looptris[i];
const int face_i = looptri_faces[i]; const int face_i = looptri_faces[i];
for (int j = 0; j < 3; j++) { for (int j = 0; j < 3; j++) {
@ -1137,7 +1137,7 @@ static void bake_targets_populate_pixels_color_attributes(BakeTargets *targets,
} }
} }
MEM_freeN(looptri); MEM_freeN(looptris);
} }
static void bake_result_add_to_rgba(float rgba[4], const float *result, const int channels_num) static void bake_result_add_to_rgba(float rgba[4], const float *result, const int channels_num)

@ -750,7 +750,7 @@ void ED_object_data_xform_tag_update(XFormObjectData *xod_base)
Mesh *mesh = (Mesh *)xod_base->id; Mesh *mesh = (Mesh *)xod_base->id;
if (xod_base->is_edit_mode) { if (xod_base->is_edit_mode) {
EDBMUpdate_Params params{}; EDBMUpdate_Params params{};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = true; params.calc_normals = true;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);

@ -829,7 +829,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag
BMEditMesh *em = BKE_editmesh_from_object(ob); BMEditMesh *em = BKE_editmesh_from_object(ob);
if (LIKELY(em)) { if (LIKELY(em)) {
BKE_editmesh_looptri_and_normals_calc(em); BKE_editmesh_looptris_and_normals_calc(em);
} }
WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, nullptr); WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_MESH, nullptr);

@ -344,7 +344,7 @@ static bool object_hook_index_array(Main *bmain,
em = mesh->edit_mesh; em = mesh->edit_mesh;
BKE_editmesh_looptri_and_normals_calc(em); BKE_editmesh_looptris_and_normals_calc(em);
/* check selected vertices first */ /* check selected vertices first */
if (return_editmesh_indexar(em, r_indexar_num, r_indexar, r_cent) == 0) { if (return_editmesh_indexar(em, r_indexar_num, r_indexar, r_cent) == 0) {

@ -147,7 +147,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op)
em = mesh->edit_mesh; em = mesh->edit_mesh;
BKE_editmesh_looptri_and_normals_calc(em); BKE_editmesh_looptris_and_normals_calc(em);
/* Make sure the evaluated mesh is updated. /* Make sure the evaluated mesh is updated.
* *

@ -535,7 +535,7 @@ static bool PE_create_shape_tree(PEData *data, Object *shapeob)
return false; return false;
} }
return (BKE_bvhtree_from_mesh_get(&data->shape_bvh, mesh, BVHTREE_FROM_LOOPTRI, 4) != nullptr); return (BKE_bvhtree_from_mesh_get(&data->shape_bvh, mesh, BVHTREE_FROM_LOOPTRIS, 4) != nullptr);
} }
static void PE_free_shape_tree(PEData *data) static void PE_free_shape_tree(PEData *data)

@ -146,7 +146,7 @@ struct AddOperationExecutor {
surface_positions_eval_ = surface_eval_->vert_positions(); surface_positions_eval_ = surface_eval_->vert_positions();
surface_corner_verts_eval_ = surface_eval_->corner_verts(); surface_corner_verts_eval_ = surface_eval_->corner_verts();
surface_looptris_eval_ = surface_eval_->looptris(); surface_looptris_eval_ = surface_eval_->looptris();
BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); });
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt; curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
@ -297,13 +297,13 @@ struct AddOperationExecutor {
} }
const int looptri_index = ray_hit.index; const int looptri_index = ray_hit.index;
const MLoopTri &looptri = surface_looptris_eval_[looptri_index]; const MLoopTri &lt = surface_looptris_eval_[looptri_index];
const float3 brush_pos_su = ray_hit.co; const float3 brush_pos_su = ray_hit.co;
const float3 bary_coords = bke::mesh_surface_sample::compute_bary_coord_in_triangle( const float3 bary_coords = bke::mesh_surface_sample::compute_bary_coord_in_triangle(
surface_positions_eval_, surface_corner_verts_eval_, looptri, brush_pos_su); surface_positions_eval_, surface_corner_verts_eval_, lt, brush_pos_su);
const float2 uv = bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords( const float2 uv = bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords(
bary_coords, looptri, surface_uv_map_eval_); bary_coords, lt, surface_uv_map_eval_);
r_sampled_uvs.append(uv); r_sampled_uvs.append(uv);
} }
@ -429,13 +429,10 @@ struct AddOperationExecutor {
brush_pos_su, brush_pos_su,
brush_radius_su, brush_radius_su,
[&](const int index, const float3 & /*co*/, const float /*dist_sq*/) { [&](const int index, const float3 & /*co*/, const float /*dist_sq*/) {
const MLoopTri &looptri = surface_looptris_eval_[index]; const MLoopTri &lt = surface_looptris_eval_[index];
const float3 &v0_su = const float3 &v0_su = surface_positions_eval_[surface_corner_verts_eval_[lt.tri[0]]];
surface_positions_eval_[surface_corner_verts_eval_[looptri.tri[0]]]; const float3 &v1_su = surface_positions_eval_[surface_corner_verts_eval_[lt.tri[1]]];
const float3 &v1_su = const float3 &v2_su = surface_positions_eval_[surface_corner_verts_eval_[lt.tri[2]]];
surface_positions_eval_[surface_corner_verts_eval_[looptri.tri[1]]];
const float3 &v2_su =
surface_positions_eval_[surface_corner_verts_eval_[looptri.tri[2]]];
float3 normal_su; float3 normal_su;
normal_tri_v3(normal_su, v0_su, v1_su, v2_su); normal_tri_v3(normal_su, v0_su, v1_su, v2_su);
if (math::dot(normal_su, view_direction_su) >= 0.0f) { if (math::dot(normal_su, view_direction_su) >= 0.0f) {

@ -193,7 +193,7 @@ std::optional<CurvesBrush3D> sample_curves_3d_brush(const Depsgraph &depsgraph,
Mesh *surface_eval = BKE_object_get_evaluated_mesh(surface_object_eval); Mesh *surface_eval = BKE_object_get_evaluated_mesh(surface_object_eval);
BVHTreeFromMesh surface_bvh; BVHTreeFromMesh surface_bvh;
BKE_bvhtree_from_mesh_get(&surface_bvh, surface_eval, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh, surface_eval, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); });
const float3 center_ray_start_su = math::transform_point(world_to_surface_mat, const float3 center_ray_start_su = math::transform_point(world_to_surface_mat,

@ -131,7 +131,7 @@ struct DensityAddOperationExecutor {
return; return;
} }
BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); });
surface_looptris_eval_ = surface_eval_->looptris(); surface_looptris_eval_ = surface_eval_->looptris();
/* Find UV map. */ /* Find UV map. */
@ -550,7 +550,7 @@ struct DensitySubtractOperationExecutor {
} }
surface_eval_ = BKE_object_get_evaluated_mesh(surface_ob_eval_); surface_eval_ = BKE_object_get_evaluated_mesh(surface_ob_eval_);
BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); });
curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt; curves_sculpt_ = ctx_.scene->toolsettings->curves_sculpt;
@ -834,7 +834,7 @@ static bool use_add_density_mode(const BrushStrokeMode brush_mode,
const CurvesSurfaceTransforms transforms(curves_ob_orig, curves_id_orig.surface); const CurvesSurfaceTransforms transforms(curves_ob_orig, curves_id_orig.surface);
BVHTreeFromMesh surface_bvh_eval; BVHTreeFromMesh surface_bvh_eval;
BKE_bvhtree_from_mesh_get(&surface_bvh_eval, surface_mesh_eval, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh_eval, surface_mesh_eval, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval); });
const float2 brush_pos_re = stroke_start.mouse_position; const float2 brush_pos_re = stroke_start.mouse_position;

@ -1031,7 +1031,7 @@ static int min_distance_edit_invoke(bContext *C, wmOperator *op, const wmEvent *
} }
BVHTreeFromMesh surface_bvh_eval; BVHTreeFromMesh surface_bvh_eval;
BKE_bvhtree_from_mesh_get(&surface_bvh_eval, surface_me_eval, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh_eval, surface_me_eval, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval); });
const int2 mouse_pos_int_re{event->mval}; const int2 mouse_pos_int_re{event->mval};

@ -121,7 +121,7 @@ struct PuffOperationExecutor {
surface_corner_verts_ = surface_->corner_verts(); surface_corner_verts_ = surface_->corner_verts();
surface_looptris_ = surface_->looptris(); surface_looptris_ = surface_->looptris();
corner_normals_su_ = surface_->corner_normals(); corner_normals_su_ = surface_->corner_normals();
BKE_bvhtree_from_mesh_get(&surface_bvh_, surface_, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh_, surface_, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_); });
if (stroke_extension.is_first) { if (stroke_extension.is_first) {
@ -292,15 +292,15 @@ struct PuffOperationExecutor {
surface_bvh_.nearest_callback, surface_bvh_.nearest_callback,
&surface_bvh_); &surface_bvh_);
const MLoopTri &looptri = surface_looptris_[nearest.index]; const MLoopTri &lt = surface_looptris_[nearest.index];
const float3 closest_pos_su = nearest.co; const float3 closest_pos_su = nearest.co;
const float3 &v0_su = surface_positions_[surface_corner_verts_[looptri.tri[0]]]; const float3 &v0_su = surface_positions_[surface_corner_verts_[lt.tri[0]]];
const float3 &v1_su = surface_positions_[surface_corner_verts_[looptri.tri[1]]]; const float3 &v1_su = surface_positions_[surface_corner_verts_[lt.tri[1]]];
const float3 &v2_su = surface_positions_[surface_corner_verts_[looptri.tri[2]]]; const float3 &v2_su = surface_positions_[surface_corner_verts_[lt.tri[2]]];
float3 bary_coords; float3 bary_coords;
interp_weights_tri_v3(bary_coords, v0_su, v1_su, v2_su, closest_pos_su); interp_weights_tri_v3(bary_coords, v0_su, v1_su, v2_su, closest_pos_su);
const float3 normal_su = geometry::compute_surface_point_normal( const float3 normal_su = geometry::compute_surface_point_normal(
looptri, bary_coords, corner_normals_su_); lt, bary_coords, corner_normals_su_);
const float3 normal_cu = math::normalize( const float3 normal_cu = math::normalize(
math::transform_direction(transforms_.surface_to_curves_normal, normal_su)); math::transform_direction(transforms_.surface_to_curves_normal, normal_su));

@ -200,7 +200,7 @@ struct SlideOperationExecutor {
report_missing_uv_map_on_evaluated_surface(stroke_extension.reports); report_missing_uv_map_on_evaluated_surface(stroke_extension.reports);
return; return;
} }
BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh_eval_, surface_eval_, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh_eval_); });
if (stroke_extension.is_first) { if (stroke_extension.is_first) {
@ -376,13 +376,13 @@ struct SlideOperationExecutor {
} }
/* Compute the uv of the new surface position on the evaluated mesh. */ /* Compute the uv of the new surface position on the evaluated mesh. */
const MLoopTri &looptri_eval = surface_looptris_eval_[looptri_index_eval]; const MLoopTri &lt_eval = surface_looptris_eval_[looptri_index_eval];
const float3 bary_weights_eval = bke::mesh_surface_sample::compute_bary_coord_in_triangle( const float3 bary_weights_eval = bke::mesh_surface_sample::compute_bary_coord_in_triangle(
surface_positions_eval_, surface_corner_verts_eval_, looptri_eval, hit_pos_eval_su); surface_positions_eval_, surface_corner_verts_eval_, lt_eval, hit_pos_eval_su);
const float2 uv = bke::attribute_math::mix3(bary_weights_eval, const float2 uv = bke::attribute_math::mix3(bary_weights_eval,
surface_uv_map_eval_[looptri_eval.tri[0]], surface_uv_map_eval_[lt_eval.tri[0]],
surface_uv_map_eval_[looptri_eval.tri[1]], surface_uv_map_eval_[lt_eval.tri[1]],
surface_uv_map_eval_[looptri_eval.tri[2]]); surface_uv_map_eval_[lt_eval.tri[2]]);
/* Try to find the same uv on the original surface. */ /* Try to find the same uv on the original surface. */
const ReverseUVSampler::Result result = reverse_uv_sampler_orig.sample(uv); const ReverseUVSampler::Result result = reverse_uv_sampler_orig.sample(uv);
@ -390,22 +390,22 @@ struct SlideOperationExecutor {
found_invalid_uv_mapping_.store(true); found_invalid_uv_mapping_.store(true);
continue; continue;
} }
const MLoopTri &looptri_orig = surface_looptris_orig_[result.looptri_index]; const MLoopTri &lt_orig = surface_looptris_orig_[result.looptri_index];
const float3 &bary_weights_orig = result.bary_weights; const float3 &bary_weights_orig = result.bary_weights;
/* Gather old and new surface normal. */ /* Gather old and new surface normal. */
const float3 &initial_normal_cu = slide_curve_info.initial_normal_cu; const float3 &initial_normal_cu = slide_curve_info.initial_normal_cu;
const float3 new_normal_cu = math::normalize(math::transform_point( const float3 new_normal_cu = math::normalize(
transforms_.surface_to_curves_normal, math::transform_point(transforms_.surface_to_curves_normal,
geometry::compute_surface_point_normal( geometry::compute_surface_point_normal(
looptri_orig, result.bary_weights, corner_normals_orig_su_))); lt_orig, result.bary_weights, corner_normals_orig_su_)));
/* Gather old and new surface position. */ /* Gather old and new surface position. */
const float3 new_first_pos_orig_su = bke::attribute_math::mix3<float3>( const float3 new_first_pos_orig_su = bke::attribute_math::mix3<float3>(
bary_weights_orig, bary_weights_orig,
positions_orig_su[corner_verts_orig[looptri_orig.tri[0]]], positions_orig_su[corner_verts_orig[lt_orig.tri[0]]],
positions_orig_su[corner_verts_orig[looptri_orig.tri[1]]], positions_orig_su[corner_verts_orig[lt_orig.tri[1]]],
positions_orig_su[corner_verts_orig[looptri_orig.tri[2]]]); positions_orig_su[corner_verts_orig[lt_orig.tri[2]]]);
const float3 old_first_pos_orig_cu = self_->initial_positions_cu_[first_point_i]; const float3 old_first_pos_orig_cu = self_->initial_positions_cu_[first_point_i];
const float3 new_first_pos_orig_cu = math::transform_point(transforms_.surface_to_curves, const float3 new_first_pos_orig_cu = math::transform_point(transforms_.surface_to_curves,
new_first_pos_orig_su); new_first_pos_orig_su);

@ -1322,7 +1322,7 @@ static void uv_image_outset(const ProjPaintState *ps,
int fidx[2]; int fidx[2];
uint loop_index; uint loop_index;
uint vert[2]; uint vert[2];
const MLoopTri *ltri = &ps->looptris_eval[tri_index]; const MLoopTri *lt = &ps->looptris_eval[tri_index];
float ibuf_inv[2]; float ibuf_inv[2];
@ -1338,7 +1338,7 @@ static void uv_image_outset(const ProjPaintState *ps,
continue; continue;
} }
loop_index = ltri->tri[fidx[0]]; loop_index = lt->tri[fidx[0]];
seam_data = &ps->loopSeamData[loop_index]; seam_data = &ps->loopSeamData[loop_index];
seam_uvs = seam_data->seam_uvs; seam_uvs = seam_data->seam_uvs;
@ -1350,7 +1350,7 @@ static void uv_image_outset(const ProjPaintState *ps,
fidx[1] = (fidx[0] == 2) ? 0 : fidx[0] + 1; fidx[1] = (fidx[0] == 2) ? 0 : fidx[0] + 1;
vert[0] = ps->corner_verts_eval[loop_index]; vert[0] = ps->corner_verts_eval[loop_index];
vert[1] = ps->corner_verts_eval[ltri->tri[fidx[1]]]; vert[1] = ps->corner_verts_eval[lt->tri[fidx[1]]];
for (uint i = 0; i < 2; i++) { for (uint i = 0; i < 2; i++) {
VertSeam *seam; VertSeam *seam;

@ -186,7 +186,7 @@ static void editmesh_partial_update_update_fn(bContext *C,
BMEditMesh *em = static_cast<BMEditMesh *>(arg1); BMEditMesh *em = static_cast<BMEditMesh *>(arg1);
BKE_editmesh_looptri_and_normals_calc_with_partial(em, bmpinfo); BKE_editmesh_looptris_and_normals_calc_with_partial(em, bmpinfo);
} }
/** \} */ /** \} */

@ -85,7 +85,7 @@ enum ePartialType {
* use for comparison with previous updates. * use for comparison with previous updates.
*/ */
struct PartialTypeState { struct PartialTypeState {
ePartialType for_looptri; ePartialType for_looptris;
ePartialType for_normals; ePartialType for_normals;
}; };
@ -104,7 +104,7 @@ static TransCustomDataMesh *mesh_customdata_ensure(TransDataContainer *tc)
tc->custom.type.data = MEM_callocN(sizeof(TransCustomDataMesh), __func__); tc->custom.type.data = MEM_callocN(sizeof(TransCustomDataMesh), __func__);
tc->custom.type.free_cb = mesh_customdata_free_fn; tc->custom.type.free_cb = mesh_customdata_free_fn;
tcmd = static_cast<TransCustomDataMesh *>(tc->custom.type.data); tcmd = static_cast<TransCustomDataMesh *>(tc->custom.type.data);
tcmd->partial_update_state_prev.for_looptri = PARTIAL_NONE; tcmd->partial_update_state_prev.for_looptris = PARTIAL_NONE;
tcmd->partial_update_state_prev.for_normals = PARTIAL_NONE; tcmd->partial_update_state_prev.for_normals = PARTIAL_NONE;
} }
return tcmd; return tcmd;
@ -1900,13 +1900,13 @@ static void mesh_partial_types_calc(TransInfo *t, PartialTypeState *r_partial_st
{ {
/* Calculate the kind of partial updates which can be performed. */ /* Calculate the kind of partial updates which can be performed. */
enum ePartialType partial_for_normals = PARTIAL_NONE; enum ePartialType partial_for_normals = PARTIAL_NONE;
enum ePartialType partial_for_looptri = PARTIAL_NONE; enum ePartialType partial_for_looptris = PARTIAL_NONE;
/* Note that operations such as #TFM_CREASE are not handled here /* Note that operations such as #TFM_CREASE are not handled here
* (if they were, leaving as #PARTIAL_NONE would be appropriate). */ * (if they were, leaving as #PARTIAL_NONE would be appropriate). */
switch (t->mode) { switch (t->mode) {
case TFM_TRANSLATION: { case TFM_TRANSLATION: {
partial_for_looptri = PARTIAL_TYPE_GROUP; partial_for_looptris = PARTIAL_TYPE_GROUP;
partial_for_normals = PARTIAL_TYPE_GROUP; partial_for_normals = PARTIAL_TYPE_GROUP;
/* Translation can rotate when snapping to normal. */ /* Translation can rotate when snapping to normal. */
if (transform_snap_is_active(t) && usingSnappingNormal(t) && validSnappingNormal(t)) { if (transform_snap_is_active(t) && usingSnappingNormal(t) && validSnappingNormal(t)) {
@ -1915,12 +1915,12 @@ static void mesh_partial_types_calc(TransInfo *t, PartialTypeState *r_partial_st
break; break;
} }
case TFM_ROTATION: { case TFM_ROTATION: {
partial_for_looptri = PARTIAL_TYPE_GROUP; partial_for_looptris = PARTIAL_TYPE_GROUP;
partial_for_normals = PARTIAL_TYPE_ALL; partial_for_normals = PARTIAL_TYPE_ALL;
break; break;
} }
case TFM_RESIZE: { case TFM_RESIZE: {
partial_for_looptri = PARTIAL_TYPE_GROUP; partial_for_looptris = PARTIAL_TYPE_GROUP;
partial_for_normals = PARTIAL_TYPE_GROUP; partial_for_normals = PARTIAL_TYPE_GROUP;
/* Non-uniform scale needs to recalculate all normals /* Non-uniform scale needs to recalculate all normals
* since their relative locations change. * since their relative locations change.
@ -1934,7 +1934,7 @@ static void mesh_partial_types_calc(TransInfo *t, PartialTypeState *r_partial_st
break; break;
} }
default: { default: {
partial_for_looptri = PARTIAL_TYPE_ALL; partial_for_looptris = PARTIAL_TYPE_ALL;
partial_for_normals = PARTIAL_TYPE_ALL; partial_for_normals = PARTIAL_TYPE_ALL;
break; break;
} }
@ -1942,15 +1942,15 @@ static void mesh_partial_types_calc(TransInfo *t, PartialTypeState *r_partial_st
/* With projection, transform isn't affine. */ /* With projection, transform isn't affine. */
if (transform_snap_project_individual_is_active(t)) { if (transform_snap_project_individual_is_active(t)) {
if (partial_for_looptri == PARTIAL_TYPE_GROUP) { if (partial_for_looptris == PARTIAL_TYPE_GROUP) {
partial_for_looptri = PARTIAL_TYPE_ALL; partial_for_looptris = PARTIAL_TYPE_ALL;
} }
if (partial_for_normals == PARTIAL_TYPE_GROUP) { if (partial_for_normals == PARTIAL_TYPE_GROUP) {
partial_for_normals = PARTIAL_TYPE_ALL; partial_for_normals = PARTIAL_TYPE_ALL;
} }
} }
r_partial_state->for_looptri = partial_for_looptri; r_partial_state->for_looptris = partial_for_looptris;
r_partial_state->for_normals = partial_for_normals; r_partial_state->for_normals = partial_for_normals;
} }
@ -1967,12 +1967,12 @@ static void mesh_partial_update(TransInfo *t,
/* Promote the partial update types based on the previous state /* Promote the partial update types based on the previous state
* so the values that no longer modified are reset before being left as-is. * so the values that no longer modified are reset before being left as-is.
* Needed for translation which can toggle snap-to-normal during transform. */ * Needed for translation which can toggle snap-to-normal during transform. */
const enum ePartialType partial_for_looptri = std::max(partial_state->for_looptri, const enum ePartialType partial_for_looptris = std::max(partial_state->for_looptris,
partial_state_prev->for_looptri); partial_state_prev->for_looptris);
const enum ePartialType partial_for_normals = std::max(partial_state->for_normals, const enum ePartialType partial_for_normals = std::max(partial_state->for_normals,
partial_state_prev->for_normals); partial_state_prev->for_normals);
if ((partial_for_looptri == PARTIAL_TYPE_ALL) && (partial_for_normals == PARTIAL_TYPE_ALL) && if ((partial_for_looptris == PARTIAL_TYPE_ALL) && (partial_for_normals == PARTIAL_TYPE_ALL) &&
(em->bm->totvert == em->bm->totvertsel)) (em->bm->totvert == em->bm->totvertsel))
{ {
/* The additional cost of generating the partial connectivity data isn't justified /* The additional cost of generating the partial connectivity data isn't justified
@ -1981,21 +1981,21 @@ static void mesh_partial_update(TransInfo *t,
* While proportional editing can cause all geometry to need updating with a partial * While proportional editing can cause all geometry to need updating with a partial
* selection. It's impractical to calculate this ahead of time. Further, the down side of * selection. It's impractical to calculate this ahead of time. Further, the down side of
* using partial updates when their not needed is negligible. */ * using partial updates when their not needed is negligible. */
BKE_editmesh_looptri_and_normals_calc(em); BKE_editmesh_looptris_and_normals_calc(em);
} }
else { else {
if (partial_for_looptri != PARTIAL_NONE) { if (partial_for_looptris != PARTIAL_NONE) {
BMPartialUpdate *bmpinfo = mesh_partial_ensure(t, tc, partial_for_looptri); BMPartialUpdate *bmpinfo = mesh_partial_ensure(t, tc, partial_for_looptris);
BMeshCalcTessellation_Params params{}; BMeshCalcTessellation_Params params{};
params.face_normals = true; params.face_normals = true;
BKE_editmesh_looptri_calc_with_partial_ex(em, bmpinfo, &params); BKE_editmesh_looptris_calc_with_partial_ex(em, bmpinfo, &params);
} }
if (partial_for_normals != PARTIAL_NONE) { if (partial_for_normals != PARTIAL_NONE) {
BMPartialUpdate *bmpinfo = mesh_partial_ensure(t, tc, partial_for_normals); BMPartialUpdate *bmpinfo = mesh_partial_ensure(t, tc, partial_for_normals);
/* While not a large difference, take advantage of existing normals where possible. */ /* While not a large difference, take advantage of existing normals where possible. */
const bool face_normals = !((partial_for_looptri == PARTIAL_TYPE_ALL) || const bool face_normals = !((partial_for_looptris == PARTIAL_TYPE_ALL) ||
((partial_for_looptri == PARTIAL_TYPE_GROUP) && ((partial_for_looptris == PARTIAL_TYPE_GROUP) &&
(partial_for_normals == PARTIAL_TYPE_GROUP))); (partial_for_normals == PARTIAL_TYPE_GROUP)));
BMeshNormalsUpdate_Params params{}; BMeshNormalsUpdate_Params params{};
params.face_normals = face_normals; params.face_normals = face_normals;

@ -289,7 +289,7 @@ static void recalcData_mesh_skin(TransInfo *t)
FOREACH_TRANS_DATA_CONTAINER (t, tc) { FOREACH_TRANS_DATA_CONTAINER (t, tc) {
DEG_id_tag_update(static_cast<ID *>(tc->obedit->data), ID_RECALC_GEOMETRY); DEG_id_tag_update(static_cast<ID *>(tc->obedit->data), ID_RECALC_GEOMETRY);
BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); BMEditMesh *em = BKE_editmesh_from_object(tc->obedit);
BKE_editmesh_looptri_and_normals_calc(em); BKE_editmesh_looptris_and_normals_calc(em);
} }
} }

@ -184,13 +184,13 @@ static void snap_cache_tri_ensure(SnapCache_EditMesh *em_cache, SnapObjectContex
BLI_assert(poly_to_tri_count(bm->totface, bm->totloop) == em->tottri); BLI_assert(poly_to_tri_count(bm->totface, bm->totloop) == em->tottri);
blender::BitVector<> elem_mask(em->tottri); blender::BitVector<> elem_mask(em->tottri);
int looptri_num_active = BM_iter_mesh_bitmap_from_filter_tessface( int looptris_num_active = BM_iter_mesh_bitmap_from_filter_tessface(
bm, bm,
elem_mask, elem_mask,
sctx->callbacks.edit_mesh.test_face_fn, sctx->callbacks.edit_mesh.test_face_fn,
sctx->callbacks.edit_mesh.user_data); sctx->callbacks.edit_mesh.user_data);
bvhtree_from_editmesh_looptri_ex(&treedata, em, elem_mask, looptri_num_active, 0.0f, 4, 6); bvhtree_from_editmesh_looptris_ex(&treedata, em, elem_mask, looptris_num_active, 0.0f, 4, 6);
} }
else { else {
/* Only cache if BVH-tree is created without a mask. /* Only cache if BVH-tree is created without a mask.
@ -198,7 +198,7 @@ static void snap_cache_tri_ensure(SnapCache_EditMesh *em_cache, SnapObjectContex
BKE_bvhtree_from_editmesh_get(&treedata, BKE_bvhtree_from_editmesh_get(&treedata,
em, em,
4, 4,
BVHTREE_FROM_EM_LOOPTRI, BVHTREE_FROM_EM_LOOPTRIS,
/* WORKAROUND: avoid updating while transforming. */ /* WORKAROUND: avoid updating while transforming. */
G.moving ? nullptr : &em_cache->mesh_runtime->bvh_cache, G.moving ? nullptr : &em_cache->mesh_runtime->bvh_cache,
&em_cache->mesh_runtime->eval_mutex); &em_cache->mesh_runtime->eval_mutex);
@ -261,10 +261,10 @@ static SnapCache_EditMesh *editmesh_snapdata_init(SnapObjectContext *sctx,
* \{ */ * \{ */
/* Callback to ray-cast with back-face culling (#EditMesh). */ /* Callback to ray-cast with back-face culling (#EditMesh). */
static void editmesh_looptri_raycast_backface_culling_cb(void *userdata, static void editmesh_looptris_raycast_backface_culling_cb(void *userdata,
int index, int index,
const BVHTreeRay *ray, const BVHTreeRay *ray,
BVHTreeRayHit *hit) BVHTreeRayHit *hit)
{ {
BMEditMesh *em = static_cast<BMEditMesh *>(userdata); BMEditMesh *em = static_cast<BMEditMesh *>(userdata);
const BMLoop **ltri = (const BMLoop **)em->looptris[index]; const BMLoop **ltri = (const BMLoop **)em->looptris[index];
@ -372,7 +372,7 @@ static bool raycastEditMesh(SnapCache_EditMesh *em_cache,
0.0f, 0.0f,
&hit, &hit,
sctx->runtime.params.use_backface_culling ? sctx->runtime.params.use_backface_culling ?
editmesh_looptri_raycast_backface_culling_cb : editmesh_looptris_raycast_backface_culling_cb :
em_cache->raycast_callback, em_cache->raycast_callback,
em) != -1) em) != -1)
{ {

@ -36,7 +36,7 @@ static void snap_object_data_mesh_get(const Mesh *me_eval,
{ {
/* The BVHTree from looptris is always required. */ /* The BVHTree from looptris is always required. */
BKE_bvhtree_from_mesh_get( BKE_bvhtree_from_mesh_get(
r_treedata, me_eval, use_hide ? BVHTREE_FROM_LOOPTRI_NO_HIDDEN : BVHTREE_FROM_LOOPTRI, 4); r_treedata, me_eval, use_hide ? BVHTREE_FROM_LOOPTRIS_NO_HIDDEN : BVHTREE_FROM_LOOPTRIS, 4);
} }
/** \} */ /** \} */
@ -49,10 +49,10 @@ static void snap_object_data_mesh_get(const Mesh *me_eval,
* Support for storing all depths, not just the first (ray-cast 'all'). */ * Support for storing all depths, not just the first (ray-cast 'all'). */
/* Callback to ray-cast with back-face culling (#Mesh). */ /* Callback to ray-cast with back-face culling (#Mesh). */
static void mesh_looptri_raycast_backface_culling_cb(void *userdata, static void mesh_looptris_raycast_backface_culling_cb(void *userdata,
int index, int index,
const BVHTreeRay *ray, const BVHTreeRay *ray,
BVHTreeRayHit *hit) BVHTreeRayHit *hit)
{ {
const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata; const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
const blender::Span<blender::float3> positions = data->vert_positions; const blender::Span<blender::float3> positions = data->vert_positions;
@ -166,7 +166,7 @@ static bool raycastMesh(SnapObjectContext *sctx,
0.0f, 0.0f,
&hit, &hit,
sctx->runtime.params.use_backface_culling ? sctx->runtime.params.use_backface_culling ?
mesh_looptri_raycast_backface_culling_cb : mesh_looptris_raycast_backface_culling_cb :
treedata.raycast_callback, treedata.raycast_callback,
&treedata) != -1) &treedata) != -1)
{ {
@ -533,7 +533,7 @@ static eSnapMode snapMesh(SnapObjectContext *sctx,
else { else {
BLI_assert(snap_to & SCE_SNAP_TO_EDGE_ENDPOINT); BLI_assert(snap_to & SCE_SNAP_TO_EDGE_ENDPOINT);
if (bvhtree[0]) { if (bvhtree[0]) {
/* Snap to loose edge verts. */ /* Snap to loose edges verts. */
BLI_bvhtree_find_nearest_projected( BLI_bvhtree_find_nearest_projected(
bvhtree[0], bvhtree[0],
nearest2d.pmat_local.ptr(), nearest2d.pmat_local.ptr(),
@ -547,7 +547,7 @@ static eSnapMode snapMesh(SnapObjectContext *sctx,
} }
if (treedata.tree) { if (treedata.tree) {
/* Snap to looptri verts. */ /* Snap to looptris verts. */
BLI_bvhtree_find_nearest_projected( BLI_bvhtree_find_nearest_projected(
treedata.tree, treedata.tree,
nearest2d.pmat_local.ptr(), nearest2d.pmat_local.ptr(),

@ -1322,7 +1322,7 @@ static int uv_hide_exec(bContext *C, wmOperator *op)
if (EDBM_mesh_hide(em, swap)) { if (EDBM_mesh_hide(em, swap)) {
Mesh *mesh = static_cast<Mesh *>(ob->data); Mesh *mesh = static_cast<Mesh *>(ob->data);
EDBMUpdate_Params params = {0}; EDBMUpdate_Params params = {0};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);
@ -1499,7 +1499,7 @@ static int uv_reveal_exec(bContext *C, wmOperator *op)
if (EDBM_mesh_reveal(em, select)) { if (EDBM_mesh_reveal(em, select)) {
Mesh *mesh = static_cast<Mesh *>(ob->data); Mesh *mesh = static_cast<Mesh *>(ob->data);
EDBMUpdate_Params params = {0}; EDBMUpdate_Params params = {0};
params.calc_looptri = true; params.calc_looptris = true;
params.calc_normals = false; params.calc_normals = false;
params.is_destructive = false; params.is_destructive = false;
EDBM_update(mesh, &params); EDBM_update(mesh, &params);

@ -419,8 +419,8 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id)
// Compute loop triangles // Compute loop triangles
int tottri = poly_to_tri_count(mesh->faces_num, mesh->totloop); int tottri = poly_to_tri_count(mesh->faces_num, mesh->totloop);
MLoopTri *mlooptri = (MLoopTri *)MEM_malloc_arrayN(tottri, sizeof(*mlooptri), __func__); MLoopTri *looptris = (MLoopTri *)MEM_malloc_arrayN(tottri, sizeof(*looptris), __func__);
blender::bke::mesh::looptris_calc(vert_positions, mesh_polys, corner_verts, {mlooptri, tottri}); blender::bke::mesh::looptris_calc(vert_positions, mesh_polys, corner_verts, {looptris, tottri});
const blender::Span<int> looptri_faces = mesh->looptri_faces(); const blender::Span<int> looptri_faces = mesh->looptri_faces();
const blender::Span<blender::float3> lnors = mesh->corner_normals(); const blender::Span<blender::float3> lnors = mesh->corner_normals();
@ -449,7 +449,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id)
float n1[3], n2[3], n3[3], facenormal[3]; float n1[3], n2[3], n3[3], facenormal[3];
int clip[3]; int clip[3];
for (int a = 0; a < tottri; a++) { for (int a = 0; a < tottri; a++) {
const MLoopTri *lt = &mlooptri[a]; const MLoopTri *lt = &looptris[a];
copy_v3_v3(v1, vert_positions[corner_verts[lt->tri[0]]]); copy_v3_v3(v1, vert_positions[corner_verts[lt->tri[0]]]);
copy_v3_v3(v2, vert_positions[corner_verts[lt->tri[1]]]); copy_v3_v3(v2, vert_positions[corner_verts[lt->tri[1]]]);
@ -471,7 +471,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id)
} }
#endif #endif
if (numFaces == 0) { if (numFaces == 0) {
MEM_freeN(mlooptri); MEM_freeN(looptris);
return; return;
} }
@ -523,7 +523,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id)
// We parse the vlak nodes again and import meshes while applying the clipping // We parse the vlak nodes again and import meshes while applying the clipping
// by the near and far view planes. // by the near and far view planes.
for (int a = 0; a < tottri; a++) { for (int a = 0; a < tottri; a++) {
const MLoopTri *lt = &mlooptri[a]; const MLoopTri *lt = &looptris[a];
const int poly_i = looptri_faces[a]; const int poly_i = looptri_faces[a];
Material *mat = BKE_object_material_get(ob, material_indices[poly_i] + 1); Material *mat = BKE_object_material_get(ob, material_indices[poly_i] + 1);
@ -631,7 +631,7 @@ void BlenderFileLoader::insertShapeNode(Object *ob, Mesh *mesh, int id)
} }
} }
MEM_freeN(mlooptri); MEM_freeN(looptris);
// We might have several times the same vertex. We want a clean // We might have several times the same vertex. We want a clean
// shape with no real-vertex. Here, we are making a cleaning pass. // shape with no real-vertex. Here, we are making a cleaning pass.

@ -60,7 +60,7 @@ struct AddCurvesOnMeshOutputs {
AddCurvesOnMeshOutputs add_curves_on_mesh(bke::CurvesGeometry &curves, AddCurvesOnMeshOutputs add_curves_on_mesh(bke::CurvesGeometry &curves,
const AddCurvesOnMeshInputs &inputs); const AddCurvesOnMeshInputs &inputs);
float3 compute_surface_point_normal(const MLoopTri &looptri, float3 compute_surface_point_normal(const MLoopTri &lt,
const float3 &bary_coord, const float3 &bary_coord,
Span<float3> corner_normals); Span<float3> corner_normals);

@ -37,12 +37,12 @@ struct NeighborCurve {
static constexpr int max_neighbors = 5; static constexpr int max_neighbors = 5;
using NeighborCurves = Vector<NeighborCurve, max_neighbors>; using NeighborCurves = Vector<NeighborCurve, max_neighbors>;
float3 compute_surface_point_normal(const MLoopTri &looptri, float3 compute_surface_point_normal(const MLoopTri &lt,
const float3 &bary_coord, const float3 &bary_coord,
const Span<float3> corner_normals) const Span<float3> corner_normals)
{ {
const float3 value = bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords( const float3 value = bke::mesh_surface_sample::sample_corner_attribute_with_bary_coords(
bary_coord, looptri, corner_normals); bary_coord, lt, corner_normals);
return math::normalize(value); return math::normalize(value);
} }
@ -258,14 +258,14 @@ AddCurvesOnMeshOutputs add_curves_on_mesh(CurvesGeometry &curves,
outputs.uv_error = true; outputs.uv_error = true;
continue; continue;
} }
const MLoopTri &looptri = inputs.surface_looptris[result.looptri_index]; const MLoopTri &lt = inputs.surface_looptris[result.looptri_index];
bary_coords.append(result.bary_weights); bary_coords.append(result.bary_weights);
looptri_indices.append(result.looptri_index); looptri_indices.append(result.looptri_index);
const float3 root_position_su = bke::attribute_math::mix3<float3>( const float3 root_position_su = bke::attribute_math::mix3<float3>(
result.bary_weights, result.bary_weights,
surface_positions[surface_corner_verts[looptri.tri[0]]], surface_positions[surface_corner_verts[lt.tri[0]]],
surface_positions[surface_corner_verts[looptri.tri[1]]], surface_positions[surface_corner_verts[lt.tri[1]]],
surface_positions[surface_corner_verts[looptri.tri[2]]]); surface_positions[surface_corner_verts[lt.tri[2]]]);
root_positions_cu.append( root_positions_cu.append(
math::transform_point(inputs.transforms->surface_to_curves, root_position_su)); math::transform_point(inputs.transforms->surface_to_curves, root_position_su));
used_uvs.append(uv); used_uvs.append(uv);

@ -70,7 +70,7 @@ void solve_length_and_collision_constraints(const OffsetIndices<int> points_by_c
solve_length_constraints(points_by_curve, curve_selection, segment_lengths_cu, positions_cu); solve_length_constraints(points_by_curve, curve_selection, segment_lengths_cu, positions_cu);
BVHTreeFromMesh surface_bvh; BVHTreeFromMesh surface_bvh;
BKE_bvhtree_from_mesh_get(&surface_bvh, &surface, BVHTREE_FROM_LOOPTRI, 2); BKE_bvhtree_from_mesh_get(&surface_bvh, &surface, BVHTREE_FROM_LOOPTRIS, 2);
BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); }); BLI_SCOPED_DEFER([&]() { free_bvhtree_from_mesh(&surface_bvh); });
const float radius = 0.005f; const float radius = 0.005f;

@ -65,9 +65,9 @@ void OpenVDBMeshAdapter::getIndexSpacePoint(size_t polygon_index,
size_t vertex_index, size_t vertex_index,
openvdb::Vec3d &pos) const openvdb::Vec3d &pos) const
{ {
const MLoopTri &looptri = looptris_[polygon_index]; const MLoopTri &lt = looptris_[polygon_index];
const float3 transformed_co = math::transform_point( const float3 transformed_co = math::transform_point(
transform_, positions_[corner_verts_[looptri.tri[vertex_index]]]); transform_, positions_[corner_verts_[lt.tri[vertex_index]]]);
pos = &transformed_co.x; pos = &transformed_co.x;
} }
@ -164,10 +164,9 @@ static openvdb::FloatGrid::Ptr mesh_to_sdf_volume_grid(const Mesh &mesh,
threading::parallel_for(looptris.index_range(), 2048, [&](const IndexRange range) { threading::parallel_for(looptris.index_range(), 2048, [&](const IndexRange range) {
for (const int i : range) { for (const int i : range) {
const MLoopTri &loop_tri = looptris[i]; const MLoopTri &lt = looptris[i];
triangles[i] = openvdb::Vec3I(corner_verts[loop_tri.tri[0]], triangles[i] = openvdb::Vec3I(
corner_verts[loop_tri.tri[1]], corner_verts[lt.tri[0]], corner_verts[lt.tri[1]], corner_verts[lt.tri[2]]);
corner_verts[loop_tri.tri[2]]);
} }
}); });

@ -22,10 +22,10 @@ ReverseUVSampler::ReverseUVSampler(const Span<float2> uv_map, const Span<MLoopTr
resolution_ = std::max<int>(3, std::sqrt(looptris.size()) * 2); resolution_ = std::max<int>(3, std::sqrt(looptris.size()) * 2);
for (const int looptri_index : looptris.index_range()) { for (const int looptri_index : looptris.index_range()) {
const MLoopTri &looptri = looptris[looptri_index]; const MLoopTri &lt = looptris[looptri_index];
const float2 &uv_0 = uv_map_[looptri.tri[0]]; const float2 &uv_0 = uv_map_[lt.tri[0]];
const float2 &uv_1 = uv_map_[looptri.tri[1]]; const float2 &uv_1 = uv_map_[lt.tri[1]];
const float2 &uv_2 = uv_map_[looptri.tri[2]]; const float2 &uv_2 = uv_map_[lt.tri[2]];
const int2 key_0 = uv_to_cell_key(uv_0, resolution_); const int2 key_0 = uv_to_cell_key(uv_0, resolution_);
const int2 key_1 = uv_to_cell_key(uv_1, resolution_); const int2 key_1 = uv_to_cell_key(uv_1, resolution_);
@ -50,7 +50,7 @@ ReverseUVSampler::Result ReverseUVSampler::sample(const float2 &query_uv) const
float best_dist = FLT_MAX; float best_dist = FLT_MAX;
float3 best_bary_weights; float3 best_bary_weights;
int best_looptri; int best_looptri_index;
/* The distance to an edge that is allowed to be inside or outside the triangle. Without this, /* The distance to an edge that is allowed to be inside or outside the triangle. Without this,
* the lookup can fail for floating point accuracy reasons when the uv is almost exact on an * the lookup can fail for floating point accuracy reasons when the uv is almost exact on an
@ -58,10 +58,10 @@ ReverseUVSampler::Result ReverseUVSampler::sample(const float2 &query_uv) const
const float edge_epsilon = 0.00001f; const float edge_epsilon = 0.00001f;
for (const int looptri_index : looptri_indices) { for (const int looptri_index : looptri_indices) {
const MLoopTri &looptri = looptris_[looptri_index]; const MLoopTri &lt = looptris_[looptri_index];
const float2 &uv_0 = uv_map_[looptri.tri[0]]; const float2 &uv_0 = uv_map_[lt.tri[0]];
const float2 &uv_1 = uv_map_[looptri.tri[1]]; const float2 &uv_1 = uv_map_[lt.tri[1]];
const float2 &uv_2 = uv_map_[looptri.tri[2]]; const float2 &uv_2 = uv_map_[lt.tri[2]];
float3 bary_weights; float3 bary_weights;
if (!barycentric_coords_v2(uv_0, uv_1, uv_2, query_uv, bary_weights)) { if (!barycentric_coords_v2(uv_0, uv_1, uv_2, query_uv, bary_weights)) {
continue; continue;
@ -86,14 +86,14 @@ ReverseUVSampler::Result ReverseUVSampler::sample(const float2 &query_uv) const
if (dist < best_dist) { if (dist < best_dist) {
best_dist = dist; best_dist = dist;
best_bary_weights = bary_weights; best_bary_weights = bary_weights;
best_looptri = looptri_index; best_looptri_index = looptri_index;
} }
} }
/* Allow using the closest (but not intersecting) triangle if the uv is almost exactly on an /* Allow using the closest (but not intersecting) triangle if the uv is almost exactly on an
* edge. */ * edge. */
if (best_dist < edge_epsilon) { if (best_dist < edge_epsilon) {
return Result{ResultType::Ok, best_looptri, math::clamp(best_bary_weights, 0.0f, 1.0f)}; return Result{ResultType::Ok, best_looptri_index, math::clamp(best_bary_weights, 0.0f, 1.0f)};
} }
return Result{}; return Result{};

@ -1499,9 +1499,9 @@ static void feat_data_sum_reduce(const void *__restrict /*userdata*/,
feat_chunk_join->feat_edges += feat_chunk->feat_edges; feat_chunk_join->feat_edges += feat_chunk->feat_edges;
} }
static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata, static void lineart_identify_looptri_feature_edges(void *__restrict userdata,
const int i, const int i,
const TaskParallelTLS *__restrict tls) const TaskParallelTLS *__restrict tls)
{ {
EdgeFeatData *e_feat_data = (EdgeFeatData *)userdata; EdgeFeatData *e_feat_data = (EdgeFeatData *)userdata;
EdgeFeatReduceData *reduce_data = (EdgeFeatReduceData *)tls->userdata_chunk; EdgeFeatReduceData *reduce_data = (EdgeFeatReduceData *)tls->userdata_chunk;
@ -1806,7 +1806,7 @@ static void lineart_load_tri_task(void *__restrict userdata,
LineartObjectInfo *ob_info = tri_task_data->ob_info; LineartObjectInfo *ob_info = tri_task_data->ob_info;
const blender::Span<blender::float3> positions = tri_task_data->positions; const blender::Span<blender::float3> positions = tri_task_data->positions;
const blender::Span<int> corner_verts = tri_task_data->corner_verts; const blender::Span<int> corner_verts = tri_task_data->corner_verts;
const MLoopTri *looptri = &tri_task_data->looptris[i]; const MLoopTri *lt = &tri_task_data->looptris[i];
const int face_i = tri_task_data->looptri_faces[i]; const int face_i = tri_task_data->looptri_faces[i];
const blender::Span<int> material_indices = tri_task_data->material_indices; const blender::Span<int> material_indices = tri_task_data->material_indices;
@ -1815,9 +1815,9 @@ static void lineart_load_tri_task(void *__restrict userdata,
tri = (LineartTriangle *)(((uchar *)tri) + tri_task_data->lineart_triangle_size * i); tri = (LineartTriangle *)(((uchar *)tri) + tri_task_data->lineart_triangle_size * i);
int v1 = corner_verts[looptri->tri[0]]; int v1 = corner_verts[lt->tri[0]];
int v2 = corner_verts[looptri->tri[1]]; int v2 = corner_verts[lt->tri[1]];
int v3 = corner_verts[looptri->tri[2]]; int v3 = corner_verts[lt->tri[2]];
tri->v[0] = &vert_arr[v1]; tri->v[0] = &vert_arr[v1];
tri->v[1] = &vert_arr[v2]; tri->v[1] = &vert_arr[v2];
@ -1876,13 +1876,13 @@ static void lineart_edge_neighbor_init_task(void *__restrict userdata,
{ {
EdgeNeighborData *en_data = (EdgeNeighborData *)userdata; EdgeNeighborData *en_data = (EdgeNeighborData *)userdata;
LineartAdjacentEdge *adj_e = &en_data->adj_e[i]; LineartAdjacentEdge *adj_e = &en_data->adj_e[i];
const MLoopTri *looptri = &en_data->looptris[i / 3]; const MLoopTri *lt = &en_data->looptris[i / 3];
LineartEdgeNeighbor *edge_nabr = &en_data->edge_nabr[i]; LineartEdgeNeighbor *edge_nabr = &en_data->edge_nabr[i];
const blender::Span<int> corner_verts = en_data->corner_verts; const blender::Span<int> corner_verts = en_data->corner_verts;
adj_e->e = i; adj_e->e = i;
adj_e->v1 = corner_verts[looptri->tri[i % 3]]; adj_e->v1 = corner_verts[lt->tri[i % 3]];
adj_e->v2 = corner_verts[looptri->tri[(i + 1) % 3]]; adj_e->v2 = corner_verts[lt->tri[(i + 1) % 3]];
if (adj_e->v1 > adj_e->v2) { if (adj_e->v1 > adj_e->v2) {
std::swap(adj_e->v1, adj_e->v2); std::swap(adj_e->v1, adj_e->v2);
} }
@ -2126,14 +2126,14 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
BLI_task_parallel_range(0, BLI_task_parallel_range(0,
total_edges, total_edges,
&edge_feat_data, &edge_feat_data,
lineart_identify_mlooptri_feature_edges, lineart_identify_looptri_feature_edges,
&edge_feat_settings); &edge_feat_settings);
LooseEdgeData loose_data = {0}; LooseEdgeData loose_data = {0};
if (la_data->conf.use_loose) { if (la_data->conf.use_loose) {
/* Only identifying floating edges at this point because other edges has been taken care of /* Only identifying floating edges at this point because other edges has been taken care of
* inside #lineart_identify_mlooptri_feature_edges function. */ * inside #lineart_identify_looptri_feature_edges function. */
const bke::LooseEdgeCache &loose_edges = mesh->loose_edges(); const bke::LooseEdgeCache &loose_edges = mesh->loose_edges();
loose_data.loose_array = static_cast<int *>( loose_data.loose_array = static_cast<int *>(
MEM_malloc_arrayN(loose_edges.count, sizeof(int), __func__)); MEM_malloc_arrayN(loose_edges.count, sizeof(int), __func__));

@ -277,10 +277,10 @@ void gather_corner_data(const Span<MLoopTri> looptris,
MutableSpan<T> dst_data) MutableSpan<T> dst_data)
{ {
triangles.foreach_index_optimized<int>(GrainSize(1024), [&](const int src, const int dst) { triangles.foreach_index_optimized<int>(GrainSize(1024), [&](const int src, const int dst) {
const MLoopTri &tri = looptris[src]; const MLoopTri &lt = looptris[src];
dst_data[dst * 3 + 0] = src_data[tri.tri[0]]; dst_data[dst * 3 + 0] = src_data[lt.tri[0]];
dst_data[dst * 3 + 1] = src_data[tri.tri[1]]; dst_data[dst * 3 + 1] = src_data[lt.tri[1]];
dst_data[dst * 3 + 2] = src_data[tri.tri[2]]; dst_data[dst * 3 + 2] = src_data[lt.tri[2]];
}); });
} }
@ -315,10 +315,10 @@ static void copy_submesh(const Mesh &mesh,
* for vertices actually used by the subset of triangles. */ * for vertices actually used by the subset of triangles. */
verts.reserve(triangles.size()); verts.reserve(triangles.size());
triangles.foreach_index([&](const int src, const int dst) { triangles.foreach_index([&](const int src, const int dst) {
const MLoopTri &tri = looptris[src]; const MLoopTri &lt = looptris[src];
sm.face_vertex_indices[dst * 3 + 0] = verts.index_of_or_add(corner_verts[tri.tri[0]]); sm.face_vertex_indices[dst * 3 + 0] = verts.index_of_or_add(corner_verts[lt.tri[0]]);
sm.face_vertex_indices[dst * 3 + 1] = verts.index_of_or_add(corner_verts[tri.tri[1]]); sm.face_vertex_indices[dst * 3 + 1] = verts.index_of_or_add(corner_verts[lt.tri[1]]);
sm.face_vertex_indices[dst * 3 + 2] = verts.index_of_or_add(corner_verts[tri.tri[2]]); sm.face_vertex_indices[dst * 3 + 2] = verts.index_of_or_add(corner_verts[lt.tri[2]]);
}); });
dst_verts_num = verts.size(); dst_verts_num = verts.size();
} }
@ -343,10 +343,10 @@ static void copy_submesh(const Mesh &mesh,
break; break;
case bke::MeshNormalDomain::Point: case bke::MeshNormalDomain::Point:
triangles.foreach_index(GrainSize(1024), [&](const int src, const int dst) { triangles.foreach_index(GrainSize(1024), [&](const int src, const int dst) {
const MLoopTri &tri = looptris[src]; const MLoopTri &lt = looptris[src];
dst_normals[dst * 3 + 0] = src_normals[corner_verts[tri.tri[0]]]; dst_normals[dst * 3 + 0] = src_normals[corner_verts[lt.tri[0]]];
dst_normals[dst * 3 + 1] = src_normals[corner_verts[tri.tri[1]]]; dst_normals[dst * 3 + 1] = src_normals[corner_verts[lt.tri[1]]];
dst_normals[dst * 3 + 2] = src_normals[corner_verts[tri.tri[2]]]; dst_normals[dst * 3 + 2] = src_normals[corner_verts[lt.tri[2]]];
}); });
break; break;
case bke::MeshNormalDomain::Corner: case bke::MeshNormalDomain::Corner:

@ -69,22 +69,22 @@ enum {
* \code{.cc} * \code{.cc}
* // Access vertex locations. * // Access vertex locations.
* std::array<float3, 3> tri_positions{ * std::array<float3, 3> tri_positions{
* positions[corner_verts[tri.tri[0]]], * positions[corner_verts[lt.tri[0]]],
* positions[corner_verts[tri.tri[1]]], * positions[corner_verts[lt.tri[1]]],
* positions[corner_verts[tri.tri[2]]], * positions[corner_verts[lt.tri[2]]],
* }; * };
* *
* // Access UV coordinates (works for all face corner data, vertex colors... etc). * // Access UV coordinates (works for all face corner data, vertex colors... etc).
* std::array<float2, 3> tri_uvs{ * std::array<float2, 3> tri_uvs{
* uv_map[tri.tri[0]], * uv_map[lt.tri[0]],
* uv_map[tri.tri[1]], * uv_map[lt.tri[1]],
* uv_map[tri.tri[2]], * uv_map[lt.tri[2]],
* }; * };
* *
* // Access all triangles in a given face. * // Access all triangles in a given face.
* const IndexRange face = faces[i]; * const IndexRange face = faces[i];
* const Span<MLoopTri> face_tris = looptris.slice(poly_to_tri_count(i, face.start()), * const Span<MLoopTri> looptris = looptris.slice(poly_to_tri_count(i, face.start()),
* bke::mesh::face_triangles_num(face.size())); * bke::mesh::face_triangles_num(face.size()));
* \endcode * \endcode
* *
* It may also be useful to check whether or not two vertices of a triangle form an edge in the * It may also be useful to check whether or not two vertices of a triangle form an edge in the

Some files were not shown because too many files have changed in this diff Show More