BKE_mesh_validate_arrays was correcting non-finite verts and zero normals even when...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 9 Dec 2011 07:23:17 +0000 (07:23 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 9 Dec 2011 07:23:17 +0000 (07:23 +0000)
source/blender/blenkernel/intern/mesh_validate.c

index c09e18e3ba0591857244630a2d2a6899f2e7a8db..774565bb4bd0c3ae47ff79195abac381a1d51db8 100644 (file)
@@ -136,9 +136,11 @@ int BKE_mesh_validate_arrays( Mesh *me,
        MVert *mvert= mverts;
        unsigned int i;
 
-       int do_face_free= FALSE;
-       int do_edge_free= FALSE;
-       int verts_fixed= FALSE;
+       short do_face_free= FALSE;
+       short do_edge_free= FALSE;
+
+       short verts_fixed= FALSE;
+       short vert_weights_fixed= FALSE;
 
        int do_edge_recalc= FALSE;
 
@@ -165,9 +167,12 @@ int BKE_mesh_validate_arrays( Mesh *me,
                for(j=0; j<3; j++) {
                        if(!finite(mvert->co[j])) {
                                PRINT("    vertex %u: has invalid coordinate\n", i);
-                               zero_v3(mvert->co);
 
-                               verts_fixed= TRUE;
+                               if (do_fixes) {
+                                       zero_v3(mvert->co);
+
+                                       verts_fixed= TRUE;
+                               }
                        }
 
                        if(mvert->no[j]!=0)
@@ -176,8 +181,10 @@ int BKE_mesh_validate_arrays( Mesh *me,
 
                if(fix_normal) {
                        PRINT("    vertex %u: has zero normal, assuming Z-up normal\n", i);
-                       mvert->no[2]= SHRT_MAX;
-                       verts_fixed= TRUE;
+                       if (do_fixes) {
+                               mvert->no[2]= SHRT_MAX;
+                               verts_fixed= TRUE;
+                       }
                }
        }
 
@@ -327,6 +334,7 @@ int BKE_mesh_validate_arrays( Mesh *me,
                                        PRINT("    vertex 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;
                                        }
                                }
 
@@ -339,6 +347,8 @@ int BKE_mesh_validate_arrays( Mesh *me,
                                                         * within the for loop and may not be valid */
                                                        j--;
                                                        dw= dv->dw + j;
+
+                                                       vert_weights_fixed= TRUE;
                                                }
                                                else { /* all freed */
                                                        break;
@@ -369,7 +379,7 @@ int BKE_mesh_validate_arrays( Mesh *me,
                }
        }
 
-       return (verts_fixed || do_face_free || do_edge_free || do_edge_recalc);
+       return (verts_fixed || vert_weights_fixed || do_face_free || do_edge_free || do_edge_recalc);
 }
 
 static int mesh_validate_customdata(CustomData *data, short do_verbose, const short do_fixes)