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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-02-01 04:44:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-02-01 04:46:39 +0300
commit552b2287db86ed6e77565672fbccff1d553f823f (patch)
tree235ad970599910d52c822bb89d23fb467f44f1bd /source/blender/blenkernel/intern/mesh_validate.c
parent8a51af7d1c98500022b1ff789284f9e0a3c038cd (diff)
Logging: Use CLOG for blenkernel
Part of D4277 by @sobakasu
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_validate.c')
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c
index deb3cf35027..b52fe18fb1b 100644
--- a/source/blender/blenkernel/intern/mesh_validate.c
+++ b/source/blender/blenkernel/intern/mesh_validate.c
@@ -31,6 +31,8 @@
#include <string.h>
#include <limits.h>
+#include "CLG_log.h"
+
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
@@ -52,6 +54,7 @@
/* loop v/e are unsigned, so using max uint_32 value as invalid marker... */
#define INVALID_LOOP_EDGE_MARKER 4294967295u
+static CLG_LogRef LOG = {"bke.mesh"};
/** \name Internal functions
* \{ */
@@ -198,13 +201,12 @@ static int search_polyloop_cmp(const void *v1, const void *v2)
/** \name Mesh Validation
* \{ */
-#define PRINT_MSG(...) (void) \
- ( \
- ((do_verbose) ? printf(__VA_ARGS__) : 0))
+#define PRINT_MSG(...) if(do_verbose) CLOG_INFO(&LOG, 1, __VA_ARGS__)
-#define PRINT_ERR(...) (void) \
- (is_valid = false, \
- ((do_verbose) ? printf(__VA_ARGS__) : 0))
+#define PRINT_ERR(...) do { \
+ is_valid = false; \
+ if (do_verbose) { CLOG_ERROR(&LOG, __VA_ARGS__); } \
+ } while(0)
/**
* Validate the mesh, \a do_fixes requires \a mesh to be non-null.
@@ -272,11 +274,11 @@ bool BKE_mesh_validate_arrays(
free_flag.as_flag = 0;
recalc_flag.as_flag = 0;
- PRINT_MSG("%s: verts(%u), edges(%u), loops(%u), polygons(%u)\n",
- __func__, totvert, totedge, totloop, totpoly);
+ PRINT_MSG("verts(%u), edges(%u), loops(%u), polygons(%u)",
+ totvert, totedge, totloop, totpoly);
if (totedge == 0 && totpoly != 0) {
- PRINT_ERR("\tLogical error, %u polygons and 0 edges\n", totpoly);
+ PRINT_ERR("\tLogical error, %u polygons and 0 edges", totpoly);
recalc_flag.edges = do_fixes;
}
@@ -285,7 +287,7 @@ bool BKE_mesh_validate_arrays(
for (j = 0; j < 3; j++) {
if (!isfinite(mv->co[j])) {
- PRINT_ERR("\tVertex %u: has invalid coordinate\n", i);
+ PRINT_ERR("\tVertex %u: has invalid coordinate", i);
if (do_fixes) {
zero_v3(mv->co);
@@ -299,7 +301,7 @@ bool BKE_mesh_validate_arrays(
}
if (fix_normal) {
- PRINT_ERR("\tVertex %u: has zero normal, assuming Z-up normal\n", i);
+ PRINT_ERR("\tVertex %u: has zero normal, assuming Z-up normal", i);
if (do_fixes) {
mv->no[2] = SHRT_MAX;
fix_flag.verts = true;
@@ -311,20 +313,20 @@ bool BKE_mesh_validate_arrays(
bool remove = false;
if (me->v1 == me->v2) {
- PRINT_ERR("\tEdge %u: has matching verts, both %u\n", i, me->v1);
+ PRINT_ERR("\tEdge %u: has matching verts, both %u", i, me->v1);
remove = do_fixes;
}
if (me->v1 >= totvert) {
- PRINT_ERR("\tEdge %u: v1 index out of range, %u\n", i, me->v1);
+ PRINT_ERR("\tEdge %u: v1 index out of range, %u", i, me->v1);
remove = do_fixes;
}
if (me->v2 >= totvert) {
- PRINT_ERR("\tEdge %u: v2 index out of range, %u\n", i, me->v2);
+ PRINT_ERR("\tEdge %u: v2 index out of range, %u", i, me->v2);
remove = do_fixes;
}
if ((me->v1 != me->v2) && BLI_edgehash_haskey(edge_hash, me->v1, me->v2)) {
- PRINT_ERR("\tEdge %u: is a duplicate of %d\n", i,
+ PRINT_ERR("\tEdge %u: is a duplicate of %d", i,
POINTER_AS_INT(BLI_edgehash_lookup(edge_hash, me->v1, me->v2)));
remove = do_fixes;
}
@@ -343,13 +345,13 @@ bool BKE_mesh_validate_arrays(
# define REMOVE_FACE_TAG(_mf) { _mf->v3 = 0; free_flag.faces = do_fixes; } (void)0
# define CHECK_FACE_VERT_INDEX(a, b) \
if (mf->a == mf->b) { \
- PRINT_ERR(" face %u: verts invalid, " STRINGIFY(a) "/" STRINGIFY(b) " both %u\n", i, mf->a); \
+ PRINT_ERR(" face %u: verts invalid, " STRINGIFY(a) "/" STRINGIFY(b) " both %u", i, mf->a); \
remove = do_fixes; \
} (void)0
# define CHECK_FACE_EDGE(a, b) \
if (!BLI_edgehash_haskey(edge_hash, mf->a, mf->b)) { \
PRINT_ERR(" face %u: edge " STRINGIFY(a) "/" STRINGIFY(b) \
- " (%u,%u) is missing edge data\n", i, mf->a, mf->b); \
+ " (%u,%u) is missing edge data", i, mf->a, mf->b); \
recalc_flag.edges = do_fixes; \
} (void)0
@@ -361,7 +363,7 @@ bool BKE_mesh_validate_arrays(
SortFace *sf_prev;
unsigned int totsortface = 0;
- PRINT_ERR("No Polys, only tessellated Faces\n");
+ PRINT_ERR("No Polys, only tessellated Faces");
for (i = 0, mf = mfaces, sf = sort_faces; i < totface; i++, mf++) {
bool remove = false;
@@ -372,7 +374,7 @@ bool BKE_mesh_validate_arrays(
do {
fv[fidx] = *(&(mf->v1) + fidx);
if (fv[fidx] >= totvert) {
- PRINT_ERR("\tFace %u: 'v%d' index out of range, %u\n", i, fidx + 1, fv[fidx]);
+ PRINT_ERR("\tFace %u: 'v%d' index out of range, %u", i, fidx + 1, fv[fidx]);
remove = do_fixes;
}
} while (fidx--);
@@ -449,12 +451,12 @@ bool BKE_mesh_validate_arrays(
mf_prev = mfaces + sf_prev->index;
if (mf->v4) {
- PRINT_ERR("\tFace %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)\n",
+ PRINT_ERR("\tFace %u & %u: are duplicates (%u,%u,%u,%u) (%u,%u,%u,%u)",
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_ERR("\tFace %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)\n",
+ PRINT_ERR("\tFace %u & %u: are duplicates (%u,%u,%u) (%u,%u,%u)",
sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3,
mf_prev->v1, mf_prev->v2, mf_prev->v3);
}
@@ -502,13 +504,13 @@ bool BKE_mesh_validate_arrays(
if (mp->loopstart < 0 || mp->totloop < 3) {
/* Invalid loop data. */
- PRINT_ERR("\tPoly %u is invalid (loopstart: %d, totloop: %d)\n",
+ PRINT_ERR("\tPoly %u is invalid (loopstart: %d, totloop: %d)",
sp->index, mp->loopstart, mp->totloop);
sp->invalid = true;
}
else if (mp->loopstart + mp->totloop > totloop) {
/* Invalid loop data. */
- PRINT_ERR("\tPoly %u uses loops out of range (loopstart: %d, loopend: %d, max nbr of loops: %u)\n",
+ PRINT_ERR("\tPoly %u uses loops out of range (loopstart: %d, loopend: %d, max nbr of loops: %u)",
sp->index, mp->loopstart, mp->loopstart + mp->totloop - 1, totloop - 1);
sp->invalid = true;
}
@@ -532,11 +534,11 @@ bool BKE_mesh_validate_arrays(
for (j = 0, ml = &mloops[sp->loopstart]; j < mp->totloop; j++, ml++, v++) {
if (ml->v >= totvert) {
/* Invalid vert idx. */
- PRINT_ERR("\tLoop %u has invalid vert reference (%u)\n", sp->loopstart + j, ml->v);
+ PRINT_ERR("\tLoop %u has invalid vert reference (%u)", sp->loopstart + j, ml->v);
sp->invalid = true;
}
else if (mverts[ml->v].flag & ME_VERT_TMP_TAG) {
- PRINT_ERR("\tPoly %u has duplicated vert reference at corner (%u)\n", i, j);
+ PRINT_ERR("\tPoly %u has duplicated vert reference at corner (%u)", i, j);
sp->invalid = true;
}
else {
@@ -554,7 +556,7 @@ bool BKE_mesh_validate_arrays(
v2 = mloops[sp->loopstart + (j + 1) % mp->totloop].v;
if (!BLI_edgehash_haskey(edge_hash, v1, v2)) {
/* Edge not existing. */
- PRINT_ERR("\tPoly %u needs missing edge (%d, %d)\n", sp->index, v1, v2);
+ PRINT_ERR("\tPoly %u needs missing edge (%d, %d)", sp->index, v1, v2);
if (do_fixes)
recalc_flag.edges = true;
else
@@ -567,11 +569,11 @@ bool BKE_mesh_validate_arrays(
int prev_e = ml->e;
ml->e = POINTER_AS_INT(BLI_edgehash_lookup(edge_hash, v1, v2));
fix_flag.loops_edge = true;
- PRINT_ERR("\tLoop %u has invalid edge reference (%d), fixed using edge %u\n",
+ PRINT_ERR("\tLoop %u has invalid edge reference (%d), fixed using edge %u",
sp->loopstart + j, prev_e, ml->e);
}
else {
- PRINT_ERR("\tLoop %u has invalid edge reference (%u)\n", sp->loopstart + j, ml->e);
+ PRINT_ERR("\tLoop %u has invalid edge reference (%u)", sp->loopstart + j, ml->e);
sp->invalid = true;
}
}
@@ -584,11 +586,11 @@ bool BKE_mesh_validate_arrays(
int prev_e = ml->e;
ml->e = POINTER_AS_INT(BLI_edgehash_lookup(edge_hash, v1, v2));
fix_flag.loops_edge = true;
- PRINT_ERR("\tPoly %u has invalid edge reference (%d, is_removed: %d), fixed using edge %u\n",
+ PRINT_ERR("\tPoly %u has invalid edge reference (%d, is_removed: %d), fixed using edge %u",
sp->index, prev_e, IS_REMOVED_EDGE(me), ml->e);
}
else {
- PRINT_ERR("\tPoly %u has invalid edge reference (%u)\n", sp->index, ml->e);
+ PRINT_ERR("\tPoly %u has invalid edge reference (%u)", sp->index, ml->e);
sp->invalid = true;
}
}
@@ -619,11 +621,12 @@ bool BKE_mesh_validate_arrays(
/* Test same polys. */
if ((p1_nv == p2_nv) && (memcmp(p1_v, p2_v, p1_nv * sizeof(*p1_v)) == 0)) {
if (do_verbose) {
+ // TODO: convert list to string
PRINT_ERR("\tPolys %u and %u use same vertices (%d",
prev_sp->index, sp->index, *p1_v);
for (j = 1; j < p1_nv; j++)
PRINT_ERR(", %d", p1_v[j]);
- PRINT_ERR("), considering poly %u as invalid.\n", sp->index);
+ PRINT_ERR("), considering poly %u as invalid.", sp->index);
}
else {
is_valid = false;
@@ -661,7 +664,7 @@ bool BKE_mesh_validate_arrays(
/* Unused loops. */
if (prev_end < sp->loopstart) {
for (j = prev_end, ml = &mloops[prev_end]; j < sp->loopstart; j++, ml++) {
- PRINT_ERR("\tLoop %u is unused.\n", j);
+ PRINT_ERR("\tLoop %u is unused.", j);
if (do_fixes)
REMOVE_LOOP_TAG(ml);
}
@@ -670,7 +673,7 @@ bool BKE_mesh_validate_arrays(
}
/* Multi-used loops. */
else if (prev_end > sp->loopstart) {
- PRINT_ERR("\tPolys %u and %u share loops from %d to %d, considering poly %u as invalid.\n",
+ PRINT_ERR("\tPolys %u and %u share loops from %d to %d, considering poly %u as invalid.",
prev_sp->index, sp->index, sp->loopstart, prev_end, sp->index);
if (do_fixes) {
REMOVE_POLY_TAG((&mpolys[sp->index]));
@@ -689,7 +692,7 @@ bool BKE_mesh_validate_arrays(
/* 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_ERR("\tLoop %u is unused.\n", j);
+ PRINT_ERR("\tLoop %u is unused.", j);
if (do_fixes)
REMOVE_LOOP_TAG(ml);
}
@@ -709,14 +712,14 @@ bool BKE_mesh_validate_arrays(
for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) {
/* note, greater than max defgroups is accounted for in our code, but not < 0 */
if (!isfinite(dw->weight)) {
- PRINT_ERR("\tVertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
+ PRINT_ERR("\tVertex deform %u, group %d has weight: %f", i, dw->def_nr, dw->weight);
if (do_fixes) {
dw->weight = 0.0f;
fix_flag.verts_weight = true;
}
}
else if (dw->weight < 0.0f || dw->weight > 1.0f) {
- PRINT_ERR("\tVertex deform %u, group %d has weight: %f\n", i, dw->def_nr, dw->weight);
+ PRINT_ERR("\tVertex deform %u, group %d has weight: %f", i, dw->def_nr, dw->weight);
if (do_fixes) {
CLAMP(dw->weight, 0.0f, 1.0f);
fix_flag.verts_weight = true;
@@ -724,7 +727,7 @@ bool BKE_mesh_validate_arrays(
}
if (dw->def_nr < 0) {
- PRINT_ERR("\tVertex deform %u, has invalid group %d\n", i, dw->def_nr);
+ PRINT_ERR("\tVertex deform %u, has invalid group %d", i, dw->def_nr);
if (do_fixes) {
defvert_remove_group(dv, dw);
fix_flag.verts_weight = true;
@@ -933,7 +936,7 @@ bool BKE_mesh_validate(Mesh *me, const bool do_verbose, const bool cddata_check_
bool changed;
if (do_verbose) {
- printf("MESH: %s\n", me->id.name + 2);
+ CLOG_INFO(&LOG, 0, "MESH: %s", me->id.name + 2);
}
is_valid &= BKE_mesh_validate_all_customdata(