| 1507 | } |
| 1508 | |
| 1509 | void ItemsCollideCamera() |
| 1510 | { |
| 1511 | if (!g_GameFlow->GetSettings()->Camera.ObjectCollision) |
| 1512 | return; |
| 1513 | |
| 1514 | constexpr auto RADIUS = CLICK(0.5f); |
| 1515 | |
| 1516 | auto itemList = FillCollideableItemList(); |
| 1517 | |
| 1518 | // Collide with items in the items list. |
| 1519 | for (int i = 0; i < itemList.size(); i++) |
| 1520 | { |
| 1521 | auto* item = &g_Level.Items[itemList[i]]; |
| 1522 | if (!item) |
| 1523 | return; |
| 1524 | |
| 1525 | // Break off if camera is stuck behind an object and the player runs off. |
| 1526 | auto distance = Vector3i::Distance(item->Pose.Position, LaraItem->Pose.Position); |
| 1527 | if (distance > COLL_CANCEL_THRESHOLD) |
| 1528 | continue; |
| 1529 | |
| 1530 | auto bounds = GameBoundingBox(item); |
| 1531 | if (TestBoundsCollideCamera(bounds, item->Pose, CAMERA_RADIUS)) |
| 1532 | ItemPushCamera(&bounds, &item->Pose, RADIUS); |
| 1533 | |
| 1534 | if (DebugMode) |
| 1535 | { |
| 1536 | DrawDebugBox( |
| 1537 | bounds.ToBoundingOrientedBox(item->Pose), |
| 1538 | Vector4(1.0f, 0.0f, 0.0f, 1.0f), RendererDebugPage::CollisionStats); |
| 1539 | } |
| 1540 | } |
| 1541 | |
| 1542 | // Done. |
| 1543 | itemList.clear(); |
| 1544 | |
| 1545 | // Collide with static meshes. |
| 1546 | auto staticList = FillCollideableStaticsList(); |
| 1547 | for (auto* mesh : staticList) |
| 1548 | { |
| 1549 | if (!mesh) |
| 1550 | return; |
| 1551 | |
| 1552 | auto distance = Vector3i::Distance(mesh->Pose.Position, LaraItem->Pose.Position); |
| 1553 | if (distance > COLL_CANCEL_THRESHOLD) |
| 1554 | continue; |
| 1555 | |
| 1556 | auto bounds = GetBoundsAccurate(*mesh, false); |
| 1557 | if (TestBoundsCollideCamera(bounds, mesh->Pose, CAMERA_RADIUS)) |
| 1558 | ItemPushCamera(&bounds, &mesh->Pose, RADIUS); |
| 1559 | |
| 1560 | if (DebugMode) |
| 1561 | { |
| 1562 | DrawDebugBox( |
| 1563 | bounds.ToBoundingOrientedBox(mesh->Pose), |
| 1564 | Vector4(1.0f, 0.0f, 0.0f, 1.0f), RendererDebugPage::CollisionStats); |
| 1565 | } |
| 1566 | } |
no test coverage detected