| 1049 | } |
| 1050 | |
| 1051 | void 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 | |
| 1103 | void xCameraFXUpdate(xCamera* cam, F32 dt) |
| 1104 | { |
nothing calls this directly
no test coverage detected