src/sampler.cc
branchpyrit
changeset 53 228cb8bfdd54
parent 51 89fec8668768
child 77 dbe8438d5dca
--- a/src/sampler.cc	Fri Mar 28 23:30:04 2008 +0100
+++ b/src/sampler.cc	Sat Mar 29 02:17:22 2008 +0100
@@ -59,10 +59,8 @@
 	}
 }
 
-Sample* DefaultSampler::nextSample()
+bool DefaultSampler::nextSample(Sample* s)
 {
-	DefaultSample *s = new DefaultSample;
-
 	/* grid oversampling */
 	static const int gridsamples[] = {1,5,9,16};
 	static const Float osa5x[] = {0.0, -0.4, +0.4, +0.4, -0.4};
@@ -109,11 +107,10 @@
 				sx = 0;
 				sy++;
 			}
+
 			if (sy >= h)
-			{
-				delete s;
-				return NULL;
-			}
+				return false;
+
 			s->x = (Float)sx/h - (Float)w/h/2.0;
 			s->y = (Float)sy/h - 0.5;
 			osa_samp = 0;
@@ -133,13 +130,13 @@
 	s->sx = sx;
 	s->sy = sy;
 	s->osa_samp = osa_samp;
-	return s;
+
+	return true;
 }
 
-void DefaultSampler::saveSample(Sample *samp, Colour &col)
+void DefaultSampler::saveSample(Sample &samp, Colour &col)
 {
-	DefaultSample *sp = static_cast<DefaultSample*>(samp);
-	Float *buf = buffer + 3*(sp->sy*w + sp->sx);
+	Float *buf = buffer + 3*(samp.sy * w + samp.sx);
 	if (oversample)
 	{
 		*(buf+0) += col.r;