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.
This commit is contained in:
Bastien Montagne 2015-02-05 14:03:01 +01:00
parent e442b9916e
commit 7bae9ee6b6
6 changed files with 9 additions and 7 deletions

View File

@ -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);

View File

@ -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(

View File

@ -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);

View File

@ -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); */
}
}
}

View File

@ -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
}

View File

@ -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);