diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-02-05 16:03:01 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-02-05 16:03:01 +0300 |
commit | 7bae9ee6b62dbc5defffb698ec3d3f39ce460254 (patch) | |
tree | 4361f69ef42814c6df54e49fe98925aca4f4cfaf /source | |
parent | e442b9916eefaea9f98c126e2390b5aafa4518cc (diff) |
Mesh validate: add an option to not clean temp/cache CDLayers.
This is mandatory for incoming custom normal imports from io scripts, because
often geometry here is corrupted, so we need to call mesh.validate() to clean it up.
Issue is, we cannot set custom normals before geometry is clean, so we need to store
temporary plain loop normals in a CD_NORMAL layer, validate, and then set custom normals.
So we need a way to prevent 'temp' lnors to be freed by validate.
Diffstat (limited to 'source')
6 files changed, 9 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index c9f61cac254..3138fd69cc4 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -287,7 +287,7 @@ void BKE_mesh_calc_relative_deform( /* *** mesh_validate.c *** */ -int BKE_mesh_validate(struct Mesh *me, const int do_verbose); +int BKE_mesh_validate(struct Mesh *me, const int do_verbose, const int cddata_check_mask); void BKE_mesh_cd_validate(struct Mesh *me); int BKE_mesh_validate_material_indices(struct Mesh *me); diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index ad316e55d85..51f17f738f0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -3485,7 +3485,7 @@ bool DM_is_valid(DerivedMesh *dm) dm->getEdgeDataLayout(dm), dm->getLoopDataLayout(dm), dm->getPolyDataLayout(dm), - 0, /* setting mask here isn't useful, gives false positives */ + false, /* setting mask here isn't useful, gives false positives */ do_verbose, do_fixes, &changed); is_valid &= BKE_mesh_validate_arrays( diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 3a6c949fe9c..4b2c2aba691 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -963,7 +963,7 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, * * \returns true if a change is made. */ -int BKE_mesh_validate(Mesh *me, const int do_verbose) +int BKE_mesh_validate(Mesh *me, const int do_verbose, const int cddata_check_mask) { bool is_valid = true; bool changed; @@ -974,7 +974,7 @@ int BKE_mesh_validate(Mesh *me, const int do_verbose) is_valid &= BKE_mesh_validate_all_customdata( &me->vdata, &me->edata, &me->ldata, &me->pdata, - true, + cddata_check_mask, do_verbose, true, &changed); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 3c6c90068de..02e78b9bc45 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -818,7 +818,7 @@ void MeshImporter::bmeshConversion() Mesh *me = (*m).second; BKE_mesh_tessface_clear(me); BKE_mesh_calc_normals(me); - //BKE_mesh_validate(me, 1); + /* BKE_mesh_validate(me, true, true); */ } } } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index da3d55ef563..70de246a8de 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -918,7 +918,7 @@ void BlenderStrokeRenderer::GenerateStrokeMesh(StrokeGroup *group, bool hasTex) BLI_assert(mesh->totedge == edge_index); BLI_assert(mesh->totloop == loop_index); BLI_assert(mesh->totcol == material_index); - BKE_mesh_validate(mesh, true); + BKE_mesh_validate(mesh, true, true); #endif } diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 015883d87ec..09f12f6a4af 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -207,7 +207,9 @@ void RNA_api_mesh(StructRNA *srna) func = RNA_def_function(srna, "validate", "BKE_mesh_validate"); RNA_def_function_ui_description(func, "Validate geometry, return True when the mesh has had " "invalid geometry corrected/removed"); - RNA_def_boolean(func, "verbose", 0, "Verbose", "Output information about the errors found"); + RNA_def_boolean(func, "verbose", false, "Verbose", "Output information about the errors found"); + RNA_def_boolean(func, "cleanup_cddata", true, "Cleanup CDData", + "Remove temp/cached cdlayers, like e.g. normals..."); parm = RNA_def_boolean(func, "result", 0, "Result", ""); RNA_def_function_return(func, parm); |