--- a/src/sampler.cc Fri Mar 28 00:53:20 2008 +0100
+++ b/src/sampler.cc Fri Mar 28 17:13:21 2008 +0100
@@ -42,6 +42,7 @@
{
cout << "phase 1" << endl;
phase++;
+ sx = -1;
return w*h*samples;
}
else if ( phase == 1 && oversample )
@@ -60,7 +61,7 @@
}
}
-Sample* DefaultSampler::nextSample(Sample *prev)
+Sample* DefaultSampler::nextSample()
{
DefaultSample *s = new DefaultSample;
@@ -84,58 +85,56 @@
const Float *osax = osaSx[oversample];
const Float *osay = osaSy[oversample];
- if (!prev)
+ if (sx < 0)
{
// first sample
s->x = -(Float)w/h/2.0;
s->y = -0.5;
- s->sx = 0;
- s->sy = 0;
- s->osa_samp = 0;
+ sx = 0;
+ sy = 0;
+ osa_samp = 0;
}
else
{
- DefaultSample *sp = static_cast<DefaultSample*>(prev);
-
- s->osa_samp = sp->osa_samp + 1;
+ osa_samp++;
- if (oversample && oversample <= 3 && s->osa_samp < samples)
+ if (oversample && oversample <= 3 && osa_samp < samples)
{
- s->sx = sp->sx;
- s->sy = sp->sy;
- s->x = osax[s->osa_samp]/h + (Float)s->sx/h - (Float)w/h/2.0;
- s->y = osay[s->osa_samp]/h + (Float)s->sy/h - 0.5;
+ s->x = osax[osa_samp]/h + (Float)sx/h - (Float)w/h/2.0;
+ s->y = osay[osa_samp]/h + (Float)sy/h - 0.5;
}
else
{
- s->sx = sp->sx + 1;
- s->sy = sp->sy;
- if (s->sx >= w)
+ sx++;
+ if (sx >= w)
{
- s->sx = 0;
- s->sy++;
+ sx = 0;
+ sy++;
}
- if (s->sy >= h)
+ if (sy >= h)
{
delete s;
return NULL;
}
- s->x = (Float)s->sx/h - (Float)w/h/2.0;
- s->y = (Float)s->sy/h - 0.5;
- s->osa_samp = 0;
+ s->x = (Float)sx/h - (Float)w/h/2.0;
+ s->y = (Float)sy/h - 0.5;
+ osa_samp = 0;
}
}
- if (s->osa_samp == 0 && oversample && oversample <= 3)
+ if (osa_samp == 0 && oversample && oversample <= 3)
{
s->x += osax[0]/h;
s->y += osay[0]/h;
- Float *buf = buffer + 3*(s->sy*w + s->sx);
+ Float *buf = buffer + 3*(sy*w + sx);
*(buf++) = 0;
*(buf++) = 0;
*(buf++) = 0;
}
+ s->sx = sx;
+ s->sy = sy;
+ s->osa_samp = osa_samp;
return s;
}