From 4aee701f0028fbf17103a5565d72e05bbfcc8d9f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 12 Sep 2017 14:14:34 +0500 Subject: [PATCH] Fix T52679: Hole in bake normal In fact, any type of baking might have caused holes in mesh. The issue was caused by zspan_scanconvert() attempting to get order of traversal 'a-priori', which might have failed if check happens at the "tip" of span where `zspan->span1[sn1] == zspan->span2[sn1]`. Didn't see anything bad on making it a check when iterating over scanlines and pick minimal span based on current scanline. It's slower, but unlikely to cause measurable difference. Quality should stay the same unless i'm missing something. Reviewers: brecht, dfelinto Reviewed By: brecht Differential Revision: https://developer.blender.org/D2837 --- source/blender/render/intern/source/zbuf.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 68707f163af..0b6d31ef902 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -1564,20 +1564,13 @@ void zspan_scanconvert(ZSpan *zspan, void *handle, float *v1, float *v2, float * vy0= ((double)my2)*vyd + (double)xx1; /* correct span */ - sn1= (my0 + my2)/2; - if (zspan->span1[sn1] < zspan->span2[sn1]) { - span1= zspan->span1+my2; - span2= zspan->span2+my2; - } - else { - span1= zspan->span2+my2; - span2= zspan->span1+my2; - } + span1= zspan->span1+my2; + span2= zspan->span2+my2; for (i = 0, y = my2; y >= my0; i++, y--, span1--, span2--) { - sn1= floor(*span1); - sn2= floor(*span2); + sn1= floor(min_ff(*span1, *span2)); + sn2= floor(max_ff(*span1, *span2)); sn1++; if (sn2>=rectx) sn2= rectx-1;