Cosmetic updates to mesh validate messages.
This commit is contained in:
@@ -223,7 +223,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
__func__, totvert, totedge, totloop, totpoly);
|
||||
|
||||
if (totedge == 0 && totpoly != 0) {
|
||||
PRINT(" logical error, %u polygons and 0 edges\n", totpoly);
|
||||
PRINT("\tLogical error, %u polygons and 0 edges\n", totpoly);
|
||||
do_edge_recalc = do_fixes;
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
|
||||
for (j = 0; j < 3; j++) {
|
||||
if (!finite(mv->co[j])) {
|
||||
PRINT(" vertex %u: has invalid coordinate\n", i);
|
||||
PRINT("\tVertex %u: has invalid coordinate\n", i);
|
||||
|
||||
if (do_fixes) {
|
||||
zero_v3(mv->co);
|
||||
@@ -247,7 +247,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
}
|
||||
|
||||
if (fix_normal) {
|
||||
PRINT(" vertex %u: has zero normal, assuming Z-up normal\n", i);
|
||||
PRINT("\tVertex %u: has zero normal, assuming Z-up normal\n", i);
|
||||
if (do_fixes) {
|
||||
mv->no[2] = SHRT_MAX;
|
||||
verts_fixed = TRUE;
|
||||
@@ -258,20 +258,20 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
for (i = 0, me = medges; i < totedge; i++, me++) {
|
||||
int remove = FALSE;
|
||||
if (me->v1 == me->v2) {
|
||||
PRINT(" edge %u: has matching verts, both %u\n", i, me->v1);
|
||||
PRINT("\tEdge %u: has matching verts, both %u\n", i, me->v1);
|
||||
remove = do_fixes;
|
||||
}
|
||||
if (me->v1 >= totvert) {
|
||||
PRINT(" edge %u: v1 index out of range, %u\n", i, me->v1);
|
||||
PRINT("\tEdge %u: v1 index out of range, %u\n", i, me->v1);
|
||||
remove = do_fixes;
|
||||
}
|
||||
if (me->v2 >= totvert) {
|
||||
PRINT(" edge %u: v2 index out of range, %u\n", i, me->v2);
|
||||
PRINT("\tEdge %u: v2 index out of range, %u\n", i, me->v2);
|
||||
remove = do_fixes;
|
||||
}
|
||||
|
||||
if (BLI_edgehash_haskey(edge_hash, me->v1, me->v2)) {
|
||||
PRINT(" edge %u: is a duplicate of %d\n", i,
|
||||
PRINT("\tEdge %u: is a duplicate of %d\n", i,
|
||||
GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, me->v1, me->v2)));
|
||||
remove = do_fixes;
|
||||
}
|
||||
@@ -296,7 +296,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
PRINT(" face %u: edge " STRINGIFY(a) "/" STRINGIFY(b) \
|
||||
" (%u,%u) is missing egde data\n", i, mf->a, mf->b); \
|
||||
do_edge_recalc = TRUE; \
|
||||
}
|
||||
} (void)0
|
||||
|
||||
MFace *mf;
|
||||
MFace *mf_prev;
|
||||
@@ -306,6 +306,8 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
SortFace *sf_prev;
|
||||
unsigned int totsortface = 0;
|
||||
|
||||
PRINT("No Polys, only tesselated Faces\n");
|
||||
|
||||
for (i = 0, mf = mfaces, sf = sort_faces; i < totface; i++, mf++) {
|
||||
int remove = FALSE;
|
||||
int fidx;
|
||||
@@ -315,7 +317,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
do {
|
||||
fv[fidx] = *(&(mf->v1) + fidx);
|
||||
if (fv[fidx] >= totvert) {
|
||||
PRINT(" face %u: 'v%d' index out of range, %u\n", i, fidx + 1, fv[fidx]);
|
||||
PRINT("\tFace %u: 'v%d' index out of range, %u\n", i, fidx + 1, fv[fidx]);
|
||||
remove = do_fixes;
|
||||
}
|
||||
} while (fidx--);
|
||||
@@ -392,12 +394,12 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
mf_prev = mfaces + sf_prev->index;
|
||||
|
||||
if (mf->v4) {
|
||||
PRINT(" face %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)\n",
|
||||
PRINT("\tFace %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)\n",
|
||||
sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4,
|
||||
mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4);
|
||||
}
|
||||
else {
|
||||
PRINT(" face %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)\n",
|
||||
PRINT("\tFace %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)\n",
|
||||
sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3,
|
||||
mf_prev->v1, mf_prev->v2, mf_prev->v3);
|
||||
}
|
||||
@@ -433,7 +435,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
*
|
||||
* Also, loops not used by polys can be discarded.
|
||||
* And "intersecting" loops (i.e. loops used by more than one poly) are invalid,
|
||||
* so be sure to leave at most one poly/loop!
|
||||
* so be sure to leave at most one poly per loop!
|
||||
*/
|
||||
{
|
||||
SortPoly *sort_polys = MEM_callocN(sizeof(SortPoly) * totpoly, "mesh validate's sort_polys");
|
||||
@@ -444,12 +446,12 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
|
||||
if (mp->loopstart < 0 || mp->totloop < 3) {
|
||||
/* Invalid loop data. */
|
||||
PRINT(" poly %u is invalid (loopstart: %u, totloop: %u)\n", sp->index, mp->loopstart, mp->totloop);
|
||||
PRINT("\tPoly %u is invalid (loopstart: %u, totloop: %u)\n", sp->index, mp->loopstart, mp->totloop);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
else if (mp->loopstart + mp->totloop > totloop) {
|
||||
/* Invalid loop data. */
|
||||
PRINT(" poly %u uses loops out of range (loopstart: %u, loopend: %u, max nbr of loops: %u)\n",
|
||||
PRINT("\tPoly %u uses loops out of range (loopstart: %u, loopend: %u, max nbr of loops: %u)\n",
|
||||
sp->index, mp->loopstart, mp->loopstart + mp->totloop - 1, totloop - 1);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
@@ -465,7 +467,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
for (j = 0, ml = &mloops[sp->loopstart]; j < mp->totloop; j++, ml++, v++) {
|
||||
if (ml->v >= totvert) {
|
||||
/* Invalid vert idx. */
|
||||
PRINT(" loop %u has invalid vert reference (%u)\n", sp->loopstart + j, ml->v);
|
||||
PRINT("\tLoop %u has invalid vert reference (%u)\n", sp->loopstart + j, ml->v);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
|
||||
@@ -478,7 +480,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
v = sp->verts;
|
||||
for (j = 0; j < mp->totloop; j++, v++) {
|
||||
if ((mverts[*v].flag & ME_VERT_TMP_TAG) == 0) {
|
||||
PRINT(" poly %u has duplicate vert reference at corner (%u)\n", i, j);
|
||||
PRINT("\tPoly %u has duplicate vert reference at corner (%u)\n", i, j);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
mverts[*v].flag &= ~ME_VERT_TMP_TAG;
|
||||
@@ -494,7 +496,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
v2 = mloops[sp->loopstart + (j + 1) % mp->totloop].v;
|
||||
if (!BLI_edgehash_haskey(edge_hash, v1, v2)) {
|
||||
/* Edge not existing. */
|
||||
PRINT(" poly %u needs missing edge (%u, %u)\n", sp->index, v1, v2);
|
||||
PRINT("\tPoly %u needs missing edge (%u, %u)\n", sp->index, v1, v2);
|
||||
if (do_fixes)
|
||||
do_edge_recalc = TRUE;
|
||||
else
|
||||
@@ -506,11 +508,11 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
if (do_fixes) {
|
||||
int prev_e = ml->e;
|
||||
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, v1, v2));
|
||||
PRINT(" loop %u has invalid edge reference (%u), fixed using edge %u\n",
|
||||
PRINT("\tLoop %u has invalid edge reference (%u), fixed using edge %u\n",
|
||||
sp->loopstart + j, prev_e, ml->e);
|
||||
}
|
||||
else {
|
||||
PRINT(" loop %u has invalid edge reference (%u)\n", sp->loopstart + j, ml->e);
|
||||
PRINT("\tLoop %u has invalid edge reference (%u)\n", sp->loopstart + j, ml->e);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -522,11 +524,11 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
if (do_fixes) {
|
||||
int prev_e = ml->e;
|
||||
ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, v1, v2));
|
||||
PRINT(" poly %u has invalid edge reference (%u), fixed using edge %u\n",
|
||||
PRINT("\tPoly %u has invalid edge reference (%u), fixed using edge %u\n",
|
||||
sp->index, prev_e, ml->e);
|
||||
}
|
||||
else {
|
||||
PRINT(" poly %u has invalid edge reference (%u)\n", sp->index, ml->e);
|
||||
PRINT("\tPoly %u has invalid edge reference (%u)\n", sp->index, ml->e);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
}
|
||||
@@ -544,7 +546,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
if (*v != *prev_v) {
|
||||
int dlt = v - prev_v;
|
||||
if (dlt > 1) {
|
||||
PRINT(" poly %u is invalid, it multi-uses vertex %u (%u times)\n",
|
||||
PRINT("\tPoly %u is invalid, it multi-uses vertex %u (%u times)\n",
|
||||
sp->index, *prev_v, dlt);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
@@ -552,7 +554,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
}
|
||||
}
|
||||
if (v - prev_v > 1) { /* Don't forget final verts! */
|
||||
PRINT(" poly %u is invalid, it multi-uses vertex %u (%u times)\n",
|
||||
PRINT("\tPoly %u is invalid, it multi-uses vertex %u (%u times)\n",
|
||||
sp->index, *prev_v, (int)(v - prev_v));
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
@@ -610,17 +612,17 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
p2_sub = FALSE;
|
||||
|
||||
if (p1_sub && p2_sub) {
|
||||
PRINT(" polys %u and %u use same vertices, considering poly %u as invalid.\n",
|
||||
PRINT("\tPolys %u and %u use same vertices, considering poly %u as invalid.\n",
|
||||
prev_sp->index, sp->index, sp->index);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
/* XXX In fact, these might be valid? :/ */
|
||||
else if (p1_sub) {
|
||||
PRINT(" %u is a sub-poly of %u, considering it as invalid.\n", sp->index, prev_sp->index);
|
||||
PRINT("\t%u is a sub-poly of %u, considering it as invalid.\n", sp->index, prev_sp->index);
|
||||
sp->invalid = TRUE;
|
||||
}
|
||||
else if (p2_sub) {
|
||||
PRINT(" %u is a sub-poly of %u, considering it as invalid.\n", prev_sp->index, sp->index);
|
||||
PRINT("\t%u is a sub-poly of %u, considering it as invalid.\n", prev_sp->index, sp->index);
|
||||
prev_sp->invalid = TRUE;
|
||||
prev_sp = sp; /* sp is new reference poly. */
|
||||
}
|
||||
@@ -631,7 +633,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
}
|
||||
if ((p1_nv == p2_nv) && (memcmp(p1_v, p2_v, p1_nv * sizeof(*p1_v)) == 0)) {
|
||||
if (do_verbose) {
|
||||
PRINT(" polys %u and %u use same vertices (%u",
|
||||
PRINT("\tPolys %u and %u use same vertices (%u",
|
||||
prev_sp->index, sp->index, *p1_v);
|
||||
for (j = 1; j < p1_nv; j++)
|
||||
PRINT(", %u", p1_v[j]);
|
||||
@@ -671,7 +673,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
/* Unused loops. */
|
||||
if (prev_end < sp->loopstart) {
|
||||
for (j = prev_end, ml = &mloops[prev_end]; j < sp->loopstart; j++, ml++) {
|
||||
PRINT(" loop %u is unused.\n", j);
|
||||
PRINT("\tLoop %u is unused.\n", j);
|
||||
if (do_fixes)
|
||||
REMOVE_LOOP_TAG(ml);
|
||||
}
|
||||
@@ -680,7 +682,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
}
|
||||
/* Multi-used loops. */
|
||||
else if (prev_end > sp->loopstart) {
|
||||
PRINT(" polys %u and %u share loops from %u to %u, considering poly %u as invalid.\n",
|
||||
PRINT("\tPolys %u and %u share loops from %u to %u, considering poly %u as invalid.\n",
|
||||
prev_sp->index, sp->index, sp->loopstart, prev_end, sp->index);
|
||||
if (do_fixes) {
|
||||
REMOVE_POLY_TAG((&mpolys[sp->index]));
|
||||
@@ -699,7 +701,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
/* We may have some remaining unused loops to get rid of! */
|
||||
if (prev_end < totloop) {
|
||||
for (j = prev_end, ml = &mloops[prev_end]; j < totloop; j++, ml++) {
|
||||
PRINT(" loop %u is unused.\n", j);
|
||||
PRINT("\tLoop %u is unused.\n", j);
|
||||
if (do_fixes)
|
||||
REMOVE_LOOP_TAG(ml);
|
||||
}
|
||||
@@ -720,14 +722,14 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) {
|
||||
/* note, greater then max defgroups is accounted for in our code, but not < 0 */
|
||||
if (!finite(dw->weight)) {
|
||||
PRINT(" vertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
|
||||
PRINT("\tVertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
|
||||
if (do_fixes) {
|
||||
dw->weight = 0.0f;
|
||||
vert_weights_fixed = TRUE;
|
||||
}
|
||||
}
|
||||
else if (dw->weight < 0.0f || dw->weight > 1.0f) {
|
||||
PRINT(" vertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
|
||||
PRINT("\tVertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
|
||||
if (do_fixes) {
|
||||
CLAMP(dw->weight, 0.0f, 1.0f);
|
||||
vert_weights_fixed = TRUE;
|
||||
@@ -735,7 +737,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
}
|
||||
|
||||
if (dw->def_nr < 0) {
|
||||
PRINT(" vertex deform %u, has invalid group %d\n", i, dw->def_nr);
|
||||
PRINT("\tVertex deform %u, has invalid group %d\n", i, dw->def_nr);
|
||||
if (do_fixes) {
|
||||
defvert_remove_group(dv, dw);
|
||||
if (dv->dw) {
|
||||
@@ -783,10 +785,10 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
int free_msel = FALSE;
|
||||
|
||||
for (i = 0, msel = mesh->mselect; i < mesh->totselect; i++, msel++) {
|
||||
int tot_elem;
|
||||
int tot_elem = 0;
|
||||
|
||||
if (msel->index < 0) {
|
||||
PRINT("Mesh select element %d type %d index is negative, "
|
||||
PRINT("\tMesh select element %d type %d index is negative, "
|
||||
"resetting selection stack.\n", i, msel->type);
|
||||
free_msel = TRUE;
|
||||
break;
|
||||
@@ -805,7 +807,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
}
|
||||
|
||||
if (msel->index > tot_elem) {
|
||||
PRINT("Mesh select element %d type %d index %d is larger than data array size %d, "
|
||||
PRINT("\tMesh select element %d type %d index %d is larger than data array size %d, "
|
||||
"resetting selection stack.\n", i, msel->type, msel->index, tot_elem);
|
||||
|
||||
free_msel = TRUE;
|
||||
@@ -820,7 +822,7 @@ int BKE_mesh_validate_arrays(Mesh *mesh,
|
||||
}
|
||||
}
|
||||
|
||||
PRINT("BKE_mesh_validate: finished\n\n");
|
||||
PRINT("%s: finished\n\n", __func__);
|
||||
|
||||
return (verts_fixed || vert_weights_fixed || do_polyloop_free || do_edge_free || do_edge_recalc || msel_fixed);
|
||||
}
|
||||
@@ -829,13 +831,15 @@ static int mesh_validate_customdata(CustomData *data, short do_verbose, const sh
|
||||
{
|
||||
int i = 0, has_fixes = 0;
|
||||
|
||||
PRINT("%s: Checking %d CD layers...\n", __func__, data->totlayer);
|
||||
|
||||
while (i < data->totlayer) {
|
||||
CustomDataLayer *layer = &data->layers[i];
|
||||
CustomDataMask mask = CD_TYPE_AS_MASK(layer->type);
|
||||
int ok = 1;
|
||||
|
||||
if ((mask & CD_MASK_MESH) == 0) {
|
||||
PRINT("CustomDataLayer type %d which isn't in CD_MASK_MESH is stored in Mehs structure\n", layer->type);
|
||||
PRINT("\tCustomDataLayer type %d which isn't in CD_MASK_MESH is stored in Mesh structure\n", layer->type);
|
||||
|
||||
if (do_fixes) {
|
||||
CustomData_free_layer(data, layer->type, 0, i);
|
||||
@@ -848,6 +852,8 @@ static int mesh_validate_customdata(CustomData *data, short do_verbose, const sh
|
||||
i++;
|
||||
}
|
||||
|
||||
PRINT("%s: Finished\n\n", __func__);
|
||||
|
||||
return has_fixes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user