fixed the dipole serialization code

metadata
Wenzel Jakob 2012-10-16 11:52:24 -04:00
parent e23e84b81f
commit eabc3f17bc
3 changed files with 21 additions and 12 deletions

View File

@ -396,9 +396,11 @@ public:
Float actualRadius = m_radius / std::sqrt(m_sampleMultiplier * 20);
blueNoisePointSet(scene, m_shapes, actualRadius, points, sa, aabb, job);
/* 2. gather irradiance in parallel */
/* 2. Gather irradiance in parallel */
const Sensor *sensor = scene->getSensor();
ref<IrradianceSamplingProcess> proc = new IrradianceSamplingProcess(
points, 1024, m_irrSamples, m_irrIndirect, job);
points, 1024, m_irrSamples, m_irrIndirect,
sensor->getShutterOpen() + 0.5f * sensor->getShutterOpenTime(), job);
/* Create a sampler instance for every core */
ref<Sampler> sampler = static_cast<Sampler *> (PluginManager::getInstance()->
@ -411,8 +413,11 @@ public:
}
int samplerResID = sched->registerMultiResource(samplers);
int integratorResID = sched->registerResource(
const_cast<Integrator *>(scene->getIntegrator()));
proc->bindResource("scene", sceneResID);
proc->bindResource("integrator", integratorResID);
proc->bindResource("sampler", samplerResID);
scene->bindUsedResources(proc);
m_proc = proc;
@ -423,6 +428,7 @@ public:
samplers[i]->decRef();
sched->unregisterResource(samplerResID);
sched->unregisterResource(integratorResID);
if (proc->getReturnStatus() != ParallelProcess::ESuccess)
return false;

View File

@ -26,18 +26,20 @@ MTS_NAMESPACE_BEGIN
/* Parallel irradiance sampling implementation (worker) */
class IrradianceSamplingWorker : public WorkProcessor {
public:
IrradianceSamplingWorker(int irrSamples, bool irrIndirect)
: m_irrSamples(irrSamples), m_irrIndirect(irrIndirect) {
IrradianceSamplingWorker(int irrSamples, bool irrIndirect, Float time)
: m_irrSamples(irrSamples), m_irrIndirect(irrIndirect), m_time(time) {
}
IrradianceSamplingWorker(Stream *stream, InstanceManager *manager) {
m_irrSamples = stream->readInt();
m_irrIndirect = stream->readBool();
m_time = stream->readFloat();
}
void serialize(Stream *stream, InstanceManager *manager) const {
stream->writeInt(m_irrSamples);
stream->writeBool(m_irrIndirect);
stream->writeFloat(m_time);
}
ref<WorkUnit> createWorkUnit() const {
@ -50,8 +52,8 @@ public:
void prepare() {
m_scene = static_cast<Scene *>(getResource("scene"));
m_integrator = static_cast<SamplingIntegrator *>(m_scene->getIntegrator());
m_sampler = static_cast<Sampler *>(getResource("sampler"));
m_integrator = static_cast<SamplingIntegrator *>(getResource("integrator"));
m_scene->wakeup(NULL, m_resources);
}
@ -60,7 +62,6 @@ public:
const PositionSampleVector &positions = *static_cast<const PositionSampleVector *>(workUnit);
IrradianceSampleVector *result = static_cast<IrradianceSampleVector *>(workResult);
const SamplingIntegrator *integrator = m_integrator.get();
Float time = m_scene->getSensor()->getShutterOpen();
result->clear();
@ -71,7 +72,7 @@ public:
its.p = sample.p;
its.shFrame = Frame(sample.n);
its.shape = m_scene->getShapes()[sample.shapeIndex].get();
its.time = time;
its.time = m_time;
its.hasUVPartials = false;
result->put(IrradianceSample(
@ -83,7 +84,7 @@ public:
}
ref<WorkProcessor> clone() const {
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect);
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect, m_time);
}
MTS_DECLARE_CLASS()
@ -95,6 +96,7 @@ private:
ref<SamplingIntegrator> m_integrator;
int m_irrSamples;
bool m_irrIndirect;
Float m_time;
};
void PositionSampleVector::load(Stream *stream) {
@ -144,10 +146,10 @@ std::string IrradianceSampleVector::toString() const {
}
IrradianceSamplingProcess::IrradianceSamplingProcess(PositionSampleVector *positions,
size_t granularity, int irrSamples, bool irrIndirect,
size_t granularity, int irrSamples, bool irrIndirect, Float time,
const void *data)
: m_positionSamples(positions), m_granularity(granularity),
m_irrSamples(irrSamples), m_irrIndirect(irrIndirect) {
m_irrSamples(irrSamples), m_irrIndirect(irrIndirect), m_time(time) {
m_resultMutex = new Mutex();
m_irradianceSamples = new IrradianceSampleVector();
m_irradianceSamples->reserve(positions->size());
@ -161,7 +163,7 @@ IrradianceSamplingProcess::~IrradianceSamplingProcess() {
}
ref<WorkProcessor> IrradianceSamplingProcess::createWorkProcessor() const {
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect);
return new IrradianceSamplingWorker(m_irrSamples, m_irrIndirect, m_time);
}
ParallelProcess::EStatus IrradianceSamplingProcess::generateWork(WorkUnit *unit, int worker) {

View File

@ -194,7 +194,7 @@ class IrradianceSamplingProcess : public ParallelProcess {
public:
IrradianceSamplingProcess(PositionSampleVector *positions,
size_t granularity, int irrSamples, bool irrIndirect,
const void *data);
Float time, const void *data);
inline IrradianceSampleVector *getIrradianceSampleVector() {
return m_irradianceSamples.get();
@ -223,6 +223,7 @@ private:
size_t m_samplesRequested, m_granularity;
int m_irrSamples;
bool m_irrIndirect;
Float m_time;
ref<Mutex> m_resultMutex;
ProgressReporter *m_progress;
AABB m_aabb;