meshes with nan verts could crash blender when building as mesh octree
authorCampbell Barton <ideasman42@gmail.com>
Sun, 17 Feb 2008 18:50:45 +0000 (18:50 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 17 Feb 2008 18:50:45 +0000 (18:50 +0000)
source/blender/src/meshtools.c

index 4a843f879400d933aa35fd70c84a7364295c7f9c..15515f2b0ba3939a847d3a60dec41f39d49e8ee5 100644 (file)
@@ -650,6 +650,13 @@ static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, f
        float fx, fy, fz;
        int vx, vy, vz;
        
+       if (isnan(co[0]) || !finite(co[0]) ||
+               isnan(co[1]) || !finite(co[1]) ||
+               isnan(co[2]) || !finite(co[2])
+       ) {
+               return;
+       }
+       
        fx= (co[0]-offs[0])/div[0];
        fy= (co[1]-offs[1])/div[1];
        fz= (co[2]-offs[2])/div[2];
@@ -799,7 +806,7 @@ long mesh_octree_table(Object *ob, float *co, char mode)
                
                if(ob==G.obedit) {
                        EditVert *eve;
-                       
+
                        for(eve= G.editMesh->verts.first; eve; eve= eve->next) {
                                mesh_octree_add_nodes(MeshOctree.table, eve->co, MeshOctree.offs, MeshOctree.div, (long)(eve));
                        }
@@ -861,6 +868,13 @@ EditVert *editmesh_get_x_mirror_vert(Object *ob, float *co)
        float vec[3];
        long poinval;
        
+       /* ignore nan verts */
+       if (isnan(co[0]) || !finite(co[0]) ||
+               isnan(co[1]) || !finite(co[1]) ||
+               isnan(co[2]) || !finite(co[2])
+          )
+               return NULL;
+       
        vec[0]= -co[0];
        vec[1]= co[1];
        vec[2]= co[2];