Fix divide by zero crash in zone lighter

feature/pre-code-move
kaetemi 5 years ago committed by Jan Boon
parent 8d48c8ee74
commit 761770d4eb

@ -1179,36 +1179,43 @@ void CZoneLighter::light (CLandscape &landscape, CZone& output, uint zoneToLight
// Set the thread state // Set the thread state
_LastPatchComputed.resize (_ProcessCount); _LastPatchComputed.resize (_ProcessCount);
// Launch threads if (patchCount)
uint process;
for (process=0; process<_ProcessCount; process++)
{ {
// Last patch // Launch threads
uint lastPatch=firstPatch+patchCountByThread; uint process;
lastPatch %= patchCount; for (process = 0; process < _ProcessCount; process++)
{
// Last patch
uint lastPatch = firstPatch + patchCountByThread;
lastPatch %= patchCount;
// Last patch computed // Last patch computed
_LastPatchComputed[process] = firstPatch; _LastPatchComputed[process] = firstPatch;
// Create a thread // Create a thread
CLightRunnable *runnable = new CLightRunnable (process, this, &description); CLightRunnable *runnable = new CLightRunnable(process, this, &description);
IThread *pThread=IThread::create (runnable); IThread *pThread = IThread::create(runnable);
runnable->Thread = pThread; runnable->Thread = pThread;
// New first patch // New first patch
firstPatch=lastPatch; firstPatch = lastPatch;
// Launch // Launch
pThread->start(); pThread->start();
} }
// Wait for others processes // Wait for others processes
while (_ProcessExited!=_ProcessCount) while (_ProcessExited != _ProcessCount)
{ {
nlSleep (1000); nlSleep(1000);
// Call the progress callback // Call the progress callback
progress ("Lighting patches", (float)_NumberOfPatchComputed/(float)_PatchInfo.size()); progress("Lighting patches", (float)_NumberOfPatchComputed / (float)_PatchInfo.size());
}
}
else
{
nlwarning("Empty zone");
} }
// Reset old thread mask // Reset old thread mask

Loading…
Cancel
Save