From 455b239c1560776b28b05ae4f26b1cf95f2bd005 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Tue, 22 Jul 2014 22:45:00 +0200 Subject: [PATCH] mtsgui: handle problematic scenes more gracefully where Mitsuba cannot generate any VPLs --- src/librender/vpl.cpp | 6 ++++++ src/mtsgui/preview.cpp | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/librender/vpl.cpp b/src/librender/vpl.cpp index dcacee3e..474248fc 100644 --- a/src/librender/vpl.cpp +++ b/src/librender/vpl.cpp @@ -93,10 +93,16 @@ size_t generateVPLs(const Scene *scene, Random *random, + sensor->getShutterOpenTime() * sampler->next1D(); const Frame stdFrame(Vector(1,0,0), Vector(0,1,0), Vector(0,0,1)); + int retries = 0; while (vpls.size() < count) { sampler->setSampleIndex(++offset); + if (vpls.empty() && ++retries > 10000) { + /* Unable to generate VPLs in this scene -- give up. */ + return 0; + } + PositionSamplingRecord pRec(time); DirectionSamplingRecord dRec; Spectrum weight = scene->sampleEmitterPosition(pRec, diff --git a/src/mtsgui/preview.cpp b/src/mtsgui/preview.cpp index cd56a86f..77c15e43 100644 --- a/src/mtsgui/preview.cpp +++ b/src/mtsgui/preview.cpp @@ -397,6 +397,22 @@ void PreviewThread::run() { m_backgroundScaleFactor = m_vplSampleOffset - oldOffset; } + if (m_vpls.empty()) { + /* Unable to generate any VPLs for this scene. Give up. */ + lock.lock(); + target.buffer->activateTarget(); + target.buffer->clear(); + target.buffer->releaseTarget(); + m_accumBuffer = target.buffer; + m_readyQueue.push_back(target); + if (m_useSync) + target.sync->init(); + m_queueCV->signal(); + lock.unlock(); + sleep(100); + continue; + } + VPL vpl = m_vpls.front(); m_vpls.pop_front();