Cleanup: Mesh: Access looptris with Span #105297
|
@ -580,7 +580,7 @@ static void bvhtree_from_mesh_setup_data(BVHTree *tree,
|
|||
const MEdge *edge,
|
||||
const MFace *face,
|
||||
const MLoop *loop,
|
||||
const MLoopTri *looptri,
|
||||
const Span<MLoopTri> looptris,
|
||||
BVHTreeFromMesh *r_data)
|
||||
{
|
||||
memset(r_data, 0, sizeof(*r_data));
|
||||
|
@ -591,7 +591,7 @@ static void bvhtree_from_mesh_setup_data(BVHTree *tree,
|
|||
r_data->edge = edge;
|
||||
r_data->face = face;
|
||||
r_data->loop = loop;
|
||||
r_data->looptri = looptri;
|
||||
r_data->looptri = looptris.data();
|
||||
|
||||
switch (bvh_cache_type) {
|
||||
case BVHTREE_FROM_VERTS:
|
||||
|
@ -779,7 +779,7 @@ BVHTree *bvhtree_from_mesh_verts_ex(BVHTreeFromMesh *data,
|
|||
if (data) {
|
||||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_VERTS, vert_positions, nullptr, nullptr, nullptr, nullptr, data);
|
||||
tree, BVHTREE_FROM_VERTS, vert_positions, nullptr, nullptr, nullptr, {}, data);
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -914,7 +914,7 @@ BVHTree *bvhtree_from_mesh_edges_ex(BVHTreeFromMesh *data,
|
|||
if (data) {
|
||||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_EDGES, vert_positions, edge, nullptr, nullptr, nullptr, data);
|
||||
tree, BVHTREE_FROM_EDGES, vert_positions, edge, nullptr, nullptr, {}, data);
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -1037,16 +1037,15 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(float epsilon,
|
|||
int axis,
|
||||
const float (*positions)[3],
|
||||
const MLoop *mloop,
|
||||
const MLoopTri *looptri,
|
||||
const int looptri_num,
|
||||
const Span<MLoopTri> looptris,
|
||||
const BitSpan looptri_mask,
|
||||
int looptri_num_active)
|
||||
{
|
||||
if (!looptri_mask.is_empty()) {
|
||||
BLI_assert(IN_RANGE_INCL(looptri_num_active, 0, looptri_num));
|
||||
BLI_assert(IN_RANGE_INCL(looptri_num_active, 0, looptris.size()));
|
||||
}
|
||||
else {
|
||||
looptri_num_active = looptri_num;
|
||||
looptri_num_active = looptris.size();
|
||||
}
|
||||
if (looptri_num_active == 0) {
|
||||
return nullptr;
|
||||
|
@ -1059,16 +1058,16 @@ static BVHTree *bvhtree_from_mesh_looptri_create_tree(float epsilon,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (positions && looptri) {
|
||||
for (int i = 0; i < looptri_num; i++) {
|
||||
if (positions && !looptris.is_empty()) {
|
||||
for (const int i : looptris.index_range()) {
|
||||
float co[3][3];
|
||||
if (!looptri_mask.is_empty() && !looptri_mask[i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
copy_v3_v3(co[0], positions[mloop[looptri[i].tri[0]].v]);
|
||||
copy_v3_v3(co[1], positions[mloop[looptri[i].tri[1]].v]);
|
||||
copy_v3_v3(co[2], positions[mloop[looptri[i].tri[2]].v]);
|
||||
copy_v3_v3(co[0], positions[mloop[looptris[i].tri[0]].v]);
|
||||
copy_v3_v3(co[1], positions[mloop[looptris[i].tri[1]].v]);
|
||||
copy_v3_v3(co[2], positions[mloop[looptris[i].tri[2]].v]);
|
||||
|
||||
BLI_bvhtree_insert(tree, i, co[0], 3);
|
||||
}
|
||||
|
@ -1121,8 +1120,7 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
|
|||
axis,
|
||||
vert_positions,
|
||||
mloop,
|
||||
looptri,
|
||||
looptri_num,
|
||||
{looptri, looptri_num},
|
||||
looptri_mask,
|
||||
looptri_num_active);
|
||||
|
||||
|
@ -1130,8 +1128,14 @@ BVHTree *bvhtree_from_mesh_looptri_ex(BVHTreeFromMesh *data,
|
|||
|
||||
if (data) {
|
||||
/* Setup BVHTreeFromMesh */
|
||||
bvhtree_from_mesh_setup_data(
|
||||
tree, BVHTREE_FROM_LOOPTRI, vert_positions, nullptr, nullptr, mloop, looptri, data);
|
||||
bvhtree_from_mesh_setup_data(tree,
|
||||
BVHTREE_FROM_LOOPTRI,
|
||||
vert_positions,
|
||||
nullptr,
|
||||
nullptr,
|
||||
mloop,
|
||||
{looptri, looptri_num},
|
||||
data);
|
||||
}
|
||||
|
||||
return tree;
|
||||
|
@ -1208,11 +1212,9 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
|
|||
{
|
||||
BVHCache **bvh_cache_p = (BVHCache **)&mesh->runtime->bvh_cache;
|
||||
|
||||
const MLoopTri *looptri = nullptr;
|
||||
int looptri_len = 0;
|
||||
Span<MLoopTri> looptris;
|
||||
if (ELEM(bvh_cache_type, BVHTREE_FROM_LOOPTRI, BVHTREE_FROM_LOOPTRI_NO_HIDDEN)) {
|
||||
looptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
looptri_len = BKE_mesh_runtime_looptri_len(mesh);
|
||||
looptris = mesh->looptris();
|
||||
}
|
||||
const float(*positions)[3] = reinterpret_cast<const float(*)[3]>(mesh->vert_positions().data());
|
||||
const Span<MEdge> edges = mesh->edges();
|
||||
|
@ -1225,7 +1227,7 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
|
|||
edges.data(),
|
||||
(const MFace *)CustomData_get_layer(&mesh->fdata, CD_MFACE),
|
||||
loops.data(),
|
||||
looptri,
|
||||
looptris,
|
||||
data);
|
||||
|
||||
bool lock_started = false;
|
||||
|
@ -1278,20 +1280,13 @@ BVHTree *BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data,
|
|||
mask = looptri_no_hidden_map_get(
|
||||
mesh->polys(),
|
||||
attributes.lookup_or_default(".hide_poly", ATTR_DOMAIN_FACE, false),
|
||||
looptri_len,
|
||||
looptris.size(),
|
||||
&mask_bits_act_len);
|
||||
ATTR_FALLTHROUGH;
|
||||
}
|
||||
case BVHTREE_FROM_LOOPTRI:
|
||||
data->tree = bvhtree_from_mesh_looptri_create_tree(0.0f,
|
||||
tree_type,
|
||||
6,
|
||||
positions,
|
||||
loops.data(),
|
||||
looptri,
|
||||
looptri_len,
|
||||
mask,
|
||||
mask_bits_act_len);
|
||||
data->tree = bvhtree_from_mesh_looptri_create_tree(
|
||||
0.0f, tree_type, 6, positions, loops.data(), looptris, mask, mask_bits_act_len);
|
||||
break;
|
||||
case BVHTREE_FROM_EM_VERTS:
|
||||
case BVHTREE_FROM_EM_EDGES:
|
||||
|
|
|
@ -836,9 +836,8 @@ static bool cloth_from_object(
|
|||
static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mesh)
|
||||
{
|
||||
const blender::Span<MLoop> loops = mesh->loops();
|
||||
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
const blender::Span<MLoopTri> looptris = mesh->looptris();
|
||||
const uint mvert_num = mesh->totvert;
|
||||
const uint looptri_num = BKE_mesh_runtime_looptri_len(mesh);
|
||||
|
||||
/* Allocate our vertices. */
|
||||
clmd->clothObject->mvert_num = mvert_num;
|
||||
|
@ -853,14 +852,14 @@ static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mes
|
|||
|
||||
/* save face information */
|
||||
if (clmd->hairdata == nullptr) {
|
||||
clmd->clothObject->primitive_num = looptri_num;
|
||||
clmd->clothObject->primitive_num = looptris.size();
|
||||
}
|
||||
else {
|
||||
clmd->clothObject->primitive_num = mesh->totedge;
|
||||
}
|
||||
|
||||
clmd->clothObject->tri = static_cast<MVertTri *>(
|
||||
MEM_malloc_arrayN(looptri_num, sizeof(MVertTri), __func__));
|
||||
MEM_malloc_arrayN(looptris.size(), sizeof(MVertTri), __func__));
|
||||
if (clmd->clothObject->tri == nullptr) {
|
||||
cloth_free_modifier(clmd);
|
||||
BKE_modifier_set_error(
|
||||
|
@ -869,7 +868,7 @@ static void cloth_from_mesh(ClothModifierData *clmd, const Object *ob, Mesh *mes
|
|||
return;
|
||||
}
|
||||
BKE_mesh_runtime_verttri_from_looptri(
|
||||
clmd->clothObject->tri, loops.data(), looptri, looptri_num);
|
||||
clmd->clothObject->tri, loops.data(), looptris.data(), looptris.size());
|
||||
|
||||
clmd->clothObject->edges = mesh->edges().data();
|
||||
|
||||
|
|
|
@ -1481,7 +1481,7 @@ struct DynamicPaintSetInitColorData {
|
|||
|
||||
blender::Span<MLoop> loops;
|
||||
const float (*mloopuv)[2];
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
const MLoopCol *mloopcol;
|
||||
ImagePool *pool;
|
||||
|
||||
|
@ -1498,7 +1498,7 @@ static void dynamic_paint_set_init_color_tex_to_vcol_cb(void *__restrict userdat
|
|||
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
|
||||
|
||||
const blender::Span<MLoop> loops = data->loops;
|
||||
const MLoopTri *mlooptri = data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = data->looptris;
|
||||
const float(*mloopuv)[2] = data->mloopuv;
|
||||
ImagePool *pool = data->pool;
|
||||
Tex *tex = data->surface->init_texture;
|
||||
|
@ -1509,11 +1509,11 @@ static void dynamic_paint_set_init_color_tex_to_vcol_cb(void *__restrict userdat
|
|||
|
||||
for (int j = 3; j--;) {
|
||||
TexResult texres = {0};
|
||||
const uint vert = loops[mlooptri[i].tri[j]].v;
|
||||
const uint vert = loops[looptris[i].tri[j]].v;
|
||||
|
||||
/* remap to [-1.0, 1.0] */
|
||||
uv[0] = mloopuv[mlooptri[i].tri[j]][0] * 2.0f - 1.0f;
|
||||
uv[1] = mloopuv[mlooptri[i].tri[j]][1] * 2.0f - 1.0f;
|
||||
uv[0] = mloopuv[looptris[i].tri[j]][0] * 2.0f - 1.0f;
|
||||
uv[1] = mloopuv[looptris[i].tri[j]][1] * 2.0f - 1.0f;
|
||||
|
||||
multitex_ext_safe(tex, uv, &texres, pool, scene_color_manage, false);
|
||||
|
||||
|
@ -1533,7 +1533,7 @@ static void dynamic_paint_set_init_color_tex_to_imseq_cb(void *__restrict userda
|
|||
const PaintSurfaceData *sData = data->surface->data;
|
||||
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
|
||||
|
||||
const MLoopTri *mlooptri = data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = data->looptris;
|
||||
const float(*mloopuv)[2] = data->mloopuv;
|
||||
Tex *tex = data->surface->init_texture;
|
||||
ImgSeqFormatData *f_data = (ImgSeqFormatData *)sData->format_data;
|
||||
|
@ -1548,7 +1548,7 @@ static void dynamic_paint_set_init_color_tex_to_imseq_cb(void *__restrict userda
|
|||
|
||||
/* collect all uvs */
|
||||
for (int j = 3; j--;) {
|
||||
copy_v2_v2(&uv[j * 3], mloopuv[mlooptri[f_data->uv_p[i].tri_index].tri[j]]);
|
||||
copy_v2_v2(&uv[j * 3], mloopuv[looptris[f_data->uv_p[i].tri_index].tri[j]]);
|
||||
}
|
||||
|
||||
/* interpolate final uv pos */
|
||||
|
@ -1572,7 +1572,7 @@ static void dynamic_paint_set_init_color_vcol_to_imseq_cb(
|
|||
const PaintSurfaceData *sData = data->surface->data;
|
||||
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
|
||||
|
||||
const MLoopTri *mlooptri = data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = data->looptris;
|
||||
const MLoopCol *mloopcol = data->mloopcol;
|
||||
ImgSeqFormatData *f_data = (ImgSeqFormatData *)sData->format_data;
|
||||
const int samples = (data->surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1;
|
||||
|
@ -1583,7 +1583,7 @@ static void dynamic_paint_set_init_color_vcol_to_imseq_cb(
|
|||
|
||||
/* collect color values */
|
||||
for (int j = 3; j--;) {
|
||||
rgba_uchar_to_float(colors[j], (const uchar *)&mloopcol[mlooptri[tri_idx].tri[j]].r);
|
||||
rgba_uchar_to_float(colors[j], (const uchar *)&mloopcol[looptris[tri_idx].tri[j]].r);
|
||||
}
|
||||
|
||||
/* interpolate final color */
|
||||
|
@ -1619,8 +1619,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
|
|||
Tex *tex = surface->init_texture;
|
||||
|
||||
const blender::Span<MLoop> loops = mesh->loops();
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
const int tottri = BKE_mesh_runtime_looptri_len(mesh);
|
||||
const blender::Span<MLoopTri> looptris = mesh->looptris();
|
||||
|
||||
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
|
||||
|
@ -1645,22 +1644,22 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
|
|||
DynamicPaintSetInitColorData data{};
|
||||
data.surface = surface;
|
||||
data.loops = loops;
|
||||
data.mlooptri = mlooptri;
|
||||
data.looptris = looptris;
|
||||
data.mloopuv = mloopuv;
|
||||
data.pool = pool;
|
||||
data.scene_color_manage = scene_color_manage;
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BLI_parallel_range_settings_defaults(&settings);
|
||||
settings.use_threading = (tottri > 1000);
|
||||
settings.use_threading = (looptris.size() > 1000);
|
||||
BLI_task_parallel_range(
|
||||
0, tottri, &data, dynamic_paint_set_init_color_tex_to_vcol_cb, &settings);
|
||||
0, looptris.size(), &data, dynamic_paint_set_init_color_tex_to_vcol_cb, &settings);
|
||||
BKE_image_pool_free(pool);
|
||||
}
|
||||
else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
|
||||
DynamicPaintSetInitColorData data{};
|
||||
data.surface = surface;
|
||||
data.mlooptri = mlooptri;
|
||||
data.looptris = looptris;
|
||||
data.mloopuv = mloopuv;
|
||||
data.scene_color_manage = scene_color_manage;
|
||||
|
||||
|
@ -1688,7 +1687,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
|
|||
}
|
||||
}
|
||||
else if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
const blender::Span<MLoopTri> looptris = mesh->looptris();
|
||||
const MLoopCol *col = static_cast<const MLoopCol *>(
|
||||
CustomData_get_layer_named(&mesh->ldata, CD_PROP_BYTE_COLOR, surface->init_layername));
|
||||
if (!col) {
|
||||
|
@ -1697,7 +1696,7 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
|
|||
|
||||
DynamicPaintSetInitColorData data{};
|
||||
data.surface = surface;
|
||||
data.mlooptri = mlooptri;
|
||||
data.looptris = looptris;
|
||||
data.mloopcol = col;
|
||||
|
||||
TaskParallelSettings settings;
|
||||
|
@ -2192,10 +2191,9 @@ struct DynamicPaintCreateUVSurfaceData {
|
|||
PaintUVPoint *tempPoints;
|
||||
Vec3f *tempWeights;
|
||||
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
const float (*mloopuv)[2];
|
||||
blender::Span<MLoop> loops;
|
||||
int tottri;
|
||||
|
||||
const Bounds2D *faceBB;
|
||||
uint32_t *active_points;
|
||||
|
@ -2212,10 +2210,9 @@ static void dynamic_paint_create_uv_surface_direct_cb(void *__restrict userdata,
|
|||
PaintUVPoint *tempPoints = data->tempPoints;
|
||||
Vec3f *tempWeights = data->tempWeights;
|
||||
|
||||
const MLoopTri *mlooptri = data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = data->looptris;
|
||||
const float(*mloopuv)[2] = data->mloopuv;
|
||||
const blender::Span<MLoop> loops = data->loops;
|
||||
const int tottri = data->tottri;
|
||||
|
||||
const Bounds2D *faceBB = data->faceBB;
|
||||
|
||||
|
@ -2259,16 +2256,16 @@ static void dynamic_paint_create_uv_surface_direct_cb(void *__restrict userdata,
|
|||
/* Loop through every face in the mesh */
|
||||
/* XXX TODO: This is *horrible* with big meshes, should use a 2D BVHTree over UV tris here!
|
||||
*/
|
||||
for (int i = 0; i < tottri; i++) {
|
||||
for (const int i : looptris.index_range()) {
|
||||
/* Check uv bb */
|
||||
if ((faceBB[i].min[0] > point[sample][0]) || (faceBB[i].min[1] > point[sample][1]) ||
|
||||
(faceBB[i].max[0] < point[sample][0]) || (faceBB[i].max[1] < point[sample][1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const float *uv1 = mloopuv[mlooptri[i].tri[0]];
|
||||
const float *uv2 = mloopuv[mlooptri[i].tri[1]];
|
||||
const float *uv3 = mloopuv[mlooptri[i].tri[2]];
|
||||
const float *uv1 = mloopuv[looptris[i].tri[0]];
|
||||
const float *uv2 = mloopuv[looptris[i].tri[1]];
|
||||
const float *uv3 = mloopuv[looptris[i].tri[2]];
|
||||
|
||||
/* If point is inside the face */
|
||||
if (isect_point_tri_v2(point[sample], uv1, uv2, uv3) != 0) {
|
||||
|
@ -2286,9 +2283,9 @@ static void dynamic_paint_create_uv_surface_direct_cb(void *__restrict userdata,
|
|||
tPoint->tri_index = i;
|
||||
|
||||
/* save vertex indexes */
|
||||
tPoint->v1 = loops[mlooptri[i].tri[0]].v;
|
||||
tPoint->v2 = loops[mlooptri[i].tri[1]].v;
|
||||
tPoint->v3 = loops[mlooptri[i].tri[2]].v;
|
||||
tPoint->v1 = loops[looptris[i].tri[0]].v;
|
||||
tPoint->v2 = loops[looptris[i].tri[1]].v;
|
||||
tPoint->v3 = loops[looptris[i].tri[2]].v;
|
||||
|
||||
sample = 5; /* make sure we exit sample loop as well */
|
||||
break;
|
||||
|
@ -2309,7 +2306,7 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(void *__restrict userdat
|
|||
PaintUVPoint *tempPoints = data->tempPoints;
|
||||
Vec3f *tempWeights = data->tempWeights;
|
||||
|
||||
const MLoopTri *mlooptri = data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = data->looptris;
|
||||
const float(*mloopuv)[2] = data->mloopuv;
|
||||
const blender::Span<MLoop> loops = data->loops;
|
||||
|
||||
|
@ -2351,9 +2348,9 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(void *__restrict userdat
|
|||
if (tempPoints[ind].neighbor_pixel == -1 && tempPoints[ind].tri_index != -1) {
|
||||
float uv[2];
|
||||
const int i = tempPoints[ind].tri_index;
|
||||
const float *uv1 = mloopuv[mlooptri[i].tri[0]];
|
||||
const float *uv2 = mloopuv[mlooptri[i].tri[1]];
|
||||
const float *uv3 = mloopuv[mlooptri[i].tri[2]];
|
||||
const float *uv1 = mloopuv[looptris[i].tri[0]];
|
||||
const float *uv2 = mloopuv[looptris[i].tri[1]];
|
||||
const float *uv3 = mloopuv[looptris[i].tri[2]];
|
||||
|
||||
/* tri index */
|
||||
/* There is a low possibility of actually having a neighbor point which tri is
|
||||
|
@ -2376,9 +2373,9 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(void *__restrict userdat
|
|||
}
|
||||
|
||||
/* save vertex indexes */
|
||||
tPoint->v1 = loops[mlooptri[i].tri[0]].v;
|
||||
tPoint->v2 = loops[mlooptri[i].tri[1]].v;
|
||||
tPoint->v3 = loops[mlooptri[i].tri[2]].v;
|
||||
tPoint->v1 = loops[looptris[i].tri[0]].v;
|
||||
tPoint->v2 = loops[looptris[i].tri[1]].v;
|
||||
tPoint->v3 = loops[looptris[i].tri[2]].v;
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -2396,7 +2393,7 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(void *__restrict userdat
|
|||
|
||||
#undef JITTER_SAMPLES
|
||||
|
||||
static float dist_squared_to_looptri_uv_edges(const MLoopTri *mlooptri,
|
||||
static float dist_squared_to_looptri_uv_edges(const blender::Span<MLoopTri> looptris,
|
||||
const float (*mloopuv)[2],
|
||||
int tri_index,
|
||||
const float point[2])
|
||||
|
@ -2408,8 +2405,8 @@ static float dist_squared_to_looptri_uv_edges(const MLoopTri *mlooptri,
|
|||
for (int i = 0; i < 3; i++) {
|
||||
const float dist_squared = dist_squared_to_line_segment_v2(
|
||||
point,
|
||||
mloopuv[mlooptri[tri_index].tri[(i + 0)]],
|
||||
mloopuv[mlooptri[tri_index].tri[(i + 1) % 3]]);
|
||||
mloopuv[looptris[tri_index].tri[(i + 0)]],
|
||||
mloopuv[looptris[tri_index].tri[(i + 1) % 3]]);
|
||||
|
||||
if (dist_squared < min_distance) {
|
||||
min_distance = dist_squared;
|
||||
|
@ -2520,10 +2517,10 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
|
|||
int depth)
|
||||
{
|
||||
const blender::Span<MLoop> loops = data->loops;
|
||||
const MLoopTri *mlooptri = data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = data->looptris;
|
||||
const float(*mloopuv)[2] = data->mloopuv;
|
||||
|
||||
const uint *loop_idx = mlooptri[tri_index].tri;
|
||||
const uint *loop_idx = looptris[tri_index].tri;
|
||||
|
||||
/* Enumerate all edges of the triangle, rotating the vertex list accordingly. */
|
||||
for (int edge_idx = 0; edge_idx < 3; edge_idx++) {
|
||||
|
@ -2577,7 +2574,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
|
|||
continue;
|
||||
}
|
||||
|
||||
const uint *other_loop_idx = mlooptri[lt_index].tri;
|
||||
const uint *other_loop_idx = looptris[lt_index].tri;
|
||||
|
||||
/* Check edges for match, looping in the same order as the outer loop. */
|
||||
for (int j = 0; j < 3; j++) {
|
||||
|
@ -2680,7 +2677,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 threshold = square_f(0.7f) / (w * h);
|
||||
|
||||
if (dist_squared_to_looptri_uv_edges(mlooptri, mloopuv, final_tri_index, final_pt) >
|
||||
if (dist_squared_to_looptri_uv_edges(looptris, mloopuv, final_tri_index, final_pt) >
|
||||
threshold) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2818,7 +2815,6 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
|
||||
PaintUVPoint *tempPoints = nullptr;
|
||||
Vec3f *tempWeights = nullptr;
|
||||
const MLoopTri *mlooptri = nullptr;
|
||||
const float(*mloopuv)[2] = nullptr;
|
||||
|
||||
Bounds2D *faceBB = nullptr;
|
||||
|
@ -2835,8 +2831,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
}
|
||||
|
||||
const blender::Span<MLoop> loops = mesh->loops();
|
||||
mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
const int tottri = BKE_mesh_runtime_looptri_len(mesh);
|
||||
const blender::Span<MLoopTri> looptris = mesh->looptris();
|
||||
|
||||
/* get uv map */
|
||||
if (CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
|
||||
|
@ -2859,7 +2854,8 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
/*
|
||||
* Start generating the surface
|
||||
*/
|
||||
CLOG_INFO(&LOG, 1, "Preparing UV surface of %ix%i pixels and %i tris.", w, h, tottri);
|
||||
CLOG_INFO(
|
||||
&LOG, 1, "Preparing UV surface of %ix%i pixels and %i tris.", w, h, int(looptris.size()));
|
||||
|
||||
/* Init data struct */
|
||||
if (surface->data) {
|
||||
|
@ -2893,7 +2889,8 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
* the pixel-inside-a-face search.
|
||||
*/
|
||||
if (!error) {
|
||||
faceBB = static_cast<Bounds2D *>(MEM_mallocN(tottri * sizeof(*faceBB), "MPCanvasFaceBB"));
|
||||
faceBB = static_cast<Bounds2D *>(
|
||||
MEM_malloc_arrayN(looptris.size(), sizeof(*faceBB), "MPCanvasFaceBB"));
|
||||
if (!faceBB) {
|
||||
error = true;
|
||||
}
|
||||
|
@ -2903,12 +2900,12 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
*do_update = true;
|
||||
|
||||
if (!error) {
|
||||
for (int i = 0; i < tottri; i++) {
|
||||
copy_v2_v2(faceBB[i].min, mloopuv[mlooptri[i].tri[0]]);
|
||||
copy_v2_v2(faceBB[i].max, mloopuv[mlooptri[i].tri[0]]);
|
||||
for (const int i : looptris.index_range()) {
|
||||
copy_v2_v2(faceBB[i].min, mloopuv[looptris[i].tri[0]]);
|
||||
copy_v2_v2(faceBB[i].max, mloopuv[looptris[i].tri[0]]);
|
||||
|
||||
for (int j = 1; j < 3; j++) {
|
||||
minmax_v2v2_v2(faceBB[i].min, faceBB[i].max, mloopuv[mlooptri[i].tri[j]]);
|
||||
minmax_v2v2_v2(faceBB[i].min, faceBB[i].max, mloopuv[looptris[i].tri[j]]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2920,16 +2917,15 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
data.surface = surface;
|
||||
data.tempPoints = tempPoints;
|
||||
data.tempWeights = tempWeights;
|
||||
data.mlooptri = mlooptri;
|
||||
data.looptris = looptris;
|
||||
data.mloopuv = mloopuv;
|
||||
data.loops = loops;
|
||||
data.tottri = tottri;
|
||||
data.faceBB = faceBB;
|
||||
|
||||
{
|
||||
TaskParallelSettings settings;
|
||||
BLI_parallel_range_settings_defaults(&settings);
|
||||
settings.use_threading = (h > 64 || tottri > 1000);
|
||||
settings.use_threading = (h > 64 || looptris.size() > 1000);
|
||||
BLI_task_parallel_range(0, h, &data, dynamic_paint_create_uv_surface_direct_cb, &settings);
|
||||
}
|
||||
|
||||
|
@ -2979,8 +2975,8 @@ int dynamicPaint_createUVSurface(Scene *scene,
|
|||
BKE_mesh_vert_looptri_map_create(&vert_to_looptri_map,
|
||||
&vert_to_looptri_map_mem,
|
||||
mesh->totvert,
|
||||
mlooptri,
|
||||
tottri,
|
||||
looptris.data(),
|
||||
looptris.size(),
|
||||
loops.data(),
|
||||
mesh->totloop);
|
||||
|
||||
|
@ -3439,15 +3435,15 @@ static void mesh_tris_spherecast_dp(void *userdata,
|
|||
{
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
|
||||
const float(*positions)[3] = data->vert_positions;
|
||||
const MLoopTri *mlooptri = data->looptri;
|
||||
const MLoopTri *looptris = data->looptri;
|
||||
const MLoop *loops = data->loop;
|
||||
|
||||
const float *t0, *t1, *t2;
|
||||
float dist;
|
||||
|
||||
t0 = positions[loops[mlooptri[index].tri[0]].v];
|
||||
t1 = positions[loops[mlooptri[index].tri[1]].v];
|
||||
t2 = positions[loops[mlooptri[index].tri[2]].v];
|
||||
t0 = positions[loops[looptris[index].tri[0]].v];
|
||||
t1 = positions[loops[looptris[index].tri[1]].v];
|
||||
t2 = positions[loops[looptris[index].tri[2]].v];
|
||||
|
||||
dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2);
|
||||
|
||||
|
@ -3471,14 +3467,14 @@ static void mesh_tris_nearest_point_dp(void *userdata,
|
|||
{
|
||||
const BVHTreeFromMesh *data = (BVHTreeFromMesh *)userdata;
|
||||
const float(*positions)[3] = data->vert_positions;
|
||||
const MLoopTri *mlooptri = data->looptri;
|
||||
const MLoopTri *looptris = data->looptri;
|
||||
const MLoop *loops = data->loop;
|
||||
float nearest_tmp[3], dist_sq;
|
||||
|
||||
const float *t0, *t1, *t2;
|
||||
t0 = positions[loops[mlooptri[index].tri[0]].v];
|
||||
t1 = positions[loops[mlooptri[index].tri[1]].v];
|
||||
t2 = positions[loops[mlooptri[index].tri[2]].v];
|
||||
t0 = positions[loops[looptris[index].tri[0]].v];
|
||||
t1 = positions[loops[looptris[index].tri[1]].v];
|
||||
t2 = positions[loops[looptris[index].tri[2]].v];
|
||||
|
||||
closest_on_tri_to_point_v3(nearest_tmp, co, t0, t1, t2);
|
||||
dist_sq = len_squared_v3v3(co, nearest_tmp);
|
||||
|
@ -3912,7 +3908,7 @@ struct DynamicPaintPaintData {
|
|||
Mesh *mesh;
|
||||
const float (*positions)[3];
|
||||
blender::Span<MLoop> loops;
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
float brush_radius;
|
||||
const float *avg_brushNor;
|
||||
const Vec3f *brushVelocity;
|
||||
|
@ -3946,7 +3942,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata,
|
|||
|
||||
const float(*positions)[3] = data->positions;
|
||||
const blender::Span<MLoop> loops = data->loops;
|
||||
const MLoopTri *mlooptri = data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = data->looptris;
|
||||
const float brush_radius = data->brush_radius;
|
||||
const float *avg_brushNor = data->avg_brushNor;
|
||||
const Vec3f *brushVelocity = data->brushVelocity;
|
||||
|
@ -4019,9 +4015,9 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata,
|
|||
|
||||
/* For optimization sake, hit point normal isn't calculated in ray cast loop */
|
||||
const int vtri[3] = {
|
||||
int(loops[mlooptri[hit.index].tri[0]].v),
|
||||
int(loops[mlooptri[hit.index].tri[1]].v),
|
||||
int(loops[mlooptri[hit.index].tri[2]].v),
|
||||
int(loops[looptris[hit.index].tri[0]].v),
|
||||
int(loops[looptris[hit.index].tri[1]].v),
|
||||
int(loops[looptris[hit.index].tri[2]].v),
|
||||
};
|
||||
float dot;
|
||||
|
||||
|
@ -4169,9 +4165,9 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex(void *__restrict userdata,
|
|||
float brushPointVelocity[3];
|
||||
float velocity[3];
|
||||
|
||||
const int v1 = loops[mlooptri[hitTri].tri[0]].v;
|
||||
const int v2 = loops[mlooptri[hitTri].tri[1]].v;
|
||||
const int v3 = loops[mlooptri[hitTri].tri[2]].v;
|
||||
const int v1 = loops[looptris[hitTri].tri[0]].v;
|
||||
const int v2 = loops[looptris[hitTri].tri[1]].v;
|
||||
const int v3 = loops[looptris[hitTri].tri[2]].v;
|
||||
|
||||
/* calculate barycentric weights for hit point */
|
||||
interp_weights_tri_v3(weights, positions[v1], positions[v2], positions[v3], hitCoord);
|
||||
|
@ -4270,7 +4266,6 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph,
|
|||
PaintBakeData *bData = sData->bData;
|
||||
Mesh *mesh = nullptr;
|
||||
Vec3f *brushVelocity = nullptr;
|
||||
const MLoopTri *mlooptri = nullptr;
|
||||
|
||||
if (brush->flags & MOD_DPAINT_USES_VELOCITY) {
|
||||
dynamicPaint_brushMeshCalculateVelocity(
|
||||
|
@ -4294,7 +4289,7 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph,
|
|||
mesh = BKE_mesh_copy_for_eval(brush_mesh, false);
|
||||
float(*positions)[3] = BKE_mesh_vert_positions_for_write(mesh);
|
||||
const float(*vert_normals)[3] = BKE_mesh_vert_normals_ensure(mesh);
|
||||
mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
const blender::Span<MLoopTri> looptris = mesh->looptris();
|
||||
const blender::Span<MLoop> loops = mesh->loops();
|
||||
numOfVerts = mesh->totvert;
|
||||
|
||||
|
@ -4350,7 +4345,7 @@ static bool dynamicPaint_paintMesh(Depsgraph *depsgraph,
|
|||
data.mesh = mesh;
|
||||
data.positions = positions;
|
||||
data.loops = loops;
|
||||
data.mlooptri = mlooptri;
|
||||
data.looptris = looptris;
|
||||
data.brush_radius = brush_radius;
|
||||
data.avg_brushNor = avg_brushNor;
|
||||
data.brushVelocity = brushVelocity;
|
||||
|
|
|
@ -939,7 +939,7 @@ struct ObstaclesFromDMData {
|
|||
|
||||
const float (*vert_positions)[3];
|
||||
const MLoop *mloop;
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
|
||||
BVHTreeFromMesh *tree;
|
||||
FluidObjectBB *bb;
|
||||
|
@ -974,7 +974,7 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata,
|
|||
update_velocities(data->fes,
|
||||
data->vert_positions,
|
||||
data->mloop,
|
||||
data->mlooptri,
|
||||
data->looptris.data(),
|
||||
bb->velocity,
|
||||
index,
|
||||
data->tree,
|
||||
|
@ -997,7 +997,6 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
float dt)
|
||||
{
|
||||
if (fes->mesh) {
|
||||
const MLoopTri *looptri;
|
||||
BVHTreeFromMesh tree_data = {nullptr};
|
||||
int numverts, i;
|
||||
|
||||
|
@ -1010,7 +1009,7 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
int min[3], max[3], res[3];
|
||||
|
||||
const MLoop *mloop = BKE_mesh_loops(me);
|
||||
looptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
const blender::Span<MLoopTri> looptris = me->looptris();
|
||||
numverts = me->totvert;
|
||||
|
||||
/* TODO(sebbas): Make initialization of vertex velocities optional? */
|
||||
|
@ -1074,7 +1073,7 @@ static void obstacles_from_mesh(Object *coll_ob,
|
|||
data.fes = fes;
|
||||
data.vert_positions = positions;
|
||||
data.mloop = mloop;
|
||||
data.mlooptri = looptri;
|
||||
data.looptris = looptris;
|
||||
data.tree = &tree_data;
|
||||
data.bb = bb;
|
||||
data.has_velocity = has_velocity;
|
||||
|
@ -1983,7 +1982,7 @@ struct EmitFromDMData {
|
|||
const float (*vert_positions)[3];
|
||||
const float (*vert_normals)[3];
|
||||
const MLoop *mloop;
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
const float (*mloopuv)[2];
|
||||
const MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
|
@ -2017,7 +2016,7 @@ static void emit_from_mesh_task_cb(void *__restrict userdata,
|
|||
data->vert_positions,
|
||||
data->vert_normals,
|
||||
data->mloop,
|
||||
data->mlooptri,
|
||||
data->looptris.data(),
|
||||
data->mloopuv,
|
||||
bb->influence,
|
||||
bb->velocity,
|
||||
|
@ -2067,7 +2066,7 @@ static void emit_from_mesh(
|
|||
float(*positions)[3] = BKE_mesh_vert_positions_for_write(me);
|
||||
|
||||
const MLoop *mloop = BKE_mesh_loops(me);
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
const blender::Span<MLoopTri> looptris = me->looptris();
|
||||
const int numverts = me->totvert;
|
||||
const MDeformVert *dvert = BKE_mesh_deform_verts(me);
|
||||
const float(*mloopuv)[2] = static_cast<const float(*)[2]>(
|
||||
|
@ -2144,7 +2143,7 @@ static void emit_from_mesh(
|
|||
data.vert_positions = positions;
|
||||
data.vert_normals = vert_normals;
|
||||
data.mloop = mloop;
|
||||
data.mlooptri = mlooptri;
|
||||
data.looptris = looptris;
|
||||
data.mloopuv = mloopuv;
|
||||
data.dvert = dvert;
|
||||
data.defgrp_index = defgrp_index;
|
||||
|
|
|
@ -1252,8 +1252,6 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
const float full_weight = 1.0f;
|
||||
const float max_dist_sq = max_dist * max_dist;
|
||||
|
||||
int i;
|
||||
|
||||
BLI_assert(mode & MREMAP_MODE_LOOP);
|
||||
BLI_assert((islands_precision_src >= 0.0f) && (islands_precision_src <= 1.0f));
|
||||
|
||||
|
@ -1262,7 +1260,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
if (mode == MREMAP_MODE_TOPOLOGY) {
|
||||
/* In topology mapping, we assume meshes are identical, islands included! */
|
||||
BLI_assert(numloops_dst == me_src->totloop);
|
||||
for (i = 0; i < numloops_dst; i++) {
|
||||
for (int i = 0; i < numloops_dst; i++) {
|
||||
mesh_remap_item_define(r_map, i, FLT_MAX, 0, 1, &i, &full_weight);
|
||||
}
|
||||
}
|
||||
|
@ -1311,8 +1309,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
const blender::Span<MEdge> edges_src = me_src->edges();
|
||||
const blender::Span<MPoly> polys_src = me_src->polys();
|
||||
const blender::Span<MLoop> loops_src = me_src->loops();
|
||||
const MLoopTri *looptri_src = nullptr;
|
||||
int num_looptri_src = 0;
|
||||
blender::Span<MLoopTri> looptris_src;
|
||||
|
||||
size_t buff_size_interp = MREMAP_DEFAULT_BUFSIZE;
|
||||
float(*vcos_interp)[3] = nullptr;
|
||||
|
@ -1506,7 +1503,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
MeshElemMap *isld = island_store.islands[tindex];
|
||||
int num_verts_active = 0;
|
||||
verts_active.fill(false);
|
||||
for (i = 0; i < isld->count; i++) {
|
||||
for (int i = 0; i < isld->count; i++) {
|
||||
const MPoly &poly = polys_src[isld->indices[i]];
|
||||
for (lidx_src = poly.loopstart; lidx_src < poly.loopstart + poly.totloop; lidx_src++) {
|
||||
const uint vidx_src = loops_src[lidx_src].v;
|
||||
|
@ -1533,16 +1530,14 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
}
|
||||
else { /* We use polygons. */
|
||||
if (use_islands) {
|
||||
/* bvhtree here uses looptri faces... */
|
||||
looptri_src = BKE_mesh_runtime_looptri_ensure(me_src);
|
||||
num_looptri_src = BKE_mesh_runtime_looptri_len(me_src);
|
||||
blender::BitVector<> looptri_active(num_looptri_src);
|
||||
looptris_src = me_src->looptris();
|
||||
blender::BitVector<> looptri_active(looptris_src.size());
|
||||
|
||||
for (tindex = 0; tindex < num_trees; tindex++) {
|
||||
int num_looptri_active = 0;
|
||||
looptri_active.fill(false);
|
||||
for (i = 0; i < num_looptri_src; i++) {
|
||||
const MPoly &poly = polys_src[looptri_src[i].poly];
|
||||
for (const int64_t i : looptris_src.index_range()) {
|
||||
const MPoly &poly = polys_src[looptris_src[i].poly];
|
||||
if (island_store.items_to_islands[poly.loopstart] == tindex) {
|
||||
looptri_active[i].set();
|
||||
num_looptri_active++;
|
||||
|
@ -1551,8 +1546,8 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
bvhtree_from_mesh_looptri_ex(&treedata[tindex],
|
||||
positions_src,
|
||||
loops_src.data(),
|
||||
looptri_src,
|
||||
num_looptri_src,
|
||||
looptris_src.data(),
|
||||
int(looptris_src.size()),
|
||||
looptri_active,
|
||||
num_looptri_active,
|
||||
0.0,
|
||||
|
@ -1636,7 +1631,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
vert_to_refelem_map_src = vert_to_poly_map_src;
|
||||
}
|
||||
|
||||
for (i = vert_to_refelem_map_src[nearest.index].count; i--;) {
|
||||
for (int i = vert_to_refelem_map_src[nearest.index].count; i--;) {
|
||||
const int index_src = vert_to_refelem_map_src[nearest.index].indices[i];
|
||||
BLI_assert(index_src != -1);
|
||||
const float dot = dot_v3v3(nors_src[index_src], *nor_dst);
|
||||
|
@ -1881,7 +1876,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
*/
|
||||
int last_valid_pidx_isld_src = -1;
|
||||
/* Note we go backward here, from dest to src poly. */
|
||||
for (i = as_solution.steps - 1; i--;) {
|
||||
for (int i = as_solution.steps - 1; i--;) {
|
||||
BLI_AStarGNLink *as_link = as_solution.prev_links[pidx_isld_src];
|
||||
const int eidx = POINTER_AS_INT(as_link->custom_data);
|
||||
pidx_isld_src = as_solution.prev_nodes[pidx_isld_src];
|
||||
|
@ -1973,7 +1968,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
*/
|
||||
int last_valid_pidx_isld_src = -1;
|
||||
/* Note we go backward here, from dest to src poly. */
|
||||
for (i = as_solution.steps - 1; i--;) {
|
||||
for (int i = as_solution.steps - 1; i--;) {
|
||||
BLI_AStarGNLink *as_link = as_solution.prev_links[pidx_isld_src];
|
||||
int eidx = POINTER_AS_INT(as_link->custom_data);
|
||||
|
||||
|
@ -2008,14 +2003,14 @@ void BKE_mesh_remap_calc_loops_from_mesh(const int mode,
|
|||
&poly_to_looptri_map_src_buff,
|
||||
polys_src.data(),
|
||||
int(polys_src.size()),
|
||||
looptri_src,
|
||||
num_looptri_src);
|
||||
looptris_src.data(),
|
||||
int(looptris_src.size()));
|
||||
}
|
||||
|
||||
for (j = poly_to_looptri_map_src[pidx_src].count; j--;) {
|
||||
float h[3];
|
||||
const MLoopTri *lt =
|
||||
&looptri_src[poly_to_looptri_map_src[pidx_src].indices[j]];
|
||||
&looptris_src[poly_to_looptri_map_src[pidx_src].indices[j]];
|
||||
float dist_sq;
|
||||
|
||||
closest_on_tri_to_point_v3(h,
|
||||
|
|
|
@ -65,15 +65,14 @@ static Mesh *remesh_quadriflow(const Mesh *input_mesh,
|
|||
{
|
||||
const Span<float3> input_positions = input_mesh->vert_positions();
|
||||
const Span<MLoop> input_loops = input_mesh->loops();
|
||||
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(input_mesh);
|
||||
const Span<MLoopTri> looptris = input_mesh->looptris();
|
||||
|
||||
/* Gather the required data for export to the internal quadriflow mesh format. */
|
||||
MVertTri *verttri = (MVertTri *)MEM_callocN(
|
||||
sizeof(*verttri) * BKE_mesh_runtime_looptri_len(input_mesh), "remesh_looptri");
|
||||
Array<MVertTri> verttri(looptris.size());
|
||||
BKE_mesh_runtime_verttri_from_looptri(
|
||||
verttri, input_loops.data(), looptri, BKE_mesh_runtime_looptri_len(input_mesh));
|
||||
verttri.data(), input_loops.data(), looptris.data(), looptris.size());
|
||||
|
||||
const int totfaces = BKE_mesh_runtime_looptri_len(input_mesh);
|
||||
const int totfaces = looptris.size();
|
||||
const int totverts = input_mesh->totvert;
|
||||
Array<int> faces(totfaces * 3);
|
||||
|
||||
|
@ -105,8 +104,6 @@ static Mesh *remesh_quadriflow(const Mesh *input_mesh,
|
|||
/* Run the remesher */
|
||||
QFLOW_quadriflow_remesh(&qrd, update_cb, update_cb_data);
|
||||
|
||||
MEM_freeN(verttri);
|
||||
|
||||
if (qrd.out_faces == nullptr) {
|
||||
/* The remeshing was canceled */
|
||||
return nullptr;
|
||||
|
@ -335,7 +332,7 @@ void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, const Mesh *source)
|
|||
const VArraySpan<int> src(src_face_sets);
|
||||
MutableSpan<int> dst = dst_face_sets.span;
|
||||
|
||||
const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(source);
|
||||
const blender::Span<MLoopTri> looptris = source->looptris();
|
||||
BVHTreeFromMesh bvhtree = {nullptr};
|
||||
BKE_bvhtree_from_mesh_get(&bvhtree, source, BVHTREE_FROM_LOOPTRI, 2);
|
||||
|
||||
|
@ -353,7 +350,7 @@ void BKE_remesh_reproject_sculpt_face_sets(Mesh *target, const Mesh *source)
|
|||
BLI_bvhtree_find_nearest(
|
||||
bvhtree.tree, from_co, &nearest, bvhtree.nearest_callback, &bvhtree);
|
||||
if (nearest.index != -1) {
|
||||
dst[i] = src[looptri[nearest.index].poly];
|
||||
dst[i] = src[looptris[nearest.index].poly];
|
||||
}
|
||||
else {
|
||||
dst[i] = 1;
|
||||
|
|
|
@ -574,14 +574,15 @@ void BKE_mesh_calc_loop_tangents(Mesh *me_eval,
|
|||
int tangent_names_len)
|
||||
{
|
||||
/* TODO(@ideasman42): store in Mesh.runtime to avoid recalculation. */
|
||||
const blender::Span<MLoopTri> looptris = me_eval->looptris();
|
||||
short tangent_mask = 0;
|
||||
BKE_mesh_calc_loop_tangent_ex(
|
||||
BKE_mesh_vert_positions(me_eval),
|
||||
me_eval->polys().data(),
|
||||
uint(me_eval->totpoly),
|
||||
me_eval->loops().data(),
|
||||
BKE_mesh_runtime_looptri_ensure(me_eval),
|
||||
uint(BKE_mesh_runtime_looptri_len(me_eval)),
|
||||
looptris.data(),
|
||||
uint(looptris.size()),
|
||||
&me_eval->ldata,
|
||||
calc_active_tangent,
|
||||
tangent_names,
|
||||
|
|
|
@ -231,15 +231,14 @@ static ShrinkwrapBoundaryData *shrinkwrap_build_boundary_data(Mesh *mesh)
|
|||
data->edge_is_boundary = edge_is_boundary;
|
||||
|
||||
/* Build the boundary looptri bitmask. */
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
int totlooptri = BKE_mesh_runtime_looptri_len(mesh);
|
||||
const blender::Span<MLoopTri> looptris = mesh->looptris();
|
||||
|
||||
BLI_bitmap *looptri_has_boundary = BLI_BITMAP_NEW(totlooptri,
|
||||
BLI_bitmap *looptri_has_boundary = BLI_BITMAP_NEW(looptris.size(),
|
||||
"ShrinkwrapBoundaryData::looptri_is_boundary");
|
||||
|
||||
for (int i = 0; i < totlooptri; i++) {
|
||||
for (const int64_t i : looptris.index_range()) {
|
||||
int real_edges[3];
|
||||
BKE_mesh_looptri_get_real_edges(edges.data(), loops.data(), &mlooptri[i], real_edges);
|
||||
BKE_mesh_looptri_get_real_edges(edges.data(), loops.data(), &looptris[i], real_edges);
|
||||
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (real_edges[j] >= 0 && edge_mode[real_edges[j]]) {
|
||||
|
|
|
@ -387,7 +387,7 @@ BLI_INLINE void extract_task_range_run_iter(const MeshRenderData *mr,
|
|||
int stop;
|
||||
switch (iter_type) {
|
||||
case MR_ITER_LOOPTRI:
|
||||
range_data.elems = is_mesh ? mr->mlooptri : (void *)mr->edit_bmesh->looptris;
|
||||
range_data.elems = is_mesh ? mr->looptris.data() : (void *)mr->edit_bmesh->looptris;
|
||||
func = is_mesh ? extract_range_iter_looptri_mesh : extract_range_iter_looptri_bm;
|
||||
stop = mr->tri_len;
|
||||
break;
|
||||
|
|
|
@ -339,7 +339,7 @@ void mesh_render_data_update_looptris(MeshRenderData *mr,
|
|||
if (mr->extract_type != MR_EXTRACT_BMESH) {
|
||||
/* Mesh */
|
||||
if ((iter_type & MR_ITER_LOOPTRI) || (data_flag & MR_DATA_LOOPTRI)) {
|
||||
mr->mlooptri = BKE_mesh_runtime_looptri_ensure(mr->me);
|
||||
mr->looptris = mr->me->looptris();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -83,7 +83,7 @@ struct MeshRenderData {
|
|||
BMFace *efa_act;
|
||||
BMFace *efa_act_uv;
|
||||
/* The triangulation of #Mesh polygons, owned by the mesh. */
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
const int *material_indices;
|
||||
const float (*vert_normals)[3];
|
||||
const float (*poly_normals)[3];
|
||||
|
|
|
@ -74,7 +74,7 @@ static void extract_tris_iter_poly_mesh(const MeshRenderData *mr,
|
|||
|
||||
int tri_len = mp->totloop - 2;
|
||||
for (int offs = 0; offs < tri_len; offs++) {
|
||||
const MLoopTri *mlt = &mr->mlooptri[tri_first_index_real + offs];
|
||||
const MLoopTri *mlt = &mr->looptris[tri_first_index_real + 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]);
|
||||
}
|
||||
|
|
|
@ -214,12 +214,12 @@ static void statvis_calc_thickness(const MeshRenderData *mr, float *r_thickness)
|
|||
BVHTreeFromMesh treeData = {nullptr};
|
||||
|
||||
BVHTree *tree = BKE_bvhtree_from_mesh_get(&treeData, mr->me, BVHTREE_FROM_LOOPTRI, 4);
|
||||
const MLoopTri *mlooptri = mr->mlooptri;
|
||||
for (int i = 0; i < mr->tri_len; i++, mlooptri++) {
|
||||
const int index = mlooptri->poly;
|
||||
const float *cos[3] = {mr->vert_positions[mr->mloop[mlooptri->tri[0]].v],
|
||||
mr->vert_positions[mr->mloop[mlooptri->tri[1]].v],
|
||||
mr->vert_positions[mr->mloop[mlooptri->tri[2]].v]};
|
||||
const Span<MLoopTri> looptris = mr->looptris;
|
||||
for (const int i : looptris.index_range()) {
|
||||
const int index = looptris[i].poly;
|
||||
const float *cos[3] = {mr->vert_positions[mr->mloop[looptris[i].tri[0]].v],
|
||||
mr->vert_positions[mr->mloop[looptris[i].tri[1]].v],
|
||||
mr->vert_positions[mr->mloop[looptris[i].tri[2]].v]};
|
||||
float ray_co[3];
|
||||
float ray_no[3];
|
||||
|
||||
|
@ -261,7 +261,7 @@ static void statvis_calc_thickness(const MeshRenderData *mr, float *r_thickness)
|
|||
struct BVHTree_OverlapData {
|
||||
const float3 *positions;
|
||||
const MLoop *loops;
|
||||
const MLoopTri *mlooptri;
|
||||
Span<MLoopTri> looptris;
|
||||
float epsilon;
|
||||
};
|
||||
|
||||
|
@ -269,8 +269,8 @@ static bool bvh_overlap_cb(void *userdata, int index_a, int index_b, int /*threa
|
|||
{
|
||||
struct BVHTree_OverlapData *data = static_cast<struct BVHTree_OverlapData *>(userdata);
|
||||
|
||||
const MLoopTri *tri_a = &data->mlooptri[index_a];
|
||||
const MLoopTri *tri_b = &data->mlooptri[index_b];
|
||||
const MLoopTri *tri_a = &data->looptris[index_a];
|
||||
const MLoopTri *tri_b = &data->looptris[index_b];
|
||||
|
||||
if (UNLIKELY(tri_a->poly == tri_b->poly)) {
|
||||
return false;
|
||||
|
@ -344,15 +344,15 @@ static void statvis_calc_intersect(const MeshRenderData *mr, float *r_intersect)
|
|||
struct BVHTree_OverlapData data = {nullptr};
|
||||
data.positions = mr->vert_positions;
|
||||
data.loops = mr->mloop;
|
||||
data.mlooptri = mr->mlooptri;
|
||||
data.looptris = mr->looptris;
|
||||
data.epsilon = BLI_bvhtree_get_epsilon(tree);
|
||||
|
||||
BVHTreeOverlap *overlap = BLI_bvhtree_overlap_self(tree, &overlap_len, bvh_overlap_cb, &data);
|
||||
if (overlap) {
|
||||
for (int i = 0; i < overlap_len; i++) {
|
||||
const MPoly *f_hit_pair[2] = {
|
||||
&mr->mpoly[mr->mlooptri[overlap[i].indexA].poly],
|
||||
&mr->mpoly[mr->mlooptri[overlap[i].indexB].poly],
|
||||
&mr->mpoly[mr->looptris[overlap[i].indexA].poly],
|
||||
&mr->mpoly[mr->looptris[overlap[i].indexB].poly],
|
||||
};
|
||||
for (int j = 0; j < 2; j++) {
|
||||
const MPoly *f_hit = f_hit_pair[j];
|
||||
|
|
|
@ -118,7 +118,7 @@ static void extract_tan_init_common(const MeshRenderData *mr,
|
|||
mr->mpoly,
|
||||
mr->poly_len,
|
||||
mr->mloop,
|
||||
mr->mlooptri,
|
||||
mr->looptris.data(),
|
||||
mr->tri_len,
|
||||
cd_ldata,
|
||||
calc_active_tangent,
|
||||
|
|
|
@ -928,7 +928,7 @@ typedef struct MeshDeformBind {
|
|||
struct {
|
||||
blender::Span<MPoly> polys;
|
||||
blender::Span<MLoop> loops;
|
||||
const MLoopTri *looptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
const float (*poly_nors)[3];
|
||||
} cagemesh_cache;
|
||||
} MeshDeformBind;
|
||||
|
@ -959,13 +959,12 @@ static void harmonic_ray_callback(void *userdata,
|
|||
MeshRayCallbackData *data = static_cast<MeshRayCallbackData *>(userdata);
|
||||
MeshDeformBind *mdb = data->mdb;
|
||||
const blender::Span<MLoop> loops = mdb->cagemesh_cache.loops;
|
||||
const MLoopTri *looptri = mdb->cagemesh_cache.looptri, *lt;
|
||||
const float(*poly_nors)[3] = mdb->cagemesh_cache.poly_nors;
|
||||
MeshDeformIsect *isec = data->isec;
|
||||
float no[3], co[3], dist;
|
||||
float *face[3];
|
||||
|
||||
lt = &looptri[index];
|
||||
const MLoopTri *lt = &mdb->cagemesh_cache.looptris[index];
|
||||
|
||||
face[0] = mdb->cagecos[loops[lt->tri[0]].v];
|
||||
face[1] = mdb->cagecos[loops[lt->tri[1]].v];
|
||||
|
@ -1034,7 +1033,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb,
|
|||
&data,
|
||||
BVH_RAYCAST_WATERTIGHT) != -1) {
|
||||
const blender::Span<MLoop> loops = mdb->cagemesh_cache.loops;
|
||||
const MLoopTri *lt = &mdb->cagemesh_cache.looptri[hit.index];
|
||||
const MLoopTri *lt = &mdb->cagemesh_cache.looptris[hit.index];
|
||||
const MPoly *mp = &mdb->cagemesh_cache.polys[lt->poly];
|
||||
const float(*cagecos)[3] = mdb->cagecos;
|
||||
const float len = isect_mdef.lambda;
|
||||
|
@ -1632,7 +1631,7 @@ static void harmonic_coordinates_bind(MeshDeformModifierData *mmd, MeshDeformBin
|
|||
Mesh *me = mdb->cagemesh;
|
||||
mdb->cagemesh_cache.polys = me->polys();
|
||||
mdb->cagemesh_cache.loops = me->loops();
|
||||
mdb->cagemesh_cache.looptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
mdb->cagemesh_cache.looptris = me->looptris();
|
||||
mdb->cagemesh_cache.poly_nors = BKE_mesh_poly_normals_ensure(me);
|
||||
}
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ struct ProjPaintState {
|
|||
blender::Span<MLoop> loops_eval;
|
||||
const bool *select_poly_eval;
|
||||
const int *material_indices;
|
||||
const MLoopTri *mlooptri_eval;
|
||||
blender::Span<MLoopTri> looptris_eval;
|
||||
|
||||
const float (*mloopuv_stencil_eval)[2];
|
||||
|
||||
|
@ -551,7 +551,7 @@ static Material *tex_get_material(const ProjPaintState *ps, int poly_i)
|
|||
|
||||
static TexPaintSlot *project_paint_face_paint_slot(const ProjPaintState *ps, int tri_index)
|
||||
{
|
||||
const int poly_i = ps->mlooptri_eval[tri_index].poly;
|
||||
const int poly_i = ps->looptris_eval[tri_index].poly;
|
||||
Material *ma = tex_get_material(ps, poly_i);
|
||||
return ma ? ma->texpaintslot + ma->paint_active_slot : nullptr;
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ static Image *project_paint_face_paint_image(const ProjPaintState *ps, int tri_i
|
|||
return ps->stencil_ima;
|
||||
}
|
||||
|
||||
const int poly_i = ps->mlooptri_eval[tri_index].poly;
|
||||
const int poly_i = ps->looptris_eval[tri_index].poly;
|
||||
Material *ma = tex_get_material(ps, poly_i);
|
||||
TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_active_slot : nullptr;
|
||||
return slot ? slot->ima : ps->canvas_ima;
|
||||
|
@ -570,14 +570,14 @@ static Image *project_paint_face_paint_image(const ProjPaintState *ps, int tri_i
|
|||
|
||||
static TexPaintSlot *project_paint_face_clone_slot(const ProjPaintState *ps, int tri_index)
|
||||
{
|
||||
const int poly_i = ps->mlooptri_eval[tri_index].poly;
|
||||
const int poly_i = ps->looptris_eval[tri_index].poly;
|
||||
Material *ma = tex_get_material(ps, poly_i);
|
||||
return ma ? ma->texpaintslot + ma->paint_clone_slot : nullptr;
|
||||
}
|
||||
|
||||
static Image *project_paint_face_clone_image(const ProjPaintState *ps, int tri_index)
|
||||
{
|
||||
const int poly_i = ps->mlooptri_eval[tri_index].poly;
|
||||
const int poly_i = ps->looptris_eval[tri_index].poly;
|
||||
Material *ma = tex_get_material(ps, poly_i);
|
||||
TexPaintSlot *slot = ma ? ma->texpaintslot + ma->paint_clone_slot : nullptr;
|
||||
return slot ? slot->ima : ps->clone_ima;
|
||||
|
@ -673,7 +673,7 @@ static int project_paint_PickFace(const ProjPaintState *ps, const float pt[2], f
|
|||
|
||||
for (node = ps->bucketFaces[bucket_index]; node; node = node->next) {
|
||||
const int tri_index = POINTER_AS_INT(node->link);
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const float *vtri_ss[3] = {
|
||||
ps->screenCoords[ps->loops_eval[lt->tri[0]].v],
|
||||
ps->screenCoords[ps->loops_eval[lt->tri[1]].v],
|
||||
|
@ -737,7 +737,7 @@ static bool project_paint_PickColor(
|
|||
return false;
|
||||
}
|
||||
|
||||
lt = &ps->mlooptri_eval[tri_index];
|
||||
lt = &ps->looptris_eval[tri_index];
|
||||
PS_LOOPTRI_ASSIGN_UV_3(lt_tri_uv, ps->poly_to_loop_uv, lt);
|
||||
|
||||
interp_v2_v2v2v2(uv, UNPACK3(lt_tri_uv), w);
|
||||
|
@ -915,7 +915,7 @@ static bool project_bucket_point_occluded(const ProjPaintState *ps,
|
|||
const int tri_index = POINTER_AS_INT(bucketFace->link);
|
||||
|
||||
if (orig_face != tri_index) {
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const float *vtri_ss[3] = {
|
||||
ps->screenCoords[ps->loops_eval[lt->tri[0]].v],
|
||||
ps->screenCoords[ps->loops_eval[lt->tri[1]].v],
|
||||
|
@ -1121,7 +1121,7 @@ static bool pixel_bounds_array(
|
|||
static void project_face_winding_init(const ProjPaintState *ps, const int tri_index)
|
||||
{
|
||||
/* detect the winding of faces in uv space */
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const float *lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt)};
|
||||
float winding = cross_tri_v2(lt_tri_uv[0], lt_tri_uv[1], lt_tri_uv[2]);
|
||||
|
||||
|
@ -1141,7 +1141,7 @@ static bool check_seam(const ProjPaintState *ps,
|
|||
int *other_face,
|
||||
int *orig_fidx)
|
||||
{
|
||||
const MLoopTri *orig_lt = &ps->mlooptri_eval[orig_face];
|
||||
const MLoopTri *orig_lt = &ps->looptris_eval[orig_face];
|
||||
const float *orig_lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, orig_lt)};
|
||||
/* vert indices from face vert order indices */
|
||||
const uint i1 = ps->loops_eval[orig_lt->tri[orig_i1_fidx]].v;
|
||||
|
@ -1154,7 +1154,7 @@ static bool check_seam(const ProjPaintState *ps,
|
|||
const int tri_index = POINTER_AS_INT(node->link);
|
||||
|
||||
if (tri_index != orig_face) {
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const int lt_vtri[3] = {PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt)};
|
||||
/* could check if the 2 faces images match here,
|
||||
* but then there wouldn't be a way to return the opposite face's info */
|
||||
|
@ -1303,7 +1303,7 @@ static void uv_image_outset(const ProjPaintState *ps,
|
|||
int fidx[2];
|
||||
uint loop_index;
|
||||
uint vert[2];
|
||||
const MLoopTri *ltri = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *ltri = &ps->looptris_eval[tri_index];
|
||||
|
||||
float ibuf_inv[2];
|
||||
|
||||
|
@ -1386,7 +1386,7 @@ static void insert_seam_vert_array(const ProjPaintState *ps,
|
|||
const int ibuf_x,
|
||||
const int ibuf_y)
|
||||
{
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const float *lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt)};
|
||||
const int fidx[2] = {fidx1, ((fidx1 + 1) % 3)};
|
||||
float vec[2];
|
||||
|
@ -1446,7 +1446,7 @@ static void project_face_seams_init(const ProjPaintState *ps,
|
|||
int other_face, other_fidx;
|
||||
/* next fidx in the face (0,1,2,3) -> (1,2,3,0) or (0,1,2) -> (1,2,0) for a tri */
|
||||
int fidx[2] = {2, 0};
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
LinkNode *node;
|
||||
|
||||
/* initialize face winding if needed */
|
||||
|
@ -1665,7 +1665,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
|
|||
Image *other_tpage = ps->stencil_ima;
|
||||
|
||||
if (other_tpage && (ibuf_other = BKE_image_acquire_ibuf(other_tpage, nullptr, nullptr))) {
|
||||
const MLoopTri *lt_other = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt_other = &ps->looptris_eval[tri_index];
|
||||
const float *lt_other_tri_uv[3] = {ps->mloopuv_stencil_eval[lt_other->tri[0]],
|
||||
ps->mloopuv_stencil_eval[lt_other->tri[1]],
|
||||
ps->mloopuv_stencil_eval[lt_other->tri[2]]};
|
||||
|
@ -1704,7 +1704,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
|
|||
}
|
||||
|
||||
if (ps->do_mask_cavity) {
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const int lt_vtri[3] = {PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt)};
|
||||
float ca1, ca2, ca3, ca_mask;
|
||||
ca1 = ps->cavities[lt_vtri[0]];
|
||||
|
@ -1719,7 +1719,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps,
|
|||
|
||||
/* calculate mask */
|
||||
if (ps->do_mask_normal) {
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const int lt_vtri[3] = {PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt)};
|
||||
const MPoly *mp = &ps->polys_eval[lt->poly];
|
||||
float no[3], angle_cos;
|
||||
|
@ -1959,7 +1959,7 @@ static ProjPixel *project_paint_uvpixel_init(const ProjPaintState *ps,
|
|||
Image *other_tpage = project_paint_face_clone_image(ps, tri_index);
|
||||
|
||||
if (other_tpage && (ibuf_other = BKE_image_acquire_ibuf(other_tpage, nullptr, nullptr))) {
|
||||
const MLoopTri *lt_other = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt_other = &ps->looptris_eval[tri_index];
|
||||
const float *lt_other_tri_uv[3] = {
|
||||
PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv_clone, lt_other)};
|
||||
|
||||
|
@ -2996,7 +2996,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
|
|||
ps->projImages + image_index,
|
||||
};
|
||||
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const int lt_vtri[3] = {PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt)};
|
||||
const float *lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt)};
|
||||
|
||||
|
@ -3287,7 +3287,7 @@ static void project_paint_face_init(const ProjPaintState *ps,
|
|||
bucket_clip_edges[1])) {
|
||||
/* Avoid div by zero. */
|
||||
if (len_squared_v2v2(vCoSS[fidx1], vCoSS[fidx2]) > FLT_EPSILON) {
|
||||
uint loop_idx = ps->mlooptri_eval[tri_index].tri[fidx1];
|
||||
uint loop_idx = ps->looptris_eval[tri_index].tri[fidx1];
|
||||
LoopSeamData *seam_data = &ps->loopSeamData[loop_idx];
|
||||
float(*seam_uvs)[2] = seam_data->seam_uvs;
|
||||
|
||||
|
@ -3525,7 +3525,7 @@ static void project_bucket_init(const ProjPaintState *ps,
|
|||
for (node = ps->bucketFaces[bucket_index]; node; node = node->next) {
|
||||
tri_index = POINTER_AS_INT(node->link);
|
||||
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const float *lt_tri_uv[3] = {PS_LOOPTRI_AS_UV_3(ps->poly_to_loop_uv, lt)};
|
||||
|
||||
/* Image context switching */
|
||||
|
@ -4085,8 +4085,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
|
|||
ps->totpoly_eval = ps->me_eval->totpoly;
|
||||
ps->totloop_eval = ps->me_eval->totloop;
|
||||
|
||||
ps->mlooptri_eval = BKE_mesh_runtime_looptri_ensure(ps->me_eval);
|
||||
ps->totlooptri_eval = BKE_mesh_runtime_looptri_len(ps->me_eval);
|
||||
ps->looptris_eval = ps->me_eval->looptris();
|
||||
|
||||
ps->poly_to_loop_uv = static_cast<const float(**)[2]>(
|
||||
MEM_mallocN(ps->totpoly_eval * sizeof(float(*)[2]), "proj_paint_mtfaces"));
|
||||
|
@ -4159,7 +4158,7 @@ static bool project_paint_clone_face_skip(ProjPaintState *ps,
|
|||
}
|
||||
|
||||
/* will set multiple times for 4+ sided poly */
|
||||
ps->poly_to_loop_uv_clone[ps->mlooptri_eval[tri_index].poly] = lc->mloopuv_clone_base;
|
||||
ps->poly_to_loop_uv_clone[ps->looptris_eval[tri_index].poly] = lc->mloopuv_clone_base;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -4304,17 +4303,17 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
|
|||
TexPaintSlot *slot_last = nullptr;
|
||||
TexPaintSlot *slot = nullptr;
|
||||
int tile_last = -1, tile;
|
||||
const MLoopTri *lt;
|
||||
int image_index = -1, tri_index;
|
||||
int prev_poly = -1;
|
||||
const blender::Span<MLoopTri> looptris = ps->looptris_eval;
|
||||
|
||||
BLI_assert(ps->image_tot == 0);
|
||||
|
||||
for (tri_index = 0, lt = ps->mlooptri_eval; tri_index < ps->totlooptri_eval; tri_index++, lt++) {
|
||||
for (tri_index = 0; tri_index < ps->totlooptri_eval; tri_index++) {
|
||||
bool is_face_sel;
|
||||
bool skip_tri = false;
|
||||
|
||||
is_face_sel = project_paint_check_face_sel(ps, face_lookup, lt);
|
||||
is_face_sel = project_paint_check_face_sel(ps, face_lookup, &looptris[tri_index]);
|
||||
|
||||
if (!ps->do_stencil_brush) {
|
||||
slot = project_paint_face_paint_slot(ps, tri_index);
|
||||
|
@ -4353,12 +4352,12 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
|
|||
tpage = ps->stencil_ima;
|
||||
}
|
||||
|
||||
ps->poly_to_loop_uv[lt->poly] = mloopuv_base;
|
||||
ps->poly_to_loop_uv[looptris[tri_index].poly] = mloopuv_base;
|
||||
|
||||
tile = project_paint_face_paint_tile(tpage, mloopuv_base[lt->tri[0]]);
|
||||
tile = project_paint_face_paint_tile(tpage, mloopuv_base[looptris[tri_index].tri[0]]);
|
||||
|
||||
#ifndef PROJ_DEBUG_NOSEAMBLEED
|
||||
project_paint_bleed_add_face_user(ps, arena, lt, tri_index);
|
||||
project_paint_bleed_add_face_user(ps, arena, &looptris[tri_index], tri_index);
|
||||
#endif
|
||||
|
||||
if (skip_tri || project_paint_clone_face_skip(ps, layer_clone, slot, tri_index)) {
|
||||
|
@ -4369,7 +4368,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
|
|||
|
||||
if (is_face_sel && tpage) {
|
||||
ProjPaintFaceCoSS coSS;
|
||||
proj_paint_face_coSS_init(ps, lt, &coSS);
|
||||
proj_paint_face_coSS_init(ps, &looptris[tri_index], &coSS);
|
||||
|
||||
if (is_multi_view == false) {
|
||||
if (project_paint_flt_max_cull(ps, &coSS)) {
|
||||
|
@ -4386,12 +4385,12 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
|
|||
/* Back-face culls individual triangles but mask normal will use polygon. */
|
||||
if (ps->do_backfacecull) {
|
||||
if (ps->do_mask_normal) {
|
||||
if (prev_poly != lt->poly) {
|
||||
if (prev_poly != looptris[tri_index].poly) {
|
||||
int iloop;
|
||||
bool culled = true;
|
||||
const MPoly *poly = &ps->polys_eval[lt->poly];
|
||||
const MPoly *poly = &ps->polys_eval[looptris[tri_index].poly];
|
||||
int poly_loops = poly->totloop;
|
||||
prev_poly = lt->poly;
|
||||
prev_poly = looptris[tri_index].poly;
|
||||
for (iloop = 0; iloop < poly_loops; iloop++) {
|
||||
if (!(ps->vertFlags[ps->loops_eval[poly->loopstart + iloop].v] & PROJ_VERT_CULL)) {
|
||||
culled = false;
|
||||
|
@ -4404,7 +4403,6 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
|
|||
* but counter gets incremented when continuing, so decrease by 3 */
|
||||
int poly_tri = poly_loops - 3;
|
||||
tri_index += poly_tri;
|
||||
lt += poly_tri;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -4451,7 +4449,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps,
|
|||
if (image_index != -1) {
|
||||
/* Initialize the faces screen pixels */
|
||||
/* Add this to a list to initialize later */
|
||||
project_paint_delayed_face_init(ps, lt, tri_index);
|
||||
project_paint_delayed_face_init(ps, &looptris[tri_index], tri_index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5703,7 +5701,7 @@ static bool project_paint_op(void *state, const float lastpos[2], const float po
|
|||
tri_index = project_paint_PickFace(ps, pos, w);
|
||||
|
||||
if (tri_index != -1) {
|
||||
const MLoopTri *lt = &ps->mlooptri_eval[tri_index];
|
||||
const MLoopTri *lt = &ps->looptris_eval[tri_index];
|
||||
const int lt_vtri[3] = {PS_LOOPTRI_AS_VERT_INDEX_3(ps, lt)};
|
||||
float world[3];
|
||||
UnifiedPaintSettings *ups = &ps->scene->toolsettings->unified_paint_settings;
|
||||
|
|
|
@ -72,6 +72,7 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
const float(*positions)[3] = BKE_mesh_vert_positions(me);
|
||||
const blender::Span<MPoly> polys = me->polys();
|
||||
const blender::Span<MLoop> loops = me->loops();
|
||||
const blender::Span<MLoopTri> looptris = me->looptris();
|
||||
|
||||
facemap_data = static_cast<const int *>(CustomData_get_layer(&me->pdata, CD_FACEMAP));
|
||||
|
||||
|
@ -90,46 +91,23 @@ void ED_draw_object_facemap(Depsgraph *depsgraph,
|
|||
GPUVertBufRaw pos_step;
|
||||
GPU_vertbuf_attr_get_raw_data(vbo_pos, pos_id, &pos_step);
|
||||
|
||||
if (BKE_mesh_runtime_looptri_ensure(me)) {
|
||||
const MLoopTri *mlt = BKE_mesh_runtime_looptri_ensure(me);
|
||||
for (const int i : polys.index_range()) {
|
||||
const MPoly &poly = polys[i];
|
||||
if (facemap_data[i] == facemap) {
|
||||
for (int j = 2; j < poly.totloop; j++) {
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[mlt->tri[0]].v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[mlt->tri[1]].v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[mlt->tri[2]].v]);
|
||||
vbo_len_used += 3;
|
||||
mlt++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mlt += poly.totloop - 2;
|
||||
int tri_index = 0;
|
||||
for (const int i : polys.index_range()) {
|
||||
const MPoly &poly = polys[i];
|
||||
if (facemap_data[i] == facemap) {
|
||||
for (int j = 2; j < poly.totloop; j++) {
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[looptris[tri_index].tri[0]].v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[looptris[tri_index].tri[1]].v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[loops[looptris[tri_index].tri[2]].v]);
|
||||
vbo_len_used += 3;
|
||||
tri_index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* No tessellation data, fan-fill. */
|
||||
for (const int i : polys.index_range()) {
|
||||
const MPoly &poly = polys[i];
|
||||
if (facemap_data[i] == facemap) {
|
||||
const MLoop *ml_start = &loops[poly.loopstart];
|
||||
const MLoop *ml_a = ml_start + 1;
|
||||
const MLoop *ml_b = ml_start + 2;
|
||||
for (int j = 2; j < poly.totloop; j++) {
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)),
|
||||
positions[ml_start->v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), positions[ml_a->v]);
|
||||
copy_v3_v3(static_cast<float *>(GPU_vertbuf_raw_step(&pos_step)), positions[ml_b->v]);
|
||||
vbo_len_used += 3;
|
||||
|
||||
ml_a++;
|
||||
ml_b++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tri_index += poly.totloop - 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1430,7 +1430,7 @@ struct Nearest2dUserData {
|
|||
const float (*vert_normals)[3];
|
||||
const MEdge *edge; /* only used for #BVHTreeFromMeshEdges */
|
||||
const MLoop *loop;
|
||||
const MLoopTri *looptri;
|
||||
const MLoopTri *looptris;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1481,7 +1481,7 @@ static void cb_mlooptri_edges_get(const int index, const Nearest2dUserData *data
|
|||
{
|
||||
const MEdge *medge = data->edge;
|
||||
const MLoop *mloop = data->loop;
|
||||
const MLoopTri *lt = &data->looptri[index];
|
||||
const MLoopTri *lt = &data->looptris[index];
|
||||
for (int j = 2, j_next = 0; j_next < 3; j = j_next++) {
|
||||
const MEdge *ed = &medge[mloop[lt->tri[j]].e];
|
||||
const uint tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v};
|
||||
|
@ -1498,7 +1498,7 @@ static void cb_mlooptri_edges_get(const int index, const Nearest2dUserData *data
|
|||
static void cb_mlooptri_verts_get(const int index, const Nearest2dUserData *data, int r_v_index[3])
|
||||
{
|
||||
const MLoop *loop = data->loop;
|
||||
const MLoopTri *looptri = &data->looptri[index];
|
||||
const MLoopTri *looptri = &data->looptris[index];
|
||||
|
||||
r_v_index[0] = loop[looptri->tri[0]].v;
|
||||
r_v_index[1] = loop[looptri->tri[1]].v;
|
||||
|
@ -1719,7 +1719,7 @@ static void nearest2d_data_init_mesh(const Mesh *mesh,
|
|||
r_nearest2d->vert_normals = BKE_mesh_vert_normals_ensure(mesh);
|
||||
r_nearest2d->edge = mesh->edges().data();
|
||||
r_nearest2d->loop = mesh->loops().data();
|
||||
r_nearest2d->looptri = BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
r_nearest2d->looptris = mesh->looptris().data();
|
||||
|
||||
r_nearest2d->is_persp = is_persp;
|
||||
r_nearest2d->use_backface_culling = use_backface_culling;
|
||||
|
|
|
@ -1474,11 +1474,11 @@ struct EdgeFeatData {
|
|||
LineartData *ld;
|
||||
Mesh *me;
|
||||
Object *ob_eval; /* For evaluated materials. */
|
||||
const MLoopTri *mlooptri;
|
||||
const int *material_indices;
|
||||
blender::Span<MEdge> edges;
|
||||
blender::Span<MLoop> loops;
|
||||
blender::Span<MPoly> polys;
|
||||
blender::Span<MLoop> loops;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
LineartTriangle *tri_array;
|
||||
blender::VArray<bool> sharp_edges;
|
||||
LineartVert *v_array;
|
||||
|
@ -1514,7 +1514,7 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata,
|
|||
const int *material_indices = e_feat_data->material_indices;
|
||||
Object *ob_eval = e_feat_data->ob_eval;
|
||||
LineartEdgeNeighbor *edge_nabr = e_feat_data->edge_nabr;
|
||||
const MLoopTri *mlooptri = e_feat_data->mlooptri;
|
||||
const blender::Span<MLoopTri> looptris = e_feat_data->looptris;
|
||||
|
||||
uint16_t edge_flag_result = 0;
|
||||
|
||||
|
@ -1532,10 +1532,10 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata,
|
|||
FreestyleFace *ff1, *ff2;
|
||||
int index = e_feat_data->freestyle_face_index;
|
||||
if (index > -1) {
|
||||
ff1 = &((FreestyleFace *)me->pdata.layers[index].data)[mlooptri[i / 3].poly];
|
||||
ff1 = &((FreestyleFace *)me->pdata.layers[index].data)[looptris[i / 3].poly];
|
||||
}
|
||||
if (edge_nabr[i].e > -1) {
|
||||
ff2 = &((FreestyleFace *)me->pdata.layers[index].data)[mlooptri[edge_nabr[i].e / 3].poly];
|
||||
ff2 = &((FreestyleFace *)me->pdata.layers[index].data)[looptris[edge_nabr[i].e / 3].poly];
|
||||
}
|
||||
else {
|
||||
/* Handle mesh boundary cases: We want mesh boundaries to respect
|
||||
|
@ -1648,8 +1648,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata,
|
|||
if (ld->conf.use_crease) {
|
||||
bool do_crease = true;
|
||||
if (!ld->conf.force_crease && !e_feat_data->use_auto_smooth &&
|
||||
(e_feat_data->polys[mlooptri[f1].poly].flag & ME_SMOOTH) &&
|
||||
(e_feat_data->polys[mlooptri[f2].poly].flag & ME_SMOOTH)) {
|
||||
(e_feat_data->polys[looptris[f1].poly].flag & ME_SMOOTH) &&
|
||||
(e_feat_data->polys[looptris[f2].poly].flag & ME_SMOOTH)) {
|
||||
do_crease = false;
|
||||
}
|
||||
if (do_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < e_feat_data->crease_threshold)) {
|
||||
|
@ -1657,8 +1657,8 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata,
|
|||
}
|
||||
}
|
||||
|
||||
int mat1 = material_indices ? material_indices[mlooptri[f1].poly] : 0;
|
||||
int mat2 = material_indices ? material_indices[mlooptri[f2].poly] : 0;
|
||||
int mat1 = material_indices ? material_indices[looptris[f1].poly] : 0;
|
||||
int mat2 = material_indices ? material_indices[looptris[f2].poly] : 0;
|
||||
|
||||
if (mat1 != mat2) {
|
||||
Material *m1 = BKE_object_material_get_eval(ob_eval, mat1 + 1);
|
||||
|
@ -1683,7 +1683,7 @@ static void lineart_identify_mlooptri_feature_edges(void *__restrict userdata,
|
|||
|
||||
int real_edges[3];
|
||||
BKE_mesh_looptri_get_real_edges(
|
||||
e_feat_data->edges.data(), e_feat_data->loops.data(), &mlooptri[i / 3], real_edges);
|
||||
e_feat_data->edges.data(), e_feat_data->loops.data(), &looptris[i / 3], real_edges);
|
||||
|
||||
if (real_edges[i % 3] >= 0) {
|
||||
if (ld->conf.use_crease && ld->conf.sharp_as_crease &&
|
||||
|
@ -1789,7 +1789,7 @@ struct TriData {
|
|||
LineartObjectInfo *ob_info;
|
||||
blender::Span<blender::float3> positions;
|
||||
blender::Span<MLoop> loops;
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
const int *material_indices;
|
||||
LineartVert *vert_arr;
|
||||
LineartTriangle *tri_arr;
|
||||
|
@ -1805,16 +1805,16 @@ static void lineart_load_tri_task(void *__restrict userdata,
|
|||
LineartObjectInfo *ob_info = tri_task_data->ob_info;
|
||||
const blender::Span<blender::float3> positions = tri_task_data->positions;
|
||||
const blender::Span<MLoop> loops = tri_task_data->loops;
|
||||
const MLoopTri *mlooptri = &tri_task_data->mlooptri[i];
|
||||
const MLoopTri *looptri = &tri_task_data->looptris[i];
|
||||
const int *material_indices = tri_task_data->material_indices;
|
||||
LineartVert *vert_arr = tri_task_data->vert_arr;
|
||||
LineartTriangle *tri = tri_task_data->tri_arr;
|
||||
|
||||
tri = (LineartTriangle *)(((uchar *)tri) + tri_task_data->lineart_triangle_size * i);
|
||||
|
||||
int v1 = loops[mlooptri->tri[0]].v;
|
||||
int v2 = loops[mlooptri->tri[1]].v;
|
||||
int v3 = loops[mlooptri->tri[2]].v;
|
||||
int v1 = loops[looptri->tri[0]].v;
|
||||
int v2 = loops[looptri->tri[1]].v;
|
||||
int v3 = loops[looptri->tri[2]].v;
|
||||
|
||||
tri->v[0] = &vert_arr[v1];
|
||||
tri->v[1] = &vert_arr[v2];
|
||||
|
@ -1822,7 +1822,7 @@ static void lineart_load_tri_task(void *__restrict userdata,
|
|||
|
||||
/* Material mask bits and occlusion effectiveness assignment. */
|
||||
Material *mat = BKE_object_material_get(
|
||||
ob_info->original_ob_eval, material_indices ? material_indices[mlooptri->poly] + 1 : 1);
|
||||
ob_info->original_ob_eval, material_indices ? material_indices[looptri->poly] + 1 : 1);
|
||||
tri->material_mask_bits |= ((mat && (mat->lineart.flags & LRT_MATERIAL_MASK_ENABLED)) ?
|
||||
mat->lineart.material_mask_bits :
|
||||
0);
|
||||
|
@ -1862,8 +1862,8 @@ static void lineart_load_tri_task(void *__restrict userdata,
|
|||
struct EdgeNeighborData {
|
||||
LineartEdgeNeighbor *edge_nabr;
|
||||
LineartAdjacentEdge *adj_e;
|
||||
const MLoopTri *mlooptri;
|
||||
blender::Span<MLoop> loops;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
};
|
||||
|
||||
static void lineart_edge_neighbor_init_task(void *__restrict userdata,
|
||||
|
@ -1872,7 +1872,7 @@ static void lineart_edge_neighbor_init_task(void *__restrict userdata,
|
|||
{
|
||||
EdgeNeighborData *en_data = (EdgeNeighborData *)userdata;
|
||||
LineartAdjacentEdge *adj_e = &en_data->adj_e[i];
|
||||
const MLoopTri *looptri = &en_data->mlooptri[i / 3];
|
||||
const MLoopTri *looptri = &en_data->looptris[i / 3];
|
||||
LineartEdgeNeighbor *edge_nabr = &en_data->edge_nabr[i];
|
||||
const blender::Span<MLoop> loops = en_data->loops;
|
||||
|
||||
|
@ -1924,8 +1924,8 @@ static LineartEdgeNeighbor *lineart_build_edge_neighbor(Mesh *me, int total_edge
|
|||
EdgeNeighborData en_data;
|
||||
en_data.adj_e = adj_e;
|
||||
en_data.edge_nabr = edge_nabr;
|
||||
en_data.mlooptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
en_data.loops = me->loops();
|
||||
en_data.looptris = me->looptris();
|
||||
|
||||
BLI_task_parallel_range(0, total_edges, &en_data, lineart_edge_neighbor_init_task, &en_settings);
|
||||
|
||||
|
@ -1954,8 +1954,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
|
|||
}
|
||||
|
||||
/* Triangulate. */
|
||||
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me);
|
||||
const int tot_tri = BKE_mesh_runtime_looptri_len(me);
|
||||
const blender::Span<MLoopTri> looptris = me->looptris();
|
||||
|
||||
const int *material_indices = (const int *)CustomData_get_layer_named(
|
||||
&me->pdata, CD_PROP_INT32, "material_index");
|
||||
|
@ -1978,8 +1977,8 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
|
|||
* chains containing the same edge. */
|
||||
LineartVert *la_v_arr = static_cast<LineartVert *>(
|
||||
lineart_mem_acquire_thread(&la_data->render_data_pool, sizeof(LineartVert) * me->totvert));
|
||||
LineartTriangle *la_tri_arr = static_cast<LineartTriangle *>(
|
||||
lineart_mem_acquire_thread(&la_data->render_data_pool, tot_tri * la_data->sizeof_triangle));
|
||||
LineartTriangle *la_tri_arr = static_cast<LineartTriangle *>(lineart_mem_acquire_thread(
|
||||
&la_data->render_data_pool, looptris.size() * la_data->sizeof_triangle));
|
||||
|
||||
Object *orig_ob = ob_info->original_ob;
|
||||
|
||||
|
@ -2025,7 +2024,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
|
|||
|
||||
int usage = ob_info->usage;
|
||||
|
||||
elem_link_node->element_count = tot_tri;
|
||||
elem_link_node->element_count = looptris.size();
|
||||
elem_link_node->object_ref = orig_ob;
|
||||
elem_link_node->flags = eLineArtElementNodeFlag(
|
||||
elem_link_node->flags |
|
||||
|
@ -2033,7 +2032,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
|
|||
|
||||
/* Note this memory is not from pool, will be deleted after culling. */
|
||||
LineartTriangleAdjacent *tri_adj = static_cast<LineartTriangleAdjacent *>(
|
||||
MEM_callocN(sizeof(LineartTriangleAdjacent) * tot_tri, "LineartTriangleAdjacent"));
|
||||
MEM_callocN(sizeof(LineartTriangleAdjacent) * looptris.size(), "LineartTriangleAdjacent"));
|
||||
/* Link is minimal so we use pool anyway. */
|
||||
BLI_spin_lock(&la_data->lock_task);
|
||||
lineart_list_append_pointer_pool_thread(
|
||||
|
@ -2065,7 +2064,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
|
|||
TriData tri_data;
|
||||
tri_data.ob_info = ob_info;
|
||||
tri_data.positions = me->vert_positions();
|
||||
tri_data.mlooptri = mlooptri;
|
||||
tri_data.looptris = looptris;
|
||||
tri_data.loops = me->loops();
|
||||
tri_data.material_indices = material_indices;
|
||||
tri_data.vert_arr = la_v_arr;
|
||||
|
@ -2073,9 +2072,9 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
|
|||
tri_data.lineart_triangle_size = la_data->sizeof_triangle;
|
||||
tri_data.tri_adj = tri_adj;
|
||||
|
||||
uint32_t total_edges = tot_tri * 3;
|
||||
uint32_t total_edges = looptris.size() * 3;
|
||||
|
||||
BLI_task_parallel_range(0, tot_tri, &tri_data, lineart_load_tri_task, &tri_settings);
|
||||
BLI_task_parallel_range(0, looptris.size(), &tri_data, lineart_load_tri_task, &tri_settings);
|
||||
|
||||
/* Check for contour lines in the mesh.
|
||||
* IE check if the triangle edges lies in area where the triangles go from front facing to back
|
||||
|
@ -2098,11 +2097,11 @@ static void lineart_geometry_object_load(LineartObjectInfo *ob_info,
|
|||
edge_feat_data.ld = la_data;
|
||||
edge_feat_data.me = me;
|
||||
edge_feat_data.ob_eval = ob_info->original_ob_eval;
|
||||
edge_feat_data.mlooptri = mlooptri;
|
||||
edge_feat_data.material_indices = material_indices;
|
||||
edge_feat_data.edges = me->edges();
|
||||
edge_feat_data.polys = me->polys();
|
||||
edge_feat_data.loops = me->loops();
|
||||
edge_feat_data.looptris = looptris;
|
||||
edge_feat_data.sharp_edges = sharp_edges;
|
||||
edge_feat_data.edge_nabr = lineart_build_edge_neighbor(me, total_edges);
|
||||
edge_feat_data.tri_array = la_tri_arr;
|
||||
|
|
|
@ -66,7 +66,7 @@ static void init_dualcon_mesh(DualConInput *input, Mesh *mesh)
|
|||
input->mloop = (DualConLoop)mesh->loops().data();
|
||||
input->loop_stride = sizeof(MLoop);
|
||||
|
||||
input->looptri = (DualConTri)BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
input->looptri = (DualConTri)mesh->looptris().data();
|
||||
input->tri_stride = sizeof(MLoopTri);
|
||||
input->tottri = BKE_mesh_runtime_looptri_len(mesh);
|
||||
|
||||
|
|
|
@ -68,10 +68,10 @@ struct SDefBindCalcData {
|
|||
const SDefAdjacencyArray *vert_edges;
|
||||
const SDefEdgePolys *edge_polys;
|
||||
SDefVert *bind_verts;
|
||||
const MLoopTri *looptri;
|
||||
blender::Span<MEdge> edges;
|
||||
blender::Span<MPoly> polys;
|
||||
blender::Span<MLoop> loops;
|
||||
blender::Span<MLoopTri> looptris;
|
||||
|
||||
/** Coordinates to bind to, transformed into local space (compatible with `vertexCos`). */
|
||||
float (*targetCos)[3];
|
||||
|
@ -396,7 +396,7 @@ BLI_INLINE uint nearestVert(SDefBindCalcData *const data, const float point_co[3
|
|||
BLI_bvhtree_find_nearest(
|
||||
data->treeData->tree, t_point, &nearest, data->treeData->nearest_callback, data->treeData);
|
||||
|
||||
poly = &data->polys[data->looptri[nearest.index].poly];
|
||||
poly = &data->polys[data->looptris[nearest.index].poly];
|
||||
loop = &data->loops[poly->loopstart];
|
||||
|
||||
for (int i = 0; i < poly->totloop; i++, loop++) {
|
||||
|
@ -1266,7 +1266,7 @@ static bool surfacedeformBind(Object *ob,
|
|||
data.polys = polys;
|
||||
data.edges = edges;
|
||||
data.loops = loops;
|
||||
data.looptri = BKE_mesh_runtime_looptri_ensure(target);
|
||||
data.looptris = target->looptris();
|
||||
data.targetCos = static_cast<float(*)[3]>(
|
||||
MEM_malloc_arrayN(target_verts_num, sizeof(float[3]), "SDefTargetBindVertArray"));
|
||||
data.bind_verts = smd_orig->verts;
|
||||
|
|
|
@ -597,7 +597,6 @@ bool RE_bake_pixels_populate_from_objects(Mesh *me_low,
|
|||
tris_high[i] = mesh_calc_tri_tessface(highpoly[i].me, false, nullptr);
|
||||
|
||||
me_highpoly[i] = highpoly[i].me;
|
||||
BKE_mesh_runtime_looptri_ensure(me_highpoly[i]);
|
||||
|
||||
if (BKE_mesh_runtime_looptri_len(me_highpoly[i]) != 0) {
|
||||
/* Create a BVH-tree for each `highpoly` object. */
|
||||
|
|
Loading…
Reference in New Issue