Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_tessellate.cc')
-rw-r--r--source/blender/blenkernel/intern/mesh_tessellate.cc62
1 files changed, 32 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/mesh_tessellate.cc b/source/blender/blenkernel/intern/mesh_tessellate.cc
index df83743634c..eaef90dec9b 100644
--- a/source/blender/blenkernel/intern/mesh_tessellate.cc
+++ b/source/blender/blenkernel/intern/mesh_tessellate.cc
@@ -42,7 +42,7 @@
*/
BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop,
const MPoly *mpoly,
- const MVert *mvert,
+ const float (*positions)[3],
uint poly_index,
MLoopTri *mlt,
MemArena **pf_arena_p,
@@ -72,17 +72,17 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop,
if (UNLIKELY(face_normal ? is_quad_flip_v3_first_third_fast_with_normal(
/* Simpler calculation (using the normal). */
- mvert[mloop[mlt_a->tri[0]].v].co,
- mvert[mloop[mlt_a->tri[1]].v].co,
- mvert[mloop[mlt_a->tri[2]].v].co,
- mvert[mloop[mlt_b->tri[2]].v].co,
+ positions[mloop[mlt_a->tri[0]].v],
+ positions[mloop[mlt_a->tri[1]].v],
+ positions[mloop[mlt_a->tri[2]].v],
+ positions[mloop[mlt_b->tri[2]].v],
normal_precalc) :
is_quad_flip_v3_first_third_fast(
/* Expensive calculation (no normal). */
- mvert[mloop[mlt_a->tri[0]].v].co,
- mvert[mloop[mlt_a->tri[1]].v].co,
- mvert[mloop[mlt_a->tri[2]].v].co,
- mvert[mloop[mlt_b->tri[2]].v].co))) {
+ positions[mloop[mlt_a->tri[0]].v],
+ positions[mloop[mlt_a->tri[1]].v],
+ positions[mloop[mlt_a->tri[2]].v],
+ positions[mloop[mlt_b->tri[2]].v]))) {
/* Flip out of degenerate 0-2 state. */
mlt_a->tri[2] = mlt_b->tri[2];
mlt_b->tri[0] = mlt_a->tri[1];
@@ -102,9 +102,9 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop,
/* Calc normal, flipped: to get a positive 2D cross product. */
ml = mloop + mp_loopstart;
- co_prev = mvert[ml[mp_totloop - 1].v].co;
+ co_prev = positions[ml[mp_totloop - 1].v];
for (uint j = 0; j < mp_totloop; j++, ml++) {
- co_curr = mvert[ml->v].co;
+ co_curr = positions[ml->v];
add_newell_cross_v3_v3v3(normal, co_prev, co_curr);
co_prev = co_curr;
}
@@ -131,7 +131,7 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop,
ml = mloop + mp_loopstart;
for (uint j = 0; j < mp_totloop; j++, ml++) {
- mul_v2_m3v3(projverts[j], axis_mat, mvert[ml->v].co);
+ mul_v2_m3v3(projverts[j], axis_mat, positions[ml->v]);
}
BLI_polyfill_calc_arena(projverts, mp_totloop, 1, tris, pf_arena);
@@ -152,30 +152,30 @@ BLI_INLINE void mesh_calc_tessellation_for_face_impl(const MLoop *mloop,
static void mesh_calc_tessellation_for_face(const MLoop *mloop,
const MPoly *mpoly,
- const MVert *mvert,
+ const float (*positions)[3],
uint poly_index,
MLoopTri *mlt,
MemArena **pf_arena_p)
{
mesh_calc_tessellation_for_face_impl(
- mloop, mpoly, mvert, poly_index, mlt, pf_arena_p, false, nullptr);
+ mloop, mpoly, positions, poly_index, mlt, pf_arena_p, false, nullptr);
}
static void mesh_calc_tessellation_for_face_with_normal(const MLoop *mloop,
const MPoly *mpoly,
- const MVert *mvert,
+ const float (*positions)[3],
uint poly_index,
MLoopTri *mlt,
MemArena **pf_arena_p,
const float normal_precalc[3])
{
mesh_calc_tessellation_for_face_impl(
- mloop, mpoly, mvert, poly_index, mlt, pf_arena_p, true, normal_precalc);
+ mloop, mpoly, positions, poly_index, mlt, pf_arena_p, true, normal_precalc);
}
static void mesh_recalc_looptri__single_threaded(const MLoop *mloop,
const MPoly *mpoly,
- const MVert *mvert,
+ const float (*positions)[3],
int totloop,
int totpoly,
MLoopTri *mlooptri,
@@ -189,7 +189,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop,
for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) {
mesh_calc_tessellation_for_face_with_normal(mloop,
mpoly,
- mvert,
+ positions,
poly_index,
&mlooptri[tri_index],
&pf_arena,
@@ -200,7 +200,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop,
else {
for (uint poly_index = 0; poly_index < uint(totpoly); poly_index++, mp++) {
mesh_calc_tessellation_for_face(
- mloop, mpoly, mvert, poly_index, &mlooptri[tri_index], &pf_arena);
+ mloop, mpoly, positions, poly_index, &mlooptri[tri_index], &pf_arena);
tri_index += uint(mp->totloop - 2);
}
}
@@ -216,7 +216,7 @@ static void mesh_recalc_looptri__single_threaded(const MLoop *mloop,
struct TessellationUserData {
const MLoop *mloop;
const MPoly *mpoly;
- const MVert *mvert;
+ const float (*positions)[3];
/** Output array. */
MLoopTri *mlooptri;
@@ -238,7 +238,7 @@ static void mesh_calc_tessellation_for_face_fn(void *__restrict userdata,
const int tri_index = poly_to_tri_count(index, data->mpoly[index].loopstart);
mesh_calc_tessellation_for_face_impl(data->mloop,
data->mpoly,
- data->mvert,
+ data->positions,
uint(index),
&data->mlooptri[tri_index],
&tls_data->pf_arena,
@@ -255,7 +255,7 @@ static void mesh_calc_tessellation_for_face_with_normal_fn(void *__restrict user
const int tri_index = poly_to_tri_count(index, data->mpoly[index].loopstart);
mesh_calc_tessellation_for_face_impl(data->mloop,
data->mpoly,
- data->mvert,
+ data->positions,
uint(index),
&data->mlooptri[tri_index],
&tls_data->pf_arena,
@@ -274,7 +274,7 @@ static void mesh_calc_tessellation_for_face_free_fn(const void *__restrict /*use
static void mesh_recalc_looptri__multi_threaded(const MLoop *mloop,
const MPoly *mpoly,
- const MVert *mvert,
+ const float (*positions)[3],
int /*totloop*/,
int totpoly,
MLoopTri *mlooptri,
@@ -286,7 +286,7 @@ static void mesh_recalc_looptri__multi_threaded(const MLoop *mloop,
};
data.mloop = mloop;
data.mpoly = mpoly;
- data.mvert = mvert;
+ data.positions = positions;
data.mlooptri = mlooptri;
data.poly_normals = poly_normals;
@@ -308,22 +308,24 @@ static void mesh_recalc_looptri__multi_threaded(const MLoop *mloop,
void BKE_mesh_recalc_looptri(const MLoop *mloop,
const MPoly *mpoly,
- const MVert *mvert,
+ const float (*positions)[3],
int totloop,
int totpoly,
MLoopTri *mlooptri)
{
if (totloop < MESH_FACE_TESSELLATE_THREADED_LIMIT) {
- mesh_recalc_looptri__single_threaded(mloop, mpoly, mvert, totloop, totpoly, mlooptri, nullptr);
+ mesh_recalc_looptri__single_threaded(
+ mloop, mpoly, positions, totloop, totpoly, mlooptri, nullptr);
}
else {
- mesh_recalc_looptri__multi_threaded(mloop, mpoly, mvert, totloop, totpoly, mlooptri, nullptr);
+ mesh_recalc_looptri__multi_threaded(
+ mloop, mpoly, positions, totloop, totpoly, mlooptri, nullptr);
}
}
void BKE_mesh_recalc_looptri_with_normals(const MLoop *mloop,
const MPoly *mpoly,
- const MVert *mvert,
+ const float (*positions)[3],
int totloop,
int totpoly,
MLoopTri *mlooptri,
@@ -332,11 +334,11 @@ void BKE_mesh_recalc_looptri_with_normals(const MLoop *mloop,
BLI_assert(poly_normals != nullptr);
if (totloop < MESH_FACE_TESSELLATE_THREADED_LIMIT) {
mesh_recalc_looptri__single_threaded(
- mloop, mpoly, mvert, totloop, totpoly, mlooptri, poly_normals);
+ mloop, mpoly, positions, totloop, totpoly, mlooptri, poly_normals);
}
else {
mesh_recalc_looptri__multi_threaded(
- mloop, mpoly, mvert, totloop, totpoly, mlooptri, poly_normals);
+ mloop, mpoly, positions, totloop, totpoly, mlooptri, poly_normals);
}
}