| 422 | } |
| 423 | |
| 424 | void Renderer::CollectItems(short roomNumber, RenderView& renderView) |
| 425 | { |
| 426 | if (_rooms.size() <= roomNumber) |
| 427 | return; |
| 428 | |
| 429 | auto& rendererRoom = _rooms[roomNumber]; |
| 430 | const auto& room = g_Level.Rooms[rendererRoom.RoomNumber]; |
| 431 | |
| 432 | bool isRoomReflected = IsRoomReflected(renderView, roomNumber); |
| 433 | |
| 434 | short itemNumber = NO_VALUE; |
| 435 | for (itemNumber = room.itemNumber; itemNumber != NO_VALUE; itemNumber = g_Level.Items[itemNumber].NextItem) |
| 436 | { |
| 437 | const auto& item = g_Level.Items[itemNumber]; |
| 438 | |
| 439 | if (item.ObjectNumber == ID_LARA && itemNumber == g_Level.Items[itemNumber].NextItem) |
| 440 | break; |
| 441 | |
| 442 | if (item.Status == ITEM_INVISIBLE) |
| 443 | continue; |
| 444 | |
| 445 | if (item.Model.Color.w < EPSILON) |
| 446 | continue; |
| 447 | |
| 448 | if (item.ObjectNumber == ID_LARA && UseSpotCam && (SpotcamOverlay || SpotcamDontDrawLara)) |
| 449 | continue; |
| 450 | |
| 451 | if (item.ObjectNumber == ID_LARA && CurrentLevel == 0 && !g_GameFlow->IsLaraInTitleEnabled()) |
| 452 | continue; |
| 453 | |
| 454 | if (!_moveableObjects[item.ObjectNumber].has_value()) |
| 455 | continue; |
| 456 | |
| 457 | auto& obj = _moveableObjects[item.ObjectNumber].value(); |
| 458 | |
| 459 | if (obj.Hidden) |
| 460 | continue; |
| 461 | |
| 462 | // Clip object by frustum only if it doesn't cast shadows and is not in mirror room, |
| 463 | // otherwise disappearing shadows or reflections may be seen if object gets out of frustum. |
| 464 | bool inFrustum = true; |
| 465 | |
| 466 | if (!isRoomReflected && obj.ShadowType == ShadowMode::None) |
| 467 | { |
| 468 | inFrustum = false; |
| 469 | |
| 470 | // Get all spheres and check if frustum intersects any of them. |
| 471 | auto spheres = GetSpheres(itemNumber); |
| 472 | |
| 473 | for (int i = 0; !inFrustum, i < spheres.size(); i++) |
| 474 | { |
| 475 | // Blow up sphere radius by half for cases of too small calculated spheres. |
| 476 | if (renderView.Camera.Frustum.SphereInFrustum(spheres[i].Center, spheres[i].Radius * 1.5f)) |
| 477 | inFrustum = true; |
| 478 | } |
| 479 | |
| 480 | // NOTE: removed continue loop here if not in frustum, |
| 481 | // for updating first positions and animations data |
nothing calls this directly
no test coverage detected