MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / xCameraFXShakeUpdate

Function xCameraFXShakeUpdate

src/SB/Core/x/xCamera.cpp:1051–1101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1049}
1050
1051void xCameraFXShakeUpdate(cameraFX* f, F32 dt, const xMat4x3*, xMat4x3* m)
1052{
1053 F32 x, y, scale, noise;
1054 xVec3 var_4C, e;
1055
1056 f->shake.cycleTime += dt;
1057
1058 while (f->shake.cycleTime > f->shake.cycleMax)
1059 {
1060 f->shake.dir.x = -f->shake.dir.x;
1061 f->shake.dir.y = -f->shake.dir.y;
1062 f->shake.cycleTime -= f->shake.cycleMax;
1063 }
1064
1065 scale = f->shake.dampenRate * (f->maxTime - f->elapsedTime);
1066 noise = 0.1f * (xurand() - 0.5f);
1067
1068 if (f->shake.radius > 0.0f && f->shake.player)
1069 {
1070 xVec3Sub(&var_4C, f->shake.player, &f->shake.epicenter);
1071
1072 F32 f1 = var_4C.length();
1073
1074 if (f1 > f->shake.radius)
1075 {
1076 scale = 0.0f;
1077 }
1078 else
1079 {
1080 scale *= icos(f1 / f->shake.radius * 3.1415927f * 0.5f);
1081 }
1082 }
1083
1084 x = (f->shake.magnitude + noise) * f->shake.dir.x * scale / f->shake.cycleMax *
1085 f->shake.cycleTime * isin(f->shake.cycleTime / f->shake.cycleMax * 3.1415927f);
1086
1087 noise = 0.1f * (xurand() - 0.5f);
1088
1089 y = (f->shake.magnitude + noise) * f->shake.dir.y * scale / f->shake.cycleMax *
1090 f->shake.cycleTime * isin(f->shake.cycleTime / f->shake.cycleMax * 3.1415927f);
1091
1092 xMat4x3MoveLocalRight(m, x);
1093 xMat4x3MoveLocalUp(m, y);
1094
1095 xMat3x3GetEuler(m, &e);
1096
1097 e.z += f->shake.cycleTime / f->shake.cycleMax * 0.63661975f * 0.1f * scale *
1098 f->shake.rotate_magnitude;
1099
1100 xMat3x3Euler(m, &e);
1101}
1102
1103void xCameraFXUpdate(xCamera* cam, F32 dt)
1104{

Callers

nothing calls this directly

Calls 9

xurandFunction · 0.85
xVec3SubFunction · 0.85
icosFunction · 0.85
isinFunction · 0.85
xMat4x3MoveLocalRightFunction · 0.85
xMat4x3MoveLocalUpFunction · 0.85
xMat3x3EulerFunction · 0.85
lengthMethod · 0.80
xMat3x3GetEulerFunction · 0.70

Tested by

no test coverage detected