fix [#25994] Meshes with no vertices gets NaN location on setting origin to geometry

This commit is contained in:
2011-02-09 15:32:39 +00:00
parent 5aa72b8726
commit 97c57abfa3
2 changed files with 15 additions and 8 deletions

View File

@@ -1556,7 +1556,10 @@ int mesh_center_median(Mesh *me, float cent[3])
for(mvert= me->mvert; i--; mvert++) {
add_v3_v3(cent, mvert->co);
}
mul_v3_fl(cent, 1.0f/(float)me->totvert);
/* otherwise we get NAN for 0 verts */
if(me->totvert) {
mul_v3_fl(cent, 1.0f/(float)me->totvert);
}
return (me->totvert != 0);
}