src/sampler.cc
branchpyrit
changeset 92 9af5c039b678
parent 88 f7edb3b90816
child 93 96d65f841791
--- a/src/sampler.cc	Fri May 02 13:27:47 2008 +0200
+++ b/src/sampler.cc	Mon May 05 15:31:14 2008 +0200
@@ -223,19 +223,10 @@
 			}
 			else
 			{
-				sx++;
-				if (sx >= w)
-				{
-					sx = 0;
-					sy++;
-				}
-				if (sy >= h)
-					return false;
-
 				if (subsample > 1)
 				{
 					// find next not interpolated pixel
-					while ( *(buffer + 3*(sy*w + sx)) >= 0. )
+					do
 					{
 						sx++;
 						if (sx >= w)
@@ -246,6 +237,46 @@
 						if (sy >= h)
 							return false;
 					}
+					while ( *(buffer + 3*(sy*w + sx)) >= 0. );
+				}
+				else if (!oversample && !(w&1) && !(h&1))
+				{
+					// generate good raster for packet tracing
+					const int j = ((sy&1)<<1) + (sx&1);
+					switch (j)
+					{
+						case 0:
+						case 2:
+							sx++;
+							break;
+						case 1:
+							sx--;
+							sy++;
+							break;
+						case 3:
+							sx++;
+							if (sx >= w)
+							{
+								sx = 0;
+								sy++;
+							}
+							else
+								sy--;
+							if (sy >= h)
+								return false;
+							break;
+					}
+				}
+				else
+				{
+					sx++;
+					if (sx >= w)
+					{
+						sx = 0;
+						sy++;
+					}
+					if (sy >= h)
+						return false;
 				}
 
 				s->x = (Float)sx/h - (Float)w/h/2.0;