-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgravity_cutscene_cam.cpp
More file actions
62 lines (52 loc) · 1.54 KB
/
gravity_cutscene_cam.cpp
File metadata and controls
62 lines (52 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "gravity_cutscene_cam.h"
bool CutsceneCam::CalculateTransform(Matrix4x3& res, Camera& cam, Player& player)
{
if (RUNNING_KUPPA_SCRIPT)
{
const Matrix3x3& m = ActorExtension::Get(player).GetGravityMatrix();
transform.Linear() = m(cam.camMat.Linear().Transpose());
transform.c3 = m(cam.pos - player.pos) + player.pos;
}
res = transform;
return RUNNING_KUPPA_SCRIPT;
}
static void InitCamPosAndLookAt(Vector3& camPos, Vector3& lookAt, const Player& player)
{
const Vector3 realCamPos = INV_VIEW_MATRIX_ASR_3.c3 << 3;
const Fix12i dist = realCamPos.Dist(CAMERA->ownerPos);
const Vector3 realLookAt = realCamPos - INV_VIEW_MATRIX_ASR_3.c2 * dist;
const Matrix3x3& m = ActorExtension::Get(player).GetGravityMatrix();
camPos = m.Transpose()(realCamPos - player.pos) + player.pos;
lookAt = m.Transpose()(realLookAt - player.pos) + player.pos;
}
asm(R"(
ContinueToRunKuppaScript:
push {r14}
b 0x0200ef08
)");
extern "C" bool ContinueToRunKuppaScript(char* address);
bool nsub_0200ef04(char* address)
{
if (!CamCtrl::IsVanillaCamActive() && PLAYER_ARR[0])
{
InitCamPosAndLookAt(CAMERA->pos, CAMERA->lookAt, *PLAYER_ARR[0]);
}
return ContinueToRunKuppaScript(address);
}
asm(R"(
repl_020c9dbc_ov_02:
repl_020c81b4_ov_02:
mov r1, r4
b _Z25MakePlayerLookAtTheCamerasR6Player
)");
void MakePlayerLookAtTheCamera(short camAngleY, Player& player)
{
if (RUNNING_KUPPA_SCRIPT)
player.ang.y = camAngleY;
else
{
Vector3 camPos, lookAt;
InitCamPosAndLookAt(camPos, lookAt, player);
player.ang.y = lookAt.HorzAngle(camPos);
}
}