Merge branch 'master' into blender2.8
This commit is contained in:
commit
a855a763c2
|
@ -349,8 +349,9 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
|
|||
|
||||
/* Mark an arbitrary vertex as root */
|
||||
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
|
||||
vs = CustomData_bmesh_get(&bm->vdata, v->head.data,
|
||||
CD_MVERT_SKIN);
|
||||
vs = CustomData_bmesh_get(
|
||||
&bm->vdata, v->head.data,
|
||||
CD_MVERT_SKIN);
|
||||
vs->flag |= MVERT_SKIN_ROOT;
|
||||
break;
|
||||
}
|
||||
|
@ -358,11 +359,12 @@ void BKE_mesh_ensure_skin_customdata(Mesh *me)
|
|||
}
|
||||
else {
|
||||
if (!CustomData_has_layer(&me->vdata, CD_MVERT_SKIN)) {
|
||||
vs = CustomData_add_layer(&me->vdata,
|
||||
CD_MVERT_SKIN,
|
||||
CD_DEFAULT,
|
||||
NULL,
|
||||
me->totvert);
|
||||
vs = CustomData_add_layer(
|
||||
&me->vdata,
|
||||
CD_MVERT_SKIN,
|
||||
CD_DEFAULT,
|
||||
NULL,
|
||||
me->totvert);
|
||||
|
||||
/* Mark an arbitrary vertex as root */
|
||||
if (vs) {
|
||||
|
@ -384,11 +386,12 @@ bool BKE_mesh_ensure_facemap_customdata(struct Mesh *me)
|
|||
}
|
||||
else {
|
||||
if (!CustomData_has_layer(&me->pdata, CD_FACEMAP)) {
|
||||
CustomData_add_layer(&me->pdata,
|
||||
CD_FACEMAP,
|
||||
CD_DEFAULT,
|
||||
NULL,
|
||||
me->totpoly);
|
||||
CustomData_add_layer(
|
||||
&me->pdata,
|
||||
CD_FACEMAP,
|
||||
CD_DEFAULT,
|
||||
NULL,
|
||||
me->totpoly);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
@ -1200,9 +1203,10 @@ int poly_get_adj_loops_from_vert(
|
|||
const MLoop *mloop, unsigned int vert,
|
||||
unsigned int r_adj[2])
|
||||
{
|
||||
int corner = poly_find_loop_from_vert(poly,
|
||||
&mloop[poly->loopstart],
|
||||
vert);
|
||||
int corner = poly_find_loop_from_vert(
|
||||
poly,
|
||||
&mloop[poly->loopstart],
|
||||
vert);
|
||||
|
||||
if (corner != -1) {
|
||||
#if 0 /* unused - this loop */
|
||||
|
@ -1310,11 +1314,12 @@ void BKE_mesh_ensure_navmesh(Mesh *me)
|
|||
|
||||
void BKE_mesh_tessface_calc(Mesh *mesh)
|
||||
{
|
||||
mesh->totface = BKE_mesh_recalc_tessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata,
|
||||
mesh->mvert,
|
||||
mesh->totface, mesh->totloop, mesh->totpoly,
|
||||
/* calc normals right after, don't copy from polys here */
|
||||
false);
|
||||
mesh->totface = BKE_mesh_recalc_tessellation(
|
||||
&mesh->fdata, &mesh->ldata, &mesh->pdata,
|
||||
mesh->mvert,
|
||||
mesh->totface, mesh->totloop, mesh->totpoly,
|
||||
/* calc normals right after, don't copy from polys here */
|
||||
false);
|
||||
|
||||
BKE_mesh_update_customdata_pointers(mesh, true);
|
||||
}
|
||||
|
@ -1564,8 +1569,8 @@ void BKE_mesh_calc_normals_split_ex(Mesh *mesh, MLoopNorSpaceArray *r_lnors_spac
|
|||
else {
|
||||
polynors = MEM_malloc_arrayN(mesh->totpoly, sizeof(float[3]), __func__);
|
||||
BKE_mesh_calc_normals_poly(
|
||||
mesh->mvert, NULL, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false);
|
||||
mesh->mvert, NULL, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, polynors, false);
|
||||
free_polynors = true;
|
||||
}
|
||||
|
||||
|
@ -1845,8 +1850,9 @@ void BKE_mesh_split_faces(Mesh *mesh, bool free_loop_normals)
|
|||
|
||||
/* **** Depsgraph evaluation **** */
|
||||
|
||||
void BKE_mesh_eval_geometry(Depsgraph *depsgraph,
|
||||
Mesh *mesh)
|
||||
void BKE_mesh_eval_geometry(
|
||||
Depsgraph *depsgraph,
|
||||
Mesh *mesh)
|
||||
{
|
||||
DEG_debug_print_eval(depsgraph, __func__, mesh->id.name, mesh);
|
||||
if (mesh->bb == NULL || (mesh->bb->flag & BOUNDBOX_DIRTY)) {
|
||||
|
|
|
@ -134,9 +134,10 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
|
|||
/**
|
||||
* Specialized function to use when we _know_ existing edges don't overlap with poly edges.
|
||||
*/
|
||||
static void make_edges_mdata_extend(MEdge **r_alledge, int *r_totedge,
|
||||
const MPoly *mpoly, MLoop *mloop,
|
||||
const int totpoly)
|
||||
static void make_edges_mdata_extend(
|
||||
MEdge **r_alledge, int *r_totedge,
|
||||
const MPoly *mpoly, MLoop *mloop,
|
||||
const int totpoly)
|
||||
{
|
||||
int totedge = *r_totedge;
|
||||
int totedge_new;
|
||||
|
@ -561,10 +562,11 @@ void BKE_mesh_from_nurbs_displist(
|
|||
cu = ob->data;
|
||||
|
||||
if (dm == NULL) {
|
||||
if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert,
|
||||
&alledge, &totedge, &allloop,
|
||||
&allpoly, (use_orco_uv) ? &alluv : NULL,
|
||||
&totloop, &totpoly) != 0)
|
||||
if (BKE_mesh_nurbs_displist_to_mdata(
|
||||
ob, dispbase, &allvert, &totvert,
|
||||
&alledge, &totedge, &allloop,
|
||||
&allpoly, (use_orco_uv) ? &alluv : NULL,
|
||||
&totloop, &totpoly) != 0)
|
||||
{
|
||||
/* Error initializing */
|
||||
return;
|
||||
|
@ -1143,12 +1145,13 @@ Mesh *BKE_mesh_create_derived_for_modifier(
|
|||
float (*deformedVerts)[3] = BKE_mesh_vertexCos_get(me, &numVerts);
|
||||
|
||||
modifier_deformVerts(md, &mectx, NULL, deformedVerts, numVerts);
|
||||
BKE_id_copy_ex(NULL, &me->id, (ID **)&result,
|
||||
LIB_ID_CREATE_NO_MAIN |
|
||||
LIB_ID_CREATE_NO_USER_REFCOUNT |
|
||||
LIB_ID_CREATE_NO_DEG_TAG |
|
||||
LIB_ID_COPY_NO_PREVIEW,
|
||||
false);
|
||||
BKE_id_copy_ex(
|
||||
NULL, &me->id, (ID **)&result,
|
||||
LIB_ID_CREATE_NO_MAIN |
|
||||
LIB_ID_CREATE_NO_USER_REFCOUNT |
|
||||
LIB_ID_CREATE_NO_DEG_TAG |
|
||||
LIB_ID_COPY_NO_PREVIEW,
|
||||
false);
|
||||
BKE_mesh_apply_vert_coords(result, deformedVerts);
|
||||
|
||||
if (build_shapekey_layers)
|
||||
|
@ -1158,12 +1161,13 @@ Mesh *BKE_mesh_create_derived_for_modifier(
|
|||
}
|
||||
else {
|
||||
Mesh *mesh_temp;
|
||||
BKE_id_copy_ex(NULL, &me->id, (ID **)&mesh_temp,
|
||||
LIB_ID_CREATE_NO_MAIN |
|
||||
LIB_ID_CREATE_NO_USER_REFCOUNT |
|
||||
LIB_ID_CREATE_NO_DEG_TAG |
|
||||
LIB_ID_COPY_NO_PREVIEW,
|
||||
false);
|
||||
BKE_id_copy_ex(
|
||||
NULL, &me->id, (ID **)&mesh_temp,
|
||||
LIB_ID_CREATE_NO_MAIN |
|
||||
LIB_ID_CREATE_NO_USER_REFCOUNT |
|
||||
LIB_ID_CREATE_NO_DEG_TAG |
|
||||
LIB_ID_COPY_NO_PREVIEW,
|
||||
false);
|
||||
|
||||
if (build_shapekey_layers)
|
||||
add_shapekey_layers(mesh_temp, me);
|
||||
|
@ -1314,14 +1318,16 @@ void BKE_mesh_nomain_to_mesh(Mesh *mesh_src, Mesh *mesh_dst, Object *ob, CustomD
|
|||
/* TODO(Sybren): we could probably replace CD_ASSIGN with alloctype and always directly pass mesh_src->mxxx,
|
||||
* instead of using a ternary operator. */
|
||||
if (!CustomData_has_layer(&tmp.vdata, CD_MVERT)) {
|
||||
CustomData_add_layer(&tmp.vdata, CD_MVERT, CD_ASSIGN,
|
||||
(alloctype == CD_ASSIGN) ? mesh_src->mvert : MEM_dupallocN(mesh_src->mvert),
|
||||
totvert);
|
||||
CustomData_add_layer(
|
||||
&tmp.vdata, CD_MVERT, CD_ASSIGN,
|
||||
(alloctype == CD_ASSIGN) ? mesh_src->mvert : MEM_dupallocN(mesh_src->mvert),
|
||||
totvert);
|
||||
}
|
||||
if (!CustomData_has_layer(&tmp.edata, CD_MEDGE)) {
|
||||
CustomData_add_layer(&tmp.edata, CD_MEDGE, CD_ASSIGN,
|
||||
(alloctype == CD_ASSIGN) ? mesh_src->medge : MEM_dupallocN(mesh_src->medge),
|
||||
totedge);
|
||||
CustomData_add_layer(
|
||||
&tmp.edata, CD_MEDGE, CD_ASSIGN,
|
||||
(alloctype == CD_ASSIGN) ? mesh_src->medge : MEM_dupallocN(mesh_src->medge),
|
||||
totedge);
|
||||
}
|
||||
if (!CustomData_has_layer(&tmp.pdata, CD_MPOLY)) {
|
||||
/* TODO(Sybren): assigment to tmp.mxxx is probably not necessary due to the
|
||||
|
|
|
@ -96,10 +96,10 @@ void BKE_mesh_calc_normals_mapping_simple(struct Mesh *mesh)
|
|||
const bool only_face_normals = CustomData_is_referenced_layer(&mesh->vdata, CD_MVERT);
|
||||
|
||||
BKE_mesh_calc_normals_mapping_ex(
|
||||
mesh->mvert, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL,
|
||||
mesh->mface, mesh->totface, NULL, NULL,
|
||||
only_face_normals);
|
||||
mesh->mvert, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL,
|
||||
mesh->mface, mesh->totface, NULL, NULL,
|
||||
only_face_normals);
|
||||
}
|
||||
|
||||
/* Calculate vertex and face normals, face normals are returned in *r_faceNors if non-NULL
|
||||
|
@ -360,9 +360,10 @@ void BKE_mesh_calc_normals(Mesh *mesh)
|
|||
#ifdef DEBUG_TIME
|
||||
TIMEIT_START_AVERAGED(BKE_mesh_calc_normals);
|
||||
#endif
|
||||
BKE_mesh_calc_normals_poly(mesh->mvert, NULL, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
||||
NULL, false);
|
||||
BKE_mesh_calc_normals_poly(
|
||||
mesh->mvert, NULL, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
||||
NULL, false);
|
||||
#ifdef DEBUG_TIME
|
||||
TIMEIT_END_AVERAGED(BKE_mesh_calc_normals);
|
||||
#endif
|
||||
|
@ -511,8 +512,9 @@ MLoopNorSpace *BKE_lnor_space_create(MLoopNorSpaceArray *lnors_spacearr)
|
|||
* Beware, this modifies ref_vec and other_vec in place!
|
||||
* In case no valid space can be generated, ref_alpha and ref_beta are set to zero (which means 'use auto lnors').
|
||||
*/
|
||||
void BKE_lnor_space_define(MLoopNorSpace *lnor_space, const float lnor[3],
|
||||
float vec_ref[3], float vec_other[3], BLI_Stack *edge_vectors)
|
||||
void BKE_lnor_space_define(
|
||||
MLoopNorSpace *lnor_space, const float lnor[3],
|
||||
float vec_ref[3], float vec_other[3], BLI_Stack *edge_vectors)
|
||||
{
|
||||
const float pi2 = (float)M_PI * 2.0f;
|
||||
float tvec[3], dtp;
|
||||
|
@ -794,8 +796,9 @@ static void mesh_edges_sharp_tag(
|
|||
e2l[1] = (mp->flag & ME_SMOOTH) ? INDEX_UNSET : INDEX_INVALID;
|
||||
}
|
||||
else if (e2l[1] == INDEX_UNSET) {
|
||||
const bool is_angle_sharp = (check_angle &&
|
||||
dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) < split_angle_cos);
|
||||
const bool is_angle_sharp = (
|
||||
check_angle &&
|
||||
dot_v3v3(polynors[loop_to_poly[e2l[0]]], polynors[mp_index]) < split_angle_cos);
|
||||
|
||||
/* Second loop using this edge, time to test its sharpness.
|
||||
* An edge is sharp if it is tagged as such, or its face is not smooth,
|
||||
|
@ -1128,8 +1131,8 @@ static void split_loop_nor_fan_do(LoopSplitTaskDataCommon *common_data, LoopSpli
|
|||
|
||||
/* Find next loop of the smooth fan. */
|
||||
BKE_mesh_loop_manifold_fan_around_vert_next(
|
||||
mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
|
||||
&mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
|
||||
mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
|
||||
&mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
|
||||
|
||||
e2lfan_curr = edge_to_loops[mlfan_curr->e];
|
||||
}
|
||||
|
@ -1265,8 +1268,8 @@ static bool loop_split_generator_check_cyclic_smooth_fan(
|
|||
while (true) {
|
||||
/* Find next loop of the smooth fan. */
|
||||
BKE_mesh_loop_manifold_fan_around_vert_next(
|
||||
mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
|
||||
&mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
|
||||
mloops, mpolys, loop_to_poly, e2lfan_curr, mv_pivot_index,
|
||||
&mlfan_curr, &mlfan_curr_index, &mlfan_vert_index, &mpfan_curr_index);
|
||||
|
||||
e2lfan_curr = edge_to_loops[mlfan_curr->e];
|
||||
|
||||
|
@ -1615,9 +1618,10 @@ static void mesh_normals_loop_custom_set(
|
|||
BLI_SMALLSTACK_DECLARE(clnors_data, short *);
|
||||
|
||||
/* Compute current lnor spacearr. */
|
||||
BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
|
||||
mpolys, polynors, numPolys, use_split_normals, split_angle,
|
||||
&lnors_spacearr, NULL, loop_to_poly);
|
||||
BKE_mesh_normals_loop_split(
|
||||
mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
|
||||
mpolys, polynors, numPolys, use_split_normals, split_angle,
|
||||
&lnors_spacearr, NULL, loop_to_poly);
|
||||
|
||||
/* Set all given zero vectors to their default value. */
|
||||
if (use_vertices) {
|
||||
|
@ -1725,9 +1729,10 @@ static void mesh_normals_loop_custom_set(
|
|||
|
||||
/* And now, recompute our new auto lnors and lnor spacearr! */
|
||||
BKE_lnor_spacearr_clear(&lnors_spacearr);
|
||||
BKE_mesh_normals_loop_split(mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
|
||||
mpolys, polynors, numPolys, use_split_normals, split_angle,
|
||||
&lnors_spacearr, NULL, loop_to_poly);
|
||||
BKE_mesh_normals_loop_split(
|
||||
mverts, numVerts, medges, numEdges, mloops, lnors, numLoops,
|
||||
mpolys, polynors, numPolys, use_split_normals, split_angle,
|
||||
&lnors_spacearr, NULL, loop_to_poly);
|
||||
}
|
||||
else {
|
||||
BLI_BITMAP_SET_ALL(done_loops, true, (size_t)numLoops);
|
||||
|
@ -1799,8 +1804,9 @@ void BKE_mesh_normals_loop_custom_set(
|
|||
MPoly *mpolys, const float (*polynors)[3], const int numPolys,
|
||||
short (*r_clnors_data)[2])
|
||||
{
|
||||
mesh_normals_loop_custom_set(mverts, numVerts, medges, numEdges, mloops, r_custom_loopnors, numLoops,
|
||||
mpolys, polynors, numPolys, r_clnors_data, false);
|
||||
mesh_normals_loop_custom_set(
|
||||
mverts, numVerts, medges, numEdges, mloops, r_custom_loopnors, numLoops,
|
||||
mpolys, polynors, numPolys, r_clnors_data, false);
|
||||
}
|
||||
|
||||
void BKE_mesh_normals_loop_custom_from_vertices_set(
|
||||
|
@ -1809,8 +1815,9 @@ void BKE_mesh_normals_loop_custom_from_vertices_set(
|
|||
MPoly *mpolys, const float (*polynors)[3], const int numPolys,
|
||||
short (*r_clnors_data)[2])
|
||||
{
|
||||
mesh_normals_loop_custom_set(mverts, numVerts, medges, numEdges, mloops, r_custom_vertnors, numLoops,
|
||||
mpolys, polynors, numPolys, r_clnors_data, true);
|
||||
mesh_normals_loop_custom_set(
|
||||
mverts, numVerts, medges, numEdges, mloops, r_custom_vertnors, numLoops,
|
||||
mpolys, polynors, numPolys, r_clnors_data, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1894,19 +1901,19 @@ void BKE_mesh_calc_poly_normal(
|
|||
mesh_calc_ngon_normal(mpoly, loopstart, mvarray, r_no);
|
||||
}
|
||||
else if (mpoly->totloop == 3) {
|
||||
normal_tri_v3(r_no,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co
|
||||
);
|
||||
normal_tri_v3(
|
||||
r_no,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co);
|
||||
}
|
||||
else if (mpoly->totloop == 4) {
|
||||
normal_quad_v3(r_no,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co,
|
||||
mvarray[loopstart[3].v].co
|
||||
);
|
||||
normal_quad_v3(
|
||||
r_no,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co,
|
||||
mvarray[loopstart[3].v].co);
|
||||
}
|
||||
else { /* horrible, two sided face! */
|
||||
r_no[0] = 0.0;
|
||||
|
@ -1946,19 +1953,19 @@ void BKE_mesh_calc_poly_normal_coords(
|
|||
mesh_calc_ngon_normal_coords(mpoly, loopstart, vertex_coords, r_no);
|
||||
}
|
||||
else if (mpoly->totloop == 3) {
|
||||
normal_tri_v3(r_no,
|
||||
vertex_coords[loopstart[0].v],
|
||||
vertex_coords[loopstart[1].v],
|
||||
vertex_coords[loopstart[2].v]
|
||||
);
|
||||
normal_tri_v3(
|
||||
r_no,
|
||||
vertex_coords[loopstart[0].v],
|
||||
vertex_coords[loopstart[1].v],
|
||||
vertex_coords[loopstart[2].v]);
|
||||
}
|
||||
else if (mpoly->totloop == 4) {
|
||||
normal_quad_v3(r_no,
|
||||
vertex_coords[loopstart[0].v],
|
||||
vertex_coords[loopstart[1].v],
|
||||
vertex_coords[loopstart[2].v],
|
||||
vertex_coords[loopstart[3].v]
|
||||
);
|
||||
normal_quad_v3(
|
||||
r_no,
|
||||
vertex_coords[loopstart[0].v],
|
||||
vertex_coords[loopstart[1].v],
|
||||
vertex_coords[loopstart[2].v],
|
||||
vertex_coords[loopstart[3].v]);
|
||||
}
|
||||
else { /* horrible, two sided face! */
|
||||
r_no[0] = 0.0;
|
||||
|
@ -1986,19 +1993,19 @@ void BKE_mesh_calc_poly_center(
|
|||
const MVert *mvarray, float r_cent[3])
|
||||
{
|
||||
if (mpoly->totloop == 3) {
|
||||
mid_v3_v3v3v3(r_cent,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co
|
||||
);
|
||||
mid_v3_v3v3v3(
|
||||
r_cent,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co);
|
||||
}
|
||||
else if (mpoly->totloop == 4) {
|
||||
mid_v3_v3v3v3v3(r_cent,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co,
|
||||
mvarray[loopstart[3].v].co
|
||||
);
|
||||
mid_v3_v3v3v3v3(
|
||||
r_cent,
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co,
|
||||
mvarray[loopstart[3].v].co);
|
||||
}
|
||||
else {
|
||||
mesh_calc_ngon_center(mpoly, loopstart, mvarray, r_cent);
|
||||
|
@ -2011,10 +2018,10 @@ float BKE_mesh_calc_poly_area(
|
|||
const MVert *mvarray)
|
||||
{
|
||||
if (mpoly->totloop == 3) {
|
||||
return area_tri_v3(mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co
|
||||
);
|
||||
return area_tri_v3(
|
||||
mvarray[loopstart[0].v].co,
|
||||
mvarray[loopstart[1].v].co,
|
||||
mvarray[loopstart[2].v].co);
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
|
@ -2125,8 +2132,9 @@ static float mesh_calc_poly_area_centroid(
|
|||
}
|
||||
|
||||
#if 0 /* slow version of the function below */
|
||||
void BKE_mesh_calc_poly_angles(MPoly *mpoly, MLoop *loopstart,
|
||||
MVert *mvarray, float angles[])
|
||||
void BKE_mesh_calc_poly_angles(
|
||||
MPoly *mpoly, MLoop *loopstart,
|
||||
MVert *mvarray, float angles[])
|
||||
{
|
||||
MLoop *ml;
|
||||
MLoop *mloop = &loopstart[-mpoly->loopstart];
|
||||
|
@ -2494,8 +2502,9 @@ void BKE_mesh_loops_to_mface_corners(
|
|||
*
|
||||
* \note when mface is not NULL, mface[face_index].v4 is used to test quads, else, loopindices[face_index][3] is used.
|
||||
*/
|
||||
void BKE_mesh_loops_to_tessdata(CustomData *fdata, CustomData *ldata, MFace *mface,
|
||||
int *polyindices, unsigned int (*loopindices)[4], const int num_faces)
|
||||
void BKE_mesh_loops_to_tessdata(
|
||||
CustomData *fdata, CustomData *ldata, MFace *mface,
|
||||
int *polyindices, unsigned int (*loopindices)[4], const int num_faces)
|
||||
{
|
||||
/* Note: performances are sub-optimal when we get a NULL mface, we could be ~25% quicker with dedicated code...
|
||||
* Issue is, unless having two different functions with nearly the same code, there's not much ways to solve
|
||||
|
@ -3088,8 +3097,9 @@ static void bm_corners_to_loops_ex(
|
|||
|
||||
if (CustomData_external_test(fdata, CD_MDISPS)) {
|
||||
if (id && fdata->external) {
|
||||
CustomData_external_add(ldata, id, CD_MDISPS,
|
||||
totloop, fdata->external->filename);
|
||||
CustomData_external_add(
|
||||
ldata, id, CD_MDISPS,
|
||||
totloop, fdata->external->filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3127,10 +3137,11 @@ static void bm_corners_to_loops_ex(
|
|||
|
||||
void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
|
||||
{
|
||||
BKE_mesh_convert_mfaces_to_mpolys_ex(&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
|
||||
mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
|
||||
mesh->medge, mesh->mface,
|
||||
&mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
|
||||
BKE_mesh_convert_mfaces_to_mpolys_ex(
|
||||
&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
|
||||
mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
|
||||
mesh->medge, mesh->mface,
|
||||
&mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
|
||||
|
||||
BKE_mesh_update_customdata_pointers(mesh, true);
|
||||
}
|
||||
|
@ -3147,21 +3158,23 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh)
|
|||
*/
|
||||
void BKE_mesh_do_versions_convert_mfaces_to_mpolys(Mesh *mesh)
|
||||
{
|
||||
BKE_mesh_convert_mfaces_to_mpolys_ex(&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
|
||||
mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
|
||||
mesh->medge, mesh->mface,
|
||||
&mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
|
||||
BKE_mesh_convert_mfaces_to_mpolys_ex(
|
||||
&mesh->id, &mesh->fdata, &mesh->ldata, &mesh->pdata,
|
||||
mesh->totedge, mesh->totface, mesh->totloop, mesh->totpoly,
|
||||
mesh->medge, mesh->mface,
|
||||
&mesh->totloop, &mesh->totpoly, &mesh->mloop, &mesh->mpoly);
|
||||
|
||||
CustomData_bmesh_do_versions_update_active_layers(&mesh->fdata, &mesh->ldata);
|
||||
|
||||
BKE_mesh_update_customdata_pointers(mesh, true);
|
||||
}
|
||||
|
||||
void BKE_mesh_convert_mfaces_to_mpolys_ex(ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata,
|
||||
int totedge_i, int totface_i, int totloop_i, int totpoly_i,
|
||||
MEdge *medge, MFace *mface,
|
||||
int *r_totloop, int *r_totpoly,
|
||||
MLoop **r_mloop, MPoly **r_mpoly)
|
||||
void BKE_mesh_convert_mfaces_to_mpolys_ex(
|
||||
ID *id, CustomData *fdata, CustomData *ldata, CustomData *pdata,
|
||||
int totedge_i, int totface_i, int totloop_i, int totpoly_i,
|
||||
MEdge *medge, MFace *mface,
|
||||
int *r_totloop, int *r_totpoly,
|
||||
MLoop **r_mloop, MPoly **r_mpoly)
|
||||
{
|
||||
MFace *mf;
|
||||
MLoop *ml, *mloop;
|
||||
|
@ -3385,10 +3398,11 @@ void BKE_mesh_polygons_flip(
|
|||
|
||||
/* update the hide flag for edges and faces from the corresponding
|
||||
* flag in verts */
|
||||
void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert,
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int totedge,
|
||||
MPoly *mpoly, const int totpoly)
|
||||
void BKE_mesh_flush_hidden_from_verts_ex(
|
||||
const MVert *mvert,
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int totedge,
|
||||
MPoly *mpoly, const int totpoly)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -3414,15 +3428,17 @@ void BKE_mesh_flush_hidden_from_verts_ex(const MVert *mvert,
|
|||
}
|
||||
void BKE_mesh_flush_hidden_from_verts(Mesh *me)
|
||||
{
|
||||
BKE_mesh_flush_hidden_from_verts_ex(me->mvert, me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
BKE_mesh_flush_hidden_from_verts_ex(
|
||||
me->mvert, me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
}
|
||||
|
||||
void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert,
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int UNUSED(totedge),
|
||||
const MPoly *mpoly, const int totpoly)
|
||||
void BKE_mesh_flush_hidden_from_polys_ex(
|
||||
MVert *mvert,
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int UNUSED(totedge),
|
||||
const MPoly *mpoly, const int totpoly)
|
||||
{
|
||||
const MPoly *mp;
|
||||
int i;
|
||||
|
@ -3455,18 +3471,20 @@ void BKE_mesh_flush_hidden_from_polys_ex(MVert *mvert,
|
|||
}
|
||||
void BKE_mesh_flush_hidden_from_polys(Mesh *me)
|
||||
{
|
||||
BKE_mesh_flush_hidden_from_polys_ex(me->mvert, me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
BKE_mesh_flush_hidden_from_polys_ex(
|
||||
me->mvert, me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
}
|
||||
|
||||
/**
|
||||
* simple poly -> vert/edge selection.
|
||||
*/
|
||||
void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert,
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int totedge,
|
||||
const MPoly *mpoly, const int totpoly)
|
||||
void BKE_mesh_flush_select_from_polys_ex(
|
||||
MVert *mvert, const int totvert,
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int totedge,
|
||||
const MPoly *mpoly, const int totpoly)
|
||||
{
|
||||
MVert *mv;
|
||||
MEdge *med;
|
||||
|
@ -3500,16 +3518,18 @@ void BKE_mesh_flush_select_from_polys_ex(MVert *mvert, const int totvert,
|
|||
}
|
||||
void BKE_mesh_flush_select_from_polys(Mesh *me)
|
||||
{
|
||||
BKE_mesh_flush_select_from_polys_ex(me->mvert, me->totvert,
|
||||
me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
BKE_mesh_flush_select_from_polys_ex(
|
||||
me->mvert, me->totvert,
|
||||
me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
}
|
||||
|
||||
void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(totvert),
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int totedge,
|
||||
MPoly *mpoly, const int totpoly)
|
||||
void BKE_mesh_flush_select_from_verts_ex(
|
||||
const MVert *mvert, const int UNUSED(totvert),
|
||||
const MLoop *mloop,
|
||||
MEdge *medge, const int totedge,
|
||||
MPoly *mpoly, const int totpoly)
|
||||
{
|
||||
MEdge *med;
|
||||
MPoly *mp;
|
||||
|
@ -3554,10 +3574,11 @@ void BKE_mesh_flush_select_from_verts_ex(const MVert *mvert, const int UNUSED(to
|
|||
}
|
||||
void BKE_mesh_flush_select_from_verts(Mesh *me)
|
||||
{
|
||||
BKE_mesh_flush_select_from_verts_ex(me->mvert, me->totvert,
|
||||
me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
BKE_mesh_flush_select_from_verts_ex(
|
||||
me->mvert, me->totvert,
|
||||
me->mloop,
|
||||
me->medge, me->totedge,
|
||||
me->mpoly, me->totpoly);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
@ -3585,7 +3606,7 @@ void BKE_mesh_calc_relative_deform(
|
|||
const float (*vert_cos_dst)[3],
|
||||
|
||||
const float (*vert_cos_org)[3],
|
||||
float (*vert_cos_new)[3])
|
||||
float (*vert_cos_new)[3])
|
||||
{
|
||||
const MPoly *mp;
|
||||
int i;
|
||||
|
|
|
@ -243,9 +243,10 @@ static void mesh_vert_poly_or_loop_map_create(
|
|||
* Generates a map where the key is the vertex and the value is a list of polys that use that vertex as a corner.
|
||||
* The lists are allocated from one memory pool.
|
||||
*/
|
||||
void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
|
||||
const MPoly *mpoly, const MLoop *mloop,
|
||||
int totvert, int totpoly, int totloop)
|
||||
void BKE_mesh_vert_poly_map_create(
|
||||
MeshElemMap **r_map, int **r_mem,
|
||||
const MPoly *mpoly, const MLoop *mloop,
|
||||
int totvert, int totpoly, int totloop)
|
||||
{
|
||||
mesh_vert_poly_or_loop_map_create(r_map, r_mem, mpoly, mloop, totvert, totpoly, totloop, false);
|
||||
}
|
||||
|
@ -254,9 +255,10 @@ void BKE_mesh_vert_poly_map_create(MeshElemMap **r_map, int **r_mem,
|
|||
* Generates a map where the key is the vertex and the value is a list of loops that use that vertex as a corner.
|
||||
* The lists are allocated from one memory pool.
|
||||
*/
|
||||
void BKE_mesh_vert_loop_map_create(MeshElemMap **r_map, int **r_mem,
|
||||
const MPoly *mpoly, const MLoop *mloop,
|
||||
int totvert, int totpoly, int totloop)
|
||||
void BKE_mesh_vert_loop_map_create(
|
||||
MeshElemMap **r_map, int **r_mem,
|
||||
const MPoly *mpoly, const MLoop *mloop,
|
||||
int totvert, int totpoly, int totloop)
|
||||
{
|
||||
mesh_vert_poly_or_loop_map_create(r_map, r_mem, mpoly, mloop, totvert, totpoly, totloop, true);
|
||||
}
|
||||
|
@ -310,8 +312,9 @@ void BKE_mesh_vert_looptri_map_create(
|
|||
* Generates a map where the key is the vertex and the value is a list of edges that use that vertex as an endpoint.
|
||||
* The lists are allocated from one memory pool.
|
||||
*/
|
||||
void BKE_mesh_vert_edge_map_create(MeshElemMap **r_map, int **r_mem,
|
||||
const MEdge *medge, int totvert, int totedge)
|
||||
void BKE_mesh_vert_edge_map_create(
|
||||
MeshElemMap **r_map, int **r_mem,
|
||||
const MEdge *medge, int totvert, int totedge)
|
||||
{
|
||||
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totvert, "vert-edge map");
|
||||
int *indices = MEM_mallocN(sizeof(int[2]) * (size_t)totedge, "vert-edge map mem");
|
||||
|
@ -397,10 +400,11 @@ void BKE_mesh_vert_edge_vert_map_create(
|
|||
* Loops indices of a same poly are contiguous and in winding order.
|
||||
* The lists are allocated from one memory pool.
|
||||
*/
|
||||
void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, int **r_mem,
|
||||
const MEdge *UNUSED(medge), const int totedge,
|
||||
const MPoly *mpoly, const int totpoly,
|
||||
const MLoop *mloop, const int totloop)
|
||||
void BKE_mesh_edge_loop_map_create(
|
||||
MeshElemMap **r_map, int **r_mem,
|
||||
const MEdge *UNUSED(medge), const int totedge,
|
||||
const MPoly *mpoly, const int totpoly,
|
||||
const MLoop *mloop, const int totloop)
|
||||
{
|
||||
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, "edge-poly map");
|
||||
int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop * 2, "edge-poly map mem");
|
||||
|
@ -450,10 +454,11 @@ void BKE_mesh_edge_loop_map_create(MeshElemMap **r_map, int **r_mem,
|
|||
* Generates a map where the key is the edge and the value is a list of polygons that use that edge.
|
||||
* The lists are allocated from one memory pool.
|
||||
*/
|
||||
void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem,
|
||||
const MEdge *UNUSED(medge), const int totedge,
|
||||
const MPoly *mpoly, const int totpoly,
|
||||
const MLoop *mloop, const int totloop)
|
||||
void BKE_mesh_edge_poly_map_create(
|
||||
MeshElemMap **r_map, int **r_mem,
|
||||
const MEdge *UNUSED(medge), const int totedge,
|
||||
const MPoly *mpoly, const int totpoly,
|
||||
const MLoop *mloop, const int totloop)
|
||||
{
|
||||
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totedge, "edge-poly map");
|
||||
int *indices = MEM_mallocN(sizeof(int) * (size_t)totloop, "edge-poly map mem");
|
||||
|
@ -509,9 +514,10 @@ void BKE_mesh_edge_poly_map_create(MeshElemMap **r_map, int **r_mem,
|
|||
* ``totfinal`` could be ``tottessface`` and ``final_origindex`` its ORIGINDEX customdata.
|
||||
* This would allow an MPoly to loop over its tessfaces.
|
||||
*/
|
||||
void BKE_mesh_origindex_map_create(MeshElemMap **r_map, int **r_mem,
|
||||
const int totsource,
|
||||
const int *final_origindex, const int totfinal)
|
||||
void BKE_mesh_origindex_map_create(
|
||||
MeshElemMap **r_map, int **r_mem,
|
||||
const int totsource,
|
||||
const int *final_origindex, const int totfinal)
|
||||
{
|
||||
MeshElemMap *map = MEM_callocN(sizeof(MeshElemMap) * (size_t)totsource, "poly-tessface map");
|
||||
int *indices = MEM_mallocN(sizeof(int) * (size_t)totfinal, "poly-tessface map mem");
|
||||
|
@ -632,8 +638,9 @@ static void poly_edge_loop_islands_calc(
|
|||
}
|
||||
|
||||
if (!edge_poly_map) {
|
||||
BKE_mesh_edge_poly_map_create(&edge_poly_map, &edge_poly_mem,
|
||||
medge, totedge, mpoly, totpoly, mloop, totloop);
|
||||
BKE_mesh_edge_poly_map_create(
|
||||
&edge_poly_map, &edge_poly_mem,
|
||||
medge, totedge, mpoly, totpoly, mloop, totloop);
|
||||
}
|
||||
|
||||
poly_groups = MEM_callocN(sizeof(int) * (size_t)totpoly, __func__);
|
||||
|
@ -786,10 +793,11 @@ static bool poly_is_island_boundary_smooth_cb(
|
|||
* (0 being used as 'invalid' flag).
|
||||
* Note it's callers's responsibility to MEM_freeN returned array.
|
||||
*/
|
||||
int *BKE_mesh_calc_smoothgroups(const MEdge *medge, const int totedge,
|
||||
const MPoly *mpoly, const int totpoly,
|
||||
const MLoop *mloop, const int totloop,
|
||||
int *r_totgroup, const bool use_bitflags)
|
||||
int *BKE_mesh_calc_smoothgroups(
|
||||
const MEdge *medge, const int totedge,
|
||||
const MPoly *mpoly, const int totpoly,
|
||||
const MLoop *mloop, const int totloop,
|
||||
int *r_totgroup, const bool use_bitflags)
|
||||
{
|
||||
int *poly_groups = NULL;
|
||||
|
||||
|
@ -987,21 +995,23 @@ static bool mesh_calc_islands_loop_poly_uv(
|
|||
BKE_mesh_loop_islands_clear(r_island_store);
|
||||
BKE_mesh_loop_islands_init(r_island_store, MISLAND_TYPE_LOOP, totloop, MISLAND_TYPE_POLY, MISLAND_TYPE_EDGE);
|
||||
|
||||
BKE_mesh_edge_poly_map_create(&edge_poly_map, &edge_poly_mem,
|
||||
edges, totedge, polys, totpoly, loops, totloop);
|
||||
BKE_mesh_edge_poly_map_create(
|
||||
&edge_poly_map, &edge_poly_mem,
|
||||
edges, totedge, polys, totpoly, loops, totloop);
|
||||
|
||||
if (luvs) {
|
||||
BKE_mesh_edge_loop_map_create(&edge_loop_map, &edge_loop_mem,
|
||||
edges, totedge, polys, totpoly, loops, totloop);
|
||||
BKE_mesh_edge_loop_map_create(
|
||||
&edge_loop_map, &edge_loop_mem,
|
||||
edges, totedge, polys, totpoly, loops, totloop);
|
||||
edge_boundary_check_data.loops = loops;
|
||||
edge_boundary_check_data.luvs = luvs;
|
||||
edge_boundary_check_data.edge_loop_map = edge_loop_map;
|
||||
}
|
||||
|
||||
poly_edge_loop_islands_calc(
|
||||
edges, totedge, polys, totpoly, loops, totloop, edge_poly_map, false,
|
||||
mesh_check_island_boundary_uv, luvs ? &edge_boundary_check_data : NULL,
|
||||
&poly_groups, &num_poly_groups, &edge_borders, &num_edge_borders);
|
||||
edges, totedge, polys, totpoly, loops, totloop, edge_poly_map, false,
|
||||
mesh_check_island_boundary_uv, luvs ? &edge_boundary_check_data : NULL,
|
||||
&poly_groups, &num_poly_groups, &edge_borders, &num_edge_borders);
|
||||
|
||||
if (!num_poly_groups) {
|
||||
/* Should never happen... */
|
||||
|
@ -1051,8 +1061,9 @@ static bool mesh_calc_islands_loop_poly_uv(
|
|||
}
|
||||
}
|
||||
|
||||
BKE_mesh_loop_islands_add(r_island_store, num_lidx, loop_indices, num_pidx, poly_indices,
|
||||
num_einnercuts, edge_innercut_indices);
|
||||
BKE_mesh_loop_islands_add(
|
||||
r_island_store, num_lidx, loop_indices, num_pidx, poly_indices,
|
||||
num_einnercuts, edge_innercut_indices);
|
||||
}
|
||||
|
||||
MEM_freeN(edge_poly_map);
|
||||
|
@ -1089,7 +1100,7 @@ bool BKE_mesh_calc_islands_loop_poly_edgeseam(
|
|||
MeshIslandStore *r_island_store)
|
||||
{
|
||||
return mesh_calc_islands_loop_poly_uv(
|
||||
verts, totvert, edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store);
|
||||
verts, totvert, edges, totedge, polys, totpoly, loops, totloop, NULL, r_island_store);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1113,7 +1124,7 @@ bool BKE_mesh_calc_islands_loop_poly_uvmap(
|
|||
{
|
||||
BLI_assert(luvs != NULL);
|
||||
return mesh_calc_islands_loop_poly_uv(
|
||||
verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store);
|
||||
verts, totvert, edges, totedge, polys, totpoly, loops, totloop, luvs, r_island_store);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -383,9 +383,10 @@ Mesh *BKE_mesh_merge_verts(Mesh *mesh, const int *vtargetmap, const int tot_vtar
|
|||
|
||||
/* Can we optimise by reusing an old pmap ? How do we know an old pmap is stale ? */
|
||||
/* When called by MOD_array.c, the cddm has just been created, so it has no valid pmap. */
|
||||
BKE_mesh_vert_poly_map_create(&poly_map, &poly_map_mem,
|
||||
mesh->mpoly, mesh->mloop,
|
||||
totvert, totpoly, totloop);
|
||||
BKE_mesh_vert_poly_map_create(
|
||||
&poly_map, &poly_map_mem,
|
||||
mesh->mpoly, mesh->mloop,
|
||||
totvert, totpoly, totloop);
|
||||
} /* done preparing for fast poly compare */
|
||||
|
||||
|
||||
|
|
|
@ -666,8 +666,9 @@ void BKE_mesh_remap_calc_edges_from_mesh(
|
|||
v_dst_to_src_map[i].hit_dist = -1.0f;
|
||||
}
|
||||
|
||||
BKE_mesh_vert_edge_map_create(&vert_to_edge_src_map, &vert_to_edge_src_map_mem,
|
||||
edges_src, num_verts_src, num_edges_src);
|
||||
BKE_mesh_vert_edge_map_create(
|
||||
&vert_to_edge_src_map, &vert_to_edge_src_map_mem,
|
||||
edges_src, num_verts_src, num_edges_src);
|
||||
|
||||
BKE_bvhtree_from_mesh_get(&treedata, me_src, BVHTREE_FROM_VERTS, 2);
|
||||
nearest.index = -1;
|
||||
|
@ -926,8 +927,9 @@ void BKE_mesh_remap_calc_edges_from_mesh(
|
|||
indices[sources_num] = j;
|
||||
sources_num++;
|
||||
}
|
||||
mesh_remap_item_define(r_map, i, hit_dist_accum / totweights, 0,
|
||||
sources_num, indices, weights);
|
||||
mesh_remap_item_define(
|
||||
r_map, i, hit_dist_accum / totweights, 0,
|
||||
sources_num, indices, weights);
|
||||
}
|
||||
else {
|
||||
/* No source for this dest edge! */
|
||||
|
@ -1141,8 +1143,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
|
||||
BLI_AStarGraph *as_graphdata = NULL;
|
||||
BLI_AStarSolution as_solution = {0};
|
||||
const int isld_steps_src = islands_precision_src ?
|
||||
max_ii((int)(ASTAR_STEPS_MAX * islands_precision_src + 0.499f), 1) : 0;
|
||||
const int isld_steps_src = (
|
||||
islands_precision_src ?
|
||||
max_ii((int)(ASTAR_STEPS_MAX * islands_precision_src + 0.499f), 1) : 0);
|
||||
|
||||
float (*poly_nors_src)[3] = NULL;
|
||||
float (*loop_nors_src)[3] = NULL;
|
||||
|
@ -1210,8 +1213,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
}
|
||||
if (dirty_nors_dst || do_poly_nors_dst) {
|
||||
BKE_mesh_calc_normals_poly(verts_dst, NULL, numverts_dst, loops_dst, polys_dst,
|
||||
numloops_dst, numpolys_dst, poly_nors_dst, true);
|
||||
BKE_mesh_calc_normals_poly(
|
||||
verts_dst, NULL, numverts_dst, loops_dst, polys_dst,
|
||||
numloops_dst, numpolys_dst, poly_nors_dst, true);
|
||||
}
|
||||
}
|
||||
if (need_lnors_dst) {
|
||||
|
@ -1225,10 +1229,11 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
CustomData_set_layer_flag(ldata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
}
|
||||
if (dirty_nors_dst || do_loop_nors_dst) {
|
||||
BKE_mesh_normals_loop_split(verts_dst, numverts_dst, edges_dst, numedges_dst,
|
||||
loops_dst, loop_nors_dst, numloops_dst,
|
||||
polys_dst, (const float (*)[3])poly_nors_dst, numpolys_dst,
|
||||
use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL);
|
||||
BKE_mesh_normals_loop_split(
|
||||
verts_dst, numverts_dst, edges_dst, numedges_dst,
|
||||
loops_dst, loop_nors_dst, numloops_dst,
|
||||
polys_dst, (const float (*)[3])poly_nors_dst, numpolys_dst,
|
||||
use_split_nors_dst, split_angle_dst, NULL, custom_nors_dst, NULL);
|
||||
}
|
||||
}
|
||||
if (need_pnors_src || need_lnors_src) {
|
||||
|
@ -1249,17 +1254,20 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
}
|
||||
|
||||
if (use_from_vert) {
|
||||
BKE_mesh_vert_loop_map_create(&vert_to_loop_map_src, &vert_to_loop_map_src_buff,
|
||||
polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
|
||||
BKE_mesh_vert_loop_map_create(
|
||||
&vert_to_loop_map_src, &vert_to_loop_map_src_buff,
|
||||
polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
|
||||
if (mode & MREMAP_USE_POLY) {
|
||||
BKE_mesh_vert_poly_map_create(&vert_to_poly_map_src, &vert_to_poly_map_src_buff,
|
||||
polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
|
||||
BKE_mesh_vert_poly_map_create(
|
||||
&vert_to_poly_map_src, &vert_to_poly_map_src_buff,
|
||||
polys_src, loops_src, num_verts_src, num_polys_src, num_loops_src);
|
||||
}
|
||||
}
|
||||
|
||||
/* Needed for islands (or plain mesh) to AStar graph conversion. */
|
||||
BKE_mesh_edge_poly_map_create(&edge_to_poly_map_src, &edge_to_poly_map_src_buff,
|
||||
edges_src, num_edges_src, polys_src, num_polys_src, loops_src, num_loops_src);
|
||||
BKE_mesh_edge_poly_map_create(
|
||||
&edge_to_poly_map_src, &edge_to_poly_map_src_buff,
|
||||
edges_src, num_edges_src, polys_src, num_polys_src, loops_src, num_loops_src);
|
||||
if (use_from_vert) {
|
||||
loop_to_poly_map_src = MEM_mallocN(sizeof(*loop_to_poly_map_src) * (size_t)num_loops_src, __func__);
|
||||
poly_cents_src = MEM_mallocN(sizeof(*poly_cents_src) * (size_t)num_polys_src, __func__);
|
||||
|
@ -1339,8 +1347,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
}
|
||||
}
|
||||
}
|
||||
bvhtree_from_mesh_verts_ex(&treedata[tindex], verts_src, num_verts_src, false,
|
||||
verts_active, num_verts_active, 0.0, 2, 6);
|
||||
bvhtree_from_mesh_verts_ex(
|
||||
&treedata[tindex], verts_src, num_verts_src, false,
|
||||
verts_active, num_verts_active, 0.0, 2, 6);
|
||||
}
|
||||
|
||||
MEM_freeN(verts_active);
|
||||
|
@ -1456,13 +1465,15 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
BLI_assert(index_src != -1);
|
||||
const float dot = dot_v3v3(nors_src[index_src], *nor_dst);
|
||||
|
||||
pidx_src = (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
|
||||
loop_to_poly_map_src[index_src] : index_src;
|
||||
pidx_src = (
|
||||
(mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
|
||||
loop_to_poly_map_src[index_src] : index_src);
|
||||
/* WARNING! This is not the *real* lidx_src in case of POLYNOR, we only use it
|
||||
* to check we stay on current island (all loops from a given poly are
|
||||
* on same island!). */
|
||||
lidx_src = (mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
|
||||
index_src : polys_src[pidx_src].loopstart;
|
||||
lidx_src = (
|
||||
(mode == MREMAP_MODE_LOOP_NEAREST_LOOPNOR) ?
|
||||
index_src : polys_src[pidx_src].loopstart);
|
||||
|
||||
/* A same vert may be at the boundary of several islands! Hence, we have to ensure
|
||||
* poly/loop we are currently considering *belongs* to current island! */
|
||||
|
@ -1481,7 +1492,7 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
|
||||
if (!pcent_dst_valid) {
|
||||
BKE_mesh_calc_poly_center(
|
||||
mp_dst, &loops_dst[mp_dst->loopstart], verts_dst, pcent_dst);
|
||||
mp_dst, &loops_dst[mp_dst->loopstart], verts_dst, pcent_dst);
|
||||
pcent_dst_valid = true;
|
||||
}
|
||||
pcent_src = poly_cents_src[pidx_src];
|
||||
|
@ -1712,8 +1723,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
BLI_space_transform_apply(space_transform, tmp_co);
|
||||
}
|
||||
|
||||
pidx_src = use_islands ? best_island->indices[last_valid_pidx_isld_src] :
|
||||
last_valid_pidx_isld_src;
|
||||
pidx_src = (
|
||||
use_islands ? best_island->indices[last_valid_pidx_isld_src] :
|
||||
last_valid_pidx_isld_src);
|
||||
mp_src = &polys_src[pidx_src];
|
||||
ml_src = &loops_src[mp_src->loopstart];
|
||||
for (j = 0; j < mp_src->totloop; j++, ml_src++) {
|
||||
|
@ -1797,8 +1809,9 @@ void BKE_mesh_remap_calc_loops_from_mesh(
|
|||
BLI_space_transform_apply(space_transform, tmp_co);
|
||||
}
|
||||
|
||||
pidx_src = use_islands ? best_island->indices[last_valid_pidx_isld_src] :
|
||||
last_valid_pidx_isld_src;
|
||||
pidx_src = (
|
||||
use_islands ? best_island->indices[last_valid_pidx_isld_src] :
|
||||
last_valid_pidx_isld_src);
|
||||
mp_src = &polys_src[pidx_src];
|
||||
|
||||
/* Create that one on demand. */
|
||||
|
@ -1947,8 +1960,9 @@ void BKE_mesh_remap_calc_polys_from_mesh(
|
|||
CustomData_set_layer_flag(pdata_dst, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
}
|
||||
if (dirty_nors_dst) {
|
||||
BKE_mesh_calc_normals_poly(verts_dst, NULL, numverts_dst, loops_dst, polys_dst, numloops_dst, numpolys_dst,
|
||||
poly_nors_dst, true);
|
||||
BKE_mesh_calc_normals_poly(
|
||||
verts_dst, NULL, numverts_dst, loops_dst, polys_dst, numloops_dst, numpolys_dst,
|
||||
poly_nors_dst, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2131,8 +2145,9 @@ void BKE_mesh_remap_calc_polys_from_mesh(
|
|||
tri_vidx_2d[1][2] = 3;
|
||||
}
|
||||
else {
|
||||
BLI_polyfill_calc(poly_vcos_2d, (unsigned int)mp->totloop, -1,
|
||||
(unsigned int (*)[3])tri_vidx_2d);
|
||||
BLI_polyfill_calc(
|
||||
poly_vcos_2d, (unsigned int)mp->totloop, -1,
|
||||
(unsigned int (*)[3])tri_vidx_2d);
|
||||
}
|
||||
|
||||
for (j = 0; j < tris_num; j++) {
|
||||
|
|
|
@ -246,9 +246,10 @@ static void mesh_runtime_debug_info_layers(
|
|||
const char *structname;
|
||||
int structnum;
|
||||
CustomData_file_write_info(type, &structname, &structnum);
|
||||
BLI_dynstr_appendf(dynstr,
|
||||
" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
|
||||
name, structname, type, (const void *)pt, size, pt_size);
|
||||
BLI_dynstr_appendf(
|
||||
dynstr,
|
||||
" dict(name='%s', struct='%s', type=%d, ptr='%p', elem=%d, length=%d),\n",
|
||||
name, structname, type, (const void *)pt, size, pt_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -346,21 +347,21 @@ bool BKE_mesh_runtime_is_valid(Mesh *me_eval)
|
|||
}
|
||||
|
||||
is_valid &= BKE_mesh_validate_all_customdata(
|
||||
&me_eval->vdata, &me_eval->edata, &me_eval->ldata, &me_eval->pdata,
|
||||
false, /* setting mask here isn't useful, gives false positives */
|
||||
do_verbose, do_fixes,
|
||||
&changed);
|
||||
&me_eval->vdata, &me_eval->edata, &me_eval->ldata, &me_eval->pdata,
|
||||
false, /* setting mask here isn't useful, gives false positives */
|
||||
do_verbose, do_fixes,
|
||||
&changed);
|
||||
|
||||
is_valid &= BKE_mesh_validate_arrays(
|
||||
me_eval,
|
||||
me_eval->mvert, me_eval->totvert,
|
||||
me_eval->medge, me_eval->totedge,
|
||||
me_eval->mface, me_eval->totface,
|
||||
me_eval->mloop, me_eval->totloop,
|
||||
me_eval->mpoly, me_eval->totpoly,
|
||||
me_eval->dvert,
|
||||
do_verbose, do_fixes,
|
||||
&changed);
|
||||
me_eval,
|
||||
me_eval->mvert, me_eval->totvert,
|
||||
me_eval->medge, me_eval->totedge,
|
||||
me_eval->mface, me_eval->totface,
|
||||
me_eval->mloop, me_eval->totloop,
|
||||
me_eval->mpoly, me_eval->totpoly,
|
||||
me_eval->dvert,
|
||||
do_verbose, do_fixes,
|
||||
&changed);
|
||||
|
||||
BLI_assert(changed == false);
|
||||
|
||||
|
|
|
@ -91,8 +91,9 @@ static void get_position(const SMikkTSpaceContext *pContext, float r_co[3], cons
|
|||
copy_v3_v3(r_co, p_mesh->mverts[p_mesh->mloops[loop_idx].v].co);
|
||||
}
|
||||
|
||||
static void get_texture_coordinate(const SMikkTSpaceContext *pContext, float r_uv[2], const int face_idx,
|
||||
const int vert_idx)
|
||||
static void get_texture_coordinate(
|
||||
const SMikkTSpaceContext *pContext, float r_uv[2], const int face_idx,
|
||||
const int vert_idx)
|
||||
{
|
||||
BKEMeshToTangent *p_mesh = (BKEMeshToTangent *)pContext->m_pUserData;
|
||||
copy_v2_v2(r_uv, p_mesh->luvs[p_mesh->mpolys[face_idx].loopstart + vert_idx].uv);
|
||||
|
@ -104,8 +105,9 @@ static void get_normal(const SMikkTSpaceContext *pContext, float r_no[3], const
|
|||
copy_v3_v3(r_no, p_mesh->lnors[p_mesh->mpolys[face_idx].loopstart + vert_idx]);
|
||||
}
|
||||
|
||||
static void set_tspace(const SMikkTSpaceContext *pContext, const float fv_tangent[3], const float face_sign,
|
||||
const int face_idx, const int vert_idx)
|
||||
static void set_tspace(
|
||||
const SMikkTSpaceContext *pContext, const float fv_tangent[3], const float face_sign,
|
||||
const int face_idx, const int vert_idx)
|
||||
{
|
||||
BKEMeshToTangent *p_mesh = (BKEMeshToTangent *)pContext->m_pUserData;
|
||||
float *p_res = p_mesh->tangents[p_mesh->mpolys[face_idx].loopstart + vert_idx];
|
||||
|
@ -192,8 +194,9 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh, const char *uvmap, float (*r_
|
|||
return;
|
||||
}
|
||||
|
||||
BKE_mesh_calc_loop_tangent_single_ex(mesh->mvert, mesh->totvert, mesh->mloop, r_looptangents,
|
||||
loopnors, loopuvs, mesh->totloop, mesh->mpoly, mesh->totpoly, reports);
|
||||
BKE_mesh_calc_loop_tangent_single_ex(
|
||||
mesh->mvert, mesh->totvert, mesh->mloop, r_looptangents,
|
||||
loopnors, loopuvs, mesh->totloop, mesh->mpoly, mesh->totpoly, reports);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -212,15 +212,16 @@ static int search_polyloop_cmp(const void *v1, const void *v2)
|
|||
*
|
||||
* \return false if no changes needed to be made.
|
||||
*/
|
||||
bool BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
MVert *mverts, unsigned int totvert,
|
||||
MEdge *medges, unsigned int totedge,
|
||||
MFace *mfaces, unsigned int totface,
|
||||
MLoop *mloops, unsigned int totloop,
|
||||
MPoly *mpolys, unsigned int totpoly,
|
||||
MDeformVert *dverts, /* assume totvert length */
|
||||
const bool do_verbose, const bool do_fixes,
|
||||
bool *r_changed)
|
||||
bool BKE_mesh_validate_arrays(
|
||||
Mesh *mesh,
|
||||
MVert *mverts, unsigned int totvert,
|
||||
MEdge *medges, unsigned int totedge,
|
||||
MFace *mfaces, unsigned int totface,
|
||||
MLoop *mloops, unsigned int totloop,
|
||||
MPoly *mpolys, unsigned int totpoly,
|
||||
MDeformVert *dverts, /* assume totvert length */
|
||||
const bool do_verbose, const bool do_fixes,
|
||||
bool *r_changed)
|
||||
{
|
||||
# define REMOVE_EDGE_TAG(_me) { _me->v2 = _me->v1; free_flag.edges = do_fixes; } (void)0
|
||||
# define IS_REMOVED_EDGE(_me) (_me->v2 == _me->v1)
|
||||
|
@ -875,9 +876,10 @@ bool BKE_mesh_validate_arrays(Mesh *mesh,
|
|||
return is_valid;
|
||||
}
|
||||
|
||||
static bool mesh_validate_customdata(CustomData *data, CustomDataMask mask,
|
||||
const bool do_verbose, const bool do_fixes,
|
||||
bool *r_change)
|
||||
static bool mesh_validate_customdata(
|
||||
CustomData *data, CustomDataMask mask,
|
||||
const bool do_verbose, const bool do_fixes,
|
||||
bool *r_change)
|
||||
{
|
||||
bool is_valid = true;
|
||||
bool has_fixes = false;
|
||||
|
@ -928,11 +930,12 @@ static bool mesh_validate_customdata(CustomData *data, CustomDataMask mask,
|
|||
/**
|
||||
* \returns is_valid.
|
||||
*/
|
||||
bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata,
|
||||
CustomData *ldata, CustomData *pdata,
|
||||
const bool check_meshmask,
|
||||
const bool do_verbose, const bool do_fixes,
|
||||
bool *r_change)
|
||||
bool BKE_mesh_validate_all_customdata(
|
||||
CustomData *vdata, CustomData *edata,
|
||||
CustomData *ldata, CustomData *pdata,
|
||||
const bool check_meshmask,
|
||||
const bool do_verbose, const bool do_fixes,
|
||||
bool *r_change)
|
||||
{
|
||||
bool is_valid = true;
|
||||
bool is_change_v, is_change_e, is_change_l, is_change_p;
|
||||
|
@ -1229,9 +1232,10 @@ struct EdgeSort {
|
|||
};
|
||||
|
||||
/* edges have to be added with lowest index first for sorting */
|
||||
static void to_edgesort(struct EdgeSort *ed,
|
||||
unsigned int v1, unsigned int v2,
|
||||
char is_loose, short is_draw)
|
||||
static void to_edgesort(
|
||||
struct EdgeSort *ed,
|
||||
unsigned int v1, unsigned int v2,
|
||||
char is_loose, short is_draw)
|
||||
{
|
||||
if (v1 < v2) {
|
||||
ed->v1 = v1; ed->v2 = v2;
|
||||
|
@ -1380,9 +1384,10 @@ void BKE_mesh_calc_edges_legacy(Mesh *me, const bool use_old)
|
|||
MEdge *medge;
|
||||
int totedge = 0;
|
||||
|
||||
mesh_calc_edges_mdata(me->mvert, me->mface, me->mloop, me->mpoly,
|
||||
me->totvert, me->totface, me->totloop, me->totpoly,
|
||||
use_old, &medge, &totedge);
|
||||
mesh_calc_edges_mdata(
|
||||
me->mvert, me->mface, me->mloop, me->mpoly,
|
||||
me->totvert, me->totface, me->totloop, me->totpoly,
|
||||
use_old, &medge, &totedge);
|
||||
|
||||
if (totedge == 0) {
|
||||
/* flag that mesh has edges */
|
||||
|
|
Loading…
Reference in New Issue