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

Function ItemPushCamera

TombEngine/Game/camera.cpp:1368–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1366}
1367
1368void ItemPushCamera(GameBoundingBox* bounds, Pose* pos, short radius)
1369{
1370 int dx = Camera.pos.x - pos->Position.x;
1371 int dz = Camera.pos.z - pos->Position.z;
1372 auto sinY = phd_sin(pos->Orientation.y);
1373 auto cosY = phd_cos(pos->Orientation.y);
1374 auto x = (dx * cosY) - (dz * sinY);
1375 auto z = (dx * sinY) + (dz * cosY);
1376
1377 int xMin = bounds->X1 - radius;
1378 int xMax = bounds->X2 + radius;
1379 int zMin = bounds->Z1 - radius;
1380 int zMax = bounds->Z2 + radius;
1381
1382 if (x <= xMin || x >= xMax || z <= zMin || z >= zMax)
1383 return;
1384
1385 auto left = x - xMin;
1386 auto right = xMax - x;
1387 auto top = zMax - z;
1388 auto bottom = z - zMin;
1389
1390 // Left is closest.
1391 if (left <= right && left <= top && left <= bottom)
1392 x -= left;
1393 // Right is closest.
1394 else if (right <= left && right <= top && right <= bottom)
1395 x += right;
1396 // Top is closest.
1397 else if (top <= left && top <= right && top <= bottom)
1398 z += top;
1399 // Bottom is closest.
1400 else
1401 z -= bottom;
1402
1403 Camera.pos.x = pos->Position.x + ((x * cosY) + (z * sinY));
1404 Camera.pos.z = pos->Position.z + ((z * cosY) - (x * sinY));
1405
1406 auto pointColl = GetPointCollision(Camera.pos.ToVector3i(), Camera.pos.RoomNumber);
1407 if (pointColl.GetFloorHeight() == NO_HEIGHT || Camera.pos.y > pointColl.GetFloorHeight() || Camera.pos.y < pointColl.GetCeilingHeight())
1408 Camera.pos = GameVector(LastPosition.ToVector3i(), pointColl.GetRoomNumber());
1409}
1410
1411bool CheckItemCollideCamera(ItemInfo* item)
1412{

Callers 1

ItemsCollideCameraFunction · 0.85

Calls 8

phd_sinFunction · 0.85
phd_cosFunction · 0.85
GetPointCollisionFunction · 0.85
GameVectorClass · 0.50
ToVector3iMethod · 0.45
GetFloorHeightMethod · 0.45
GetCeilingHeightMethod · 0.45
GetRoomNumberMethod · 0.45

Tested by

no test coverage detected