| 324 | } |
| 325 | |
| 326 | int32 ShadowsOfMordor::Builder::doWork() |
| 327 | { |
| 328 | // Start |
| 329 | bool buildFailed = true; |
| 330 | DateTime buildStart = DateTime::NowUTC(); |
| 331 | _lastStep = BuildProgressStep::CacheEntries; |
| 332 | _lastStepStart = buildStart; |
| 333 | _hemispheresPerJob = HEMISPHERES_PER_JOB_MIN; |
| 334 | _hemispheresPerJobUpdateTime = DateTime::Now(); |
| 335 | LOG(Info, "Start building lightmaps..."); |
| 336 | _isActive = true; |
| 337 | OnBuildStarted(); |
| 338 | reportProgress(BuildProgressStep::Initialize, 0.1f); |
| 339 | |
| 340 | // Check resources and state |
| 341 | if (checkBuildCancelled() || initResources()) |
| 342 | { |
| 343 | _wasBuildCalled = false; |
| 344 | |
| 345 | // Fire event |
| 346 | _isActive = false; |
| 347 | OnBuildFinished(buildFailed); |
| 348 | |
| 349 | // Back |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | // Wait for the scene rendering service to be ready |
| 354 | reportProgress(BuildProgressStep::Initialize, 0.5f); |
| 355 | if (!Renderer::IsReady()) |
| 356 | { |
| 357 | const int32 stepSize = 5; |
| 358 | const int32 maxWaitTime = 30000; |
| 359 | int32 stepsCount = static_cast<int32>(maxWaitTime / stepSize); |
| 360 | while (!Renderer::IsReady() && stepsCount-- > 0) |
| 361 | Platform::Sleep(stepSize); |
| 362 | if (!Renderer::IsReady()) |
| 363 | { |
| 364 | LOG(Error, "Failed to initialize Renderer service."); |
| 365 | _wasBuildCalled = false; |
| 366 | _isActive = false; |
| 367 | OnBuildFinished(buildFailed); |
| 368 | return 0; |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | // Init scenes cache |
| 373 | reportProgress(BuildProgressStep::Initialize, 0.7f); |
| 374 | { |
| 375 | Array<Scene*> scenes; |
| 376 | Level::GetScenes(scenes); |
| 377 | if (scenes.Count() == 0) |
| 378 | { |
| 379 | LOG(Warning, "No scenes to bake lightmaps."); |
| 380 | _wasBuildCalled = false; |
| 381 | _isActive = false; |
| 382 | OnBuildFinished(false); |
| 383 | return 0; |
nothing calls this directly
no test coverage detected