MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / ItemsCollideCamera

Function ItemsCollideCamera

TombEngine/Game/camera.cpp:1509–1570  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1507}
1508
1509void 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 }

Callers 2

LookCameraFunction · 0.85
MoveCameraFunction · 0.85

Calls 11

FillCollideableItemListFunction · 0.85
TestBoundsCollideCameraFunction · 0.85
ItemPushCameraFunction · 0.85
DrawDebugBoxFunction · 0.85
GetSettingsMethod · 0.80
ToBoundingOrientedBoxMethod · 0.80
GameBoundingBoxClass · 0.70
Vector4Function · 0.50
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected