From 77e3eac3897975a82e1c68468002a5eb0f00a8b5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 30 Mar 2011 02:05:10 +0000 Subject: [PATCH] Fix for old bug with subsurf not initializing normals for edges that had no faces, Noted that a floating point exception caused by this r28953. With the render engine using DerivedMesh normals this came up as a memory error when rendering some files. for now zero the normals, could interpolate between vertex normals if needed. --- source/blender/blenkernel/intern/CCGSubSurf.c | 11 +++++++++++ source/blender/blenkernel/intern/subsurf_ccg.c | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 2cfd17a95f3..a311ca15e5e 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1342,6 +1342,17 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, NormCopy(EDGE_getNo(e, lvl, x), _face_getIFNoEdge(f, e, lvl, x, 0, subdivLevels, vertDataSize, normalDataOffset)); } + else { + /* set to zero here otherwise the normals are uninitialized memory + * render: tests/animation/knight.blend with valgrind. + * we could be more clever and interpolate vertex normals but these are + * most likely not used so just zero out. */ + int x; + + for (x=0; xco); - /* XXX, This gives errors with -fpe, the normals dont seem to be unit length - campbell */ + /* This gives errors with -debug-fpe + * the normals dont seem to be unit length. + * this is most likely caused by edges with no + * faces which are now zerod out, see comment in: + * ccgSubSurf__calcVertNormals(), - campbell */ normal_float_to_short_v3(mvert[i].no, vd->no); } }