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

Function MoveObjCamera

TombEngine/Game/camera.cpp:468–532  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466}
467
468void MoveObjCamera(GameVector* ideal, ItemInfo* camSlotId, int camMeshId, ItemInfo* targetItem, int targetMeshId)
469{
470 int speed = 1;
471 //Get mesh1 to attach camera to
472 //Vector3i pos = Vector3i::Zero;
473 auto pos = GetJointPosition(camSlotId, camMeshId, Vector3i::Zero);
474 //Get mesh2 to attach target to
475 //Vector3i pos2 = Vector3i::Zero;
476 auto pos2 = GetJointPosition(targetItem, targetMeshId, Vector3i::Zero);
477
478 if (OldCam.pos.Position != pos ||
479 OldCam.targetDistance != Camera.targetDistance ||
480 OldCam.targetElevation != Camera.targetElevation ||
481 OldCam.actualElevation != Camera.actualElevation ||
482 OldCam.actualAngle != Camera.actualAngle ||
483 OldCam.target != Camera.target.ToVector3i() ||
484 Camera.oldType != Camera.type ||
485 Lara.Control.Look.IsUsingBinoculars)
486 {
487 OldCam.pos.Position = pos;
488 OldCam.targetDistance = Camera.targetDistance;
489 OldCam.targetElevation = Camera.targetElevation;
490 OldCam.actualElevation = Camera.actualElevation;
491 OldCam.actualAngle = Camera.actualAngle;
492 OldCam.target = Camera.target.ToVector3i();
493 LastIdeal = pos;
494 LastIdeal.RoomNumber = ideal->RoomNumber;
495 LastTarget = pos2;
496 }
497 else
498 {
499 pos = LastIdeal.ToVector3i();
500 pos2 = LastTarget.ToVector3i();
501 ideal->RoomNumber = LastIdeal.RoomNumber;
502 }
503
504 Camera.pos += (ideal->ToVector3i() - Camera.pos.ToVector3i()) / speed;
505 Camera.pos.RoomNumber = GetPointCollision(Camera.pos.ToVector3i(), Camera.pos.RoomNumber).GetRoomNumber();
506 LookAt(&Camera, 0);
507
508 auto angle = Camera.target.ToVector3i() - Camera.pos.ToVector3i();
509 auto position = Vector3i(Camera.target.ToVector3i() - Camera.pos.ToVector3i());
510
511 // write last frame camera angle to LastAngle to compare if next frame camera angle has a bigger step than 100.
512 // To make camera movement smoother a speed of 2 is used.
513 // While for big camera angle steps (cuts) -
514 // the speed is set to 1 to make the cut immediatelly.
515 constexpr int angleThresholdDegrees = 100;
516
517 if (LastTarget.x - Camera.target.x > angleThresholdDegrees ||
518 LastTarget.y - Camera.target.y > angleThresholdDegrees ||
519 LastTarget.z - Camera.target.z > angleThresholdDegrees)
520 {
521 speed = 1;
522 }
523 else
524 {
525 speed = 2;

Callers 1

ObjCameraFunction · 0.85

Calls 6

GetJointPositionFunction · 0.85
GetPointCollisionFunction · 0.85
LookAtFunction · 0.85
Vector3iClass · 0.70
ToVector3iMethod · 0.45
GetRoomNumberMethod · 0.45

Tested by

no test coverage detected