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>2011-02-09 18:13:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-09 18:13:20 +0300
commit5aa72b87262c1dd310c5dba7cd772b3d6b02a427 (patch)
treeb80ed52824db264a5e8020f0c016ba33a8da5fd1 /source/blender/editors/mesh
parent38e5081839c9b68622a02e707780cf906e92fec1 (diff)
BKE_mesh_validate() now corrects invalid meshes (optionally), added access for python so it can correct for bad imported geometry - mesh.validate().
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r--source/blender/editors/mesh/mesh_data.c69
1 files changed, 1 insertions, 68 deletions
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 5f03edb38a2..cfd1b006ece 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -546,77 +546,10 @@ void MESH_OT_sticky_remove(wmOperatorType *ot)
/************************** Add Geometry Layers *************************/
-static void mesh_calc_edges(Mesh *mesh, int update)
-{
- CustomData edata;
- EdgeHashIterator *ehi;
- MFace *mf = mesh->mface;
- MEdge *med, *med_orig;
- EdgeHash *eh = BLI_edgehash_new();
- int i, totedge, totface = mesh->totface;
-
- if(mesh->totedge==0)
- update= 0;
-
- if(update) {
- /* assume existing edges are valid
- * useful when adding more faces and generating edges from them */
- med= mesh->medge;
- for(i= 0; i<mesh->totedge; i++, med++)
- BLI_edgehash_insert(eh, med->v1, med->v2, med);
- }
-
- for (i = 0; i < totface; i++, mf++) {
- if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2))
- BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL);
- if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3))
- BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL);
-
- if (mf->v4) {
- if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4))
- BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL);
- if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1))
- BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL);
- } else {
- if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1))
- BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL);
- }
- }
-
- totedge = BLI_edgehash_size(eh);
-
- /* write new edges into a temporary CustomData */
- memset(&edata, 0, sizeof(edata));
- CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
-
- ehi = BLI_edgehashIterator_new(eh);
- med = CustomData_get_layer(&edata, CD_MEDGE);
- for(i = 0; !BLI_edgehashIterator_isDone(ehi);
- BLI_edgehashIterator_step(ehi), ++i, ++med) {
-
- if(update && (med_orig=BLI_edgehashIterator_getValue(ehi))) {
- *med= *med_orig; /* copy from the original */
- } else {
- BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
- med->flag = ME_EDGEDRAW|ME_EDGERENDER|SELECT; /* select for newly created meshes which are selected [#25595] */
- }
- }
- BLI_edgehashIterator_free(ehi);
-
- /* free old CustomData and assign new one */
- CustomData_free(&mesh->edata, mesh->totedge);
- mesh->edata = edata;
- mesh->totedge = totedge;
-
- mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE);
-
- BLI_edgehash_free(eh, NULL);
-}
-
void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges)
{
if(calc_edges || (mesh->totface && mesh->totedge == 0))
- mesh_calc_edges(mesh, calc_edges);
+ BKE_mesh_calc_edges(mesh, calc_edges);
mesh_calc_normals(mesh->mvert, mesh->totvert, mesh->mface, mesh->totface, NULL);