2021-04-13 09:47:52 +02:00
|
|
|
#include "common.h"
|
|
|
|
|
2023-07-21 18:53:09 +02:00
|
|
|
SHIFT_BSS CamConfiguration gCurrentCamConfiguration;
|
|
|
|
SHIFT_BSS f32 D_800A08DC;
|
|
|
|
SHIFT_BSS f32 D_800A08E0;
|
|
|
|
SHIFT_BSS f32 D_800A08E4;
|
|
|
|
SHIFT_BSS f32 D_800A08E8;
|
|
|
|
SHIFT_BSS f32 D_800A08EC;
|
2021-09-22 13:17:46 +02:00
|
|
|
|
2022-10-01 03:44:48 +02:00
|
|
|
void cam_interp_lookat_pos(Camera* camera, f32 arg1, f32 arg2, s16 arg3);
|
2022-03-28 11:29:47 +02:00
|
|
|
void func_8003034C(Camera* camera);
|
2021-09-22 13:17:46 +02:00
|
|
|
|
|
|
|
void func_80030450(Camera* camera) {
|
2021-04-13 09:47:52 +02:00
|
|
|
}
|
|
|
|
|
2021-09-22 13:17:46 +02:00
|
|
|
CameraControlSettings* test_ray_zone_aabb(f32 x, f32 y, f32 z) {
|
2021-08-16 20:14:58 +02:00
|
|
|
f32 hitX, hitY, hitZ;
|
|
|
|
f32 hitDepth = 32767.0f;
|
|
|
|
f32 nx, ny, nz;
|
|
|
|
s32 zoneID = test_ray_zones(x, y, z, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &nx, &ny, &nz);
|
|
|
|
|
|
|
|
if (zoneID < 0) {
|
2021-09-22 13:17:46 +02:00
|
|
|
return NULL;
|
2021-08-16 20:14:58 +02:00
|
|
|
}
|
|
|
|
|
2022-03-28 11:29:47 +02:00
|
|
|
return gZoneCollisionData.colliderList[zoneID].camSettings;
|
2021-08-16 20:14:58 +02:00
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
enum CameraSettingsPtrType {
|
|
|
|
CAMERA_SETTINGS_PTR_MINUS_2 = -2,
|
|
|
|
CAMERA_SETTINGS_PTR_MINUS_1 = -1,
|
|
|
|
CAMERA_SETTINGS_PTR_NULL = 0,
|
|
|
|
};
|
|
|
|
|
2022-08-25 12:18:04 +02:00
|
|
|
void update_camera_from_controller(
|
|
|
|
Camera* camera,
|
2023-03-02 09:32:54 +01:00
|
|
|
CamConfiguration* oldConfiguration, CameraControlSettings** prevController,
|
|
|
|
CamConfiguration* newConfiguration, CameraControlSettings** newController,
|
2023-03-02 02:16:55 +01:00
|
|
|
f32 x1, f32 y1, f32 z1,
|
2022-08-25 12:18:04 +02:00
|
|
|
f32 tX, f32 tY, f32 tZ, s32 changingMap,
|
|
|
|
f32* interpAlpha, s32 changingZone)
|
|
|
|
{
|
|
|
|
CameraControlSettings* prevSettings;
|
2023-03-02 02:16:55 +01:00
|
|
|
CameraControlSettings* controller;
|
2023-03-02 09:32:54 +01:00
|
|
|
CamConfiguration* configuration;
|
|
|
|
|
2022-08-25 12:18:04 +02:00
|
|
|
f32 boomLength;
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 temp_f18;
|
|
|
|
f32 f24;
|
2022-08-25 12:18:04 +02:00
|
|
|
f32 temp_f2;
|
|
|
|
f32 temp_f2_2;
|
|
|
|
f32 temp_f2_3;
|
|
|
|
f32 temp_f2_4;
|
|
|
|
f32 temp_f2_7;
|
|
|
|
f32 temp_f4;
|
|
|
|
f32 temp_f4_13;
|
|
|
|
f32 temp_f4_14;
|
|
|
|
f32 temp_f4_4;
|
|
|
|
f32 temp_f4_9;
|
|
|
|
f32 temp_f6;
|
|
|
|
f32 temp_f8;
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 var_f10;
|
|
|
|
f32 var_f16;
|
2023-03-02 02:16:55 +01:00
|
|
|
f32 dz;
|
|
|
|
f32 dx;
|
|
|
|
|
|
|
|
f32 x, y, z;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration = oldConfiguration;
|
2023-03-02 02:16:55 +01:00
|
|
|
controller = *prevController;
|
|
|
|
x = x1;
|
|
|
|
y = y1;
|
|
|
|
z = z1;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if ((s32)controller != CAMERA_SETTINGS_PTR_MINUS_2 && (s32)controller != CAMERA_SETTINGS_PTR_MINUS_1) {
|
|
|
|
if (controller == CAMERA_SETTINGS_PTR_NULL) {
|
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
2023-03-02 02:16:55 +01:00
|
|
|
switch (controller->type) {
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_FIXED_ORIENTATION:
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->flag != 0) {
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 temp_f10 = -(controller->points.two.Az - controller->points.two.Bz) + controller->points.two.Bx;
|
|
|
|
f32 temp_f6 = (controller->points.two.Ax - controller->points.two.Bx) + controller->points.two.Bz;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 temp_f8 = controller->points.two.Bx - temp_f10;
|
|
|
|
f32 temp_f12_2 = controller->points.two.Bz - temp_f6;
|
2023-03-02 02:16:55 +01:00
|
|
|
|
|
|
|
f32 temp_f4 = (SQ(temp_f8) + SQ(temp_f12_2));
|
|
|
|
temp_f4 = (((x - temp_f10) * temp_f8) + ((z - temp_f6) * temp_f12_2)) / temp_f4;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = temp_f4 * temp_f8 + temp_f10;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = temp_f4 * temp_f12_2 + temp_f6;
|
2023-03-02 02:16:55 +01:00
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_CONSTAIN_BETWEEN_POINTS:
|
2023-03-02 02:16:55 +01:00
|
|
|
{
|
|
|
|
f32 ax, az, bx, bz, temp_f8_2, temp_f6_2;
|
|
|
|
f32 f22_1, f4_2, sp10, sp20, f14_1, f12_1;
|
|
|
|
f32 temp_f20, temp_f18;
|
|
|
|
f32 var1, var2;
|
|
|
|
f32 f4_1;
|
|
|
|
f32 var_f16, var_f10, temp_f8_3, temp_f6_3;
|
2023-03-02 09:32:54 +01:00
|
|
|
ax = controller->points.two.Ax;
|
|
|
|
az = controller->points.two.Az;
|
|
|
|
bx = controller->points.two.Bx;
|
|
|
|
bz = controller->points.two.Bz;
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f8_2 = bx - ax;
|
|
|
|
temp_f6_2 = bz - az;
|
|
|
|
var1 = x - ax;
|
|
|
|
var2 = z - az;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
temp_f20 = SQ(temp_f8_2);
|
|
|
|
temp_f18 = SQ(temp_f6_2);
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
f4_1 = temp_f20 + temp_f18;
|
|
|
|
f4_1 = (var1 * temp_f8_2 + var2 * temp_f6_2) / f4_1;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
var_f16 = f4_1 * temp_f8_2 + ax;
|
2023-03-03 02:42:48 +01:00
|
|
|
var_f10 = f4_1 * temp_f6_2 + az;
|
2023-03-02 02:16:55 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
f22_1 = controller->points.two.Ax;
|
|
|
|
f4_2 = controller->points.two.Az;
|
|
|
|
sp10 = controller->points.two.Bx;
|
|
|
|
sp20 = controller->points.two.Bz;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
ax = sp10 - f22_1;
|
|
|
|
az = sp20 - f4_2;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f8_2 = var_f16 - f22_1;
|
|
|
|
temp_f6_2 = var_f10 - f4_2;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f20 = x - var_f16;
|
2023-03-03 02:42:48 +01:00
|
|
|
temp_f18 = z - var_f10;
|
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
if (ax * temp_f8_2 + az * temp_f6_2 < 0.0f) {
|
|
|
|
var_f16 = f22_1;
|
|
|
|
var_f10 = f4_2;
|
|
|
|
} else if (SQ(temp_f8_2) + SQ(temp_f6_2) > SQ(ax) + SQ(az)) {
|
|
|
|
var_f16 = sp10;
|
|
|
|
var_f10 = sp20;
|
|
|
|
}
|
|
|
|
if (controller->flag == 0) {
|
|
|
|
var_f16 += temp_f20;
|
|
|
|
var_f10 += temp_f18;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = var_f16;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = var_f10;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_LOOK_AT_POINT:
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->flag != 0) {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = x - controller->points.two.Ax;
|
|
|
|
dz = z - controller->points.two.Az;
|
|
|
|
f24 = SQ(dx) + SQ(dz);
|
|
|
|
if (f24 != 0.0f) {
|
2023-03-03 02:42:48 +01:00
|
|
|
f24 = 1.0f / sqrtf(f24);
|
2023-03-02 09:32:54 +01:00
|
|
|
temp_f2 = sqrtf(SQ(controller->points.two.Bx - controller->points.two.Ax) + SQ(controller->points.two.Bz - controller->points.two.Az));
|
|
|
|
temp_f2_2 = dx * temp_f2 * f24;
|
|
|
|
temp_f4_4 = dz * temp_f2 * f24;
|
|
|
|
configuration->targetPos.x = controller->points.two.Ax + temp_f2_2;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = controller->points.two.Az + temp_f4_4;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_CONSTRAIN_TO_LINE:
|
|
|
|
case CAM_CONTROL_LOOK_AT_POINT_CONSTAIN_TO_LINE:
|
|
|
|
*prevController = (CameraControlSettings*) CAMERA_SETTINGS_PTR_MINUS_1;
|
2022-08-25 12:18:04 +02:00
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_FOLLOW_PLAYER:
|
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2023-03-02 02:16:55 +01:00
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_FIXED_POS_AND_ORIENTATION:
|
2022-08-25 12:18:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration = newConfiguration;
|
2023-03-02 02:16:55 +01:00
|
|
|
controller = *newController;
|
|
|
|
x = tX;
|
|
|
|
y = tY;
|
|
|
|
z = tZ;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller == NULL) {
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
2023-03-02 02:16:55 +01:00
|
|
|
switch (controller->type) {
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_FIXED_ORIENTATION:
|
|
|
|
dx = controller->points.two.Bx - controller->points.two.Ax;
|
|
|
|
dz = controller->points.two.Bz - controller->points.two.Az;
|
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dx, dz);
|
2023-03-02 02:16:55 +01:00
|
|
|
boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
if (boomLength < 0.0f) {
|
|
|
|
boomLength = -boomLength;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomLength = boomLength;
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
|
|
|
if (controller->flag) {
|
|
|
|
f32 ABx = controller->points.two.Ax - controller->points.two.Bx;
|
|
|
|
f32 ABz = controller->points.two.Az - controller->points.two.Bz;
|
|
|
|
f32 temp_f10 = -ABz + controller->points.two.Bx;
|
|
|
|
f32 temp_f6 = ABx + controller->points.two.Bz;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 temp_f8 = controller->points.two.Bx - temp_f10;
|
|
|
|
f32 temp_f12_2 = controller->points.two.Bz - temp_f6;
|
|
|
|
|
|
|
|
f32 temp_f4 = SQ(temp_f8) + SQ(temp_f12_2);
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f4 = (((x - temp_f10) * temp_f8) + ((z - temp_f6) * temp_f12_2)) / temp_f4;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = temp_f4 * temp_f8 + temp_f10;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = temp_f4 * temp_f12_2 + temp_f6;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (changingZone && *interpAlpha != 1.0f) {
|
|
|
|
prevSettings = *prevController;
|
|
|
|
if (((s32)prevSettings != CAMERA_SETTINGS_PTR_MINUS_2
|
|
|
|
&& (s32)prevSettings != CAMERA_SETTINGS_PTR_MINUS_1
|
|
|
|
&& (s32)prevSettings != CAMERA_SETTINGS_PTR_NULL)
|
|
|
|
&& prevSettings->type == controller->type
|
|
|
|
&& prevSettings->boomLength == controller->boomLength
|
|
|
|
&& prevSettings->boomPitch == controller->boomPitch
|
|
|
|
&& prevSettings->viewPitch == controller->viewPitch
|
|
|
|
&& prevSettings->flag != controller->flag
|
|
|
|
) {
|
|
|
|
*interpAlpha = 1.0f;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_CONSTAIN_BETWEEN_POINTS:
|
|
|
|
dx = controller->points.two.Bx - controller->points.two.Ax;
|
|
|
|
dz = controller->points.two.Bz - controller->points.two.Az;
|
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dz, -dx);
|
2023-03-02 02:16:55 +01:00
|
|
|
boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
if (boomLength < 0.0f) {
|
|
|
|
boomLength = -boomLength;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomLength = boomLength;
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
2023-03-02 02:16:55 +01:00
|
|
|
{
|
|
|
|
f32 ax, az, bx, bz, temp_f8_2, temp_f6_2;
|
|
|
|
f32 f22_1, f4_2, sp10, sp20, f14_1, f12_1;
|
|
|
|
f32 temp_f20, temp_f18;
|
|
|
|
f32 var1, var2;
|
|
|
|
f32 f4_1;
|
|
|
|
f32 var_f16, var_f10, temp_f8_3, temp_f6_3;
|
2023-03-02 09:32:54 +01:00
|
|
|
ax = controller->points.two.Ax;
|
|
|
|
az = controller->points.two.Az;
|
|
|
|
bx = controller->points.two.Bx;
|
|
|
|
bz = controller->points.two.Bz;
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f8_2 = bx - ax;
|
|
|
|
temp_f6_2 = bz - az;
|
|
|
|
var1 = x - ax;
|
|
|
|
var2 = z - az;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f20 = temp_f8_2 * temp_f8_2;
|
|
|
|
temp_f18 = temp_f6_2 * temp_f6_2;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
f4_1 = temp_f20 + temp_f18;
|
|
|
|
f4_1 = (var1 * temp_f8_2 + var2 * temp_f6_2) / f4_1;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
var_f16 = f4_1 * temp_f8_2 + ax;
|
2023-03-03 02:42:48 +01:00
|
|
|
var_f10 = f4_1 * temp_f6_2 + az;
|
2023-03-02 02:16:55 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
f22_1 = controller->points.two.Ax;
|
|
|
|
f4_2 = controller->points.two.Az;
|
|
|
|
sp10 = controller->points.two.Bx;
|
|
|
|
sp20 = controller->points.two.Bz;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
ax = sp10 - f22_1;
|
|
|
|
az = sp20 - f4_2;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f8_2 = var_f16 - f22_1;
|
|
|
|
temp_f6_2 = var_f10 - f4_2;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f20 = x - var_f16;
|
2023-03-03 02:42:48 +01:00
|
|
|
temp_f18 = z - var_f10;
|
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
if (ax * temp_f8_2 + az * temp_f6_2 < 0.0f) {
|
|
|
|
var_f16 = f22_1;
|
|
|
|
var_f10 = f4_2;
|
|
|
|
} else if (SQ(temp_f8_2) + SQ(temp_f6_2) > SQ(ax) + SQ(az)) {
|
|
|
|
var_f16 = sp10;
|
|
|
|
var_f10 = sp20;
|
|
|
|
}
|
|
|
|
if (controller->flag == 0) {
|
|
|
|
var_f16 += temp_f20;
|
|
|
|
var_f10 += temp_f18;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = var_f16;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = var_f10;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
if (changingZone) {
|
|
|
|
if (*interpAlpha != 1.0f) {
|
|
|
|
prevSettings = *prevController;
|
2023-03-02 09:32:54 +01:00
|
|
|
if (((s32)prevSettings != CAMERA_SETTINGS_PTR_MINUS_2
|
|
|
|
&& (s32)prevSettings != CAMERA_SETTINGS_PTR_MINUS_1
|
2023-03-03 02:42:48 +01:00
|
|
|
&& (s32)prevSettings != CAMERA_SETTINGS_PTR_NULL)
|
|
|
|
&& (prevSettings->type == controller->type)
|
|
|
|
&& (prevSettings->boomLength == controller->boomLength)
|
|
|
|
&& (prevSettings->boomPitch == controller->boomPitch)
|
2023-03-02 09:32:54 +01:00
|
|
|
&& (prevSettings->viewPitch == controller->viewPitch)
|
|
|
|
&& (prevSettings->flag != controller->flag)
|
|
|
|
) {
|
2022-08-25 12:18:04 +02:00
|
|
|
*interpAlpha = 1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_LOOK_AT_POINT:
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->boomLength < 0.0f) {
|
|
|
|
// negative boom length means look *away* from point
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = x - controller->points.two.Ax;
|
|
|
|
dz = z - controller->points.two.Az;
|
|
|
|
configuration->boomLength = -controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = controller->points.two.Ax - x;
|
|
|
|
dz = controller->points.two.Az - z;
|
|
|
|
configuration->boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dx, dz);
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->flag != 0) {
|
|
|
|
// constrain to fixed radius
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = x - controller->points.two.Ax;
|
|
|
|
dz = z - controller->points.two.Az;
|
|
|
|
f24 = SQ(dx) + SQ(dz);
|
|
|
|
if (f24 != 0.0f) {
|
|
|
|
f24 = 1.0f / sqrtf(f24);
|
|
|
|
temp_f2_3 = sqrtf(SQ(controller->points.two.Bx - controller->points.two.Ax) + SQ(controller->points.two.Bz - controller->points.two.Az));
|
|
|
|
temp_f2_4 = dx * temp_f2_3 * f24;
|
|
|
|
temp_f4_9 = dz * temp_f2_3 * f24;
|
|
|
|
configuration->targetPos.x = controller->points.two.Ax + temp_f2_4;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = controller->points.two.Az + temp_f4_9;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (changingZone) {
|
|
|
|
if (*interpAlpha != 1.0f) {
|
|
|
|
prevSettings = *prevController;
|
2023-03-02 09:32:54 +01:00
|
|
|
if (((s32)prevSettings != CAMERA_SETTINGS_PTR_MINUS_2
|
|
|
|
&& (s32)prevSettings != CAMERA_SETTINGS_PTR_MINUS_1
|
|
|
|
&& (s32)prevSettings != CAMERA_SETTINGS_PTR_NULL)
|
2023-03-03 02:42:48 +01:00
|
|
|
&& (prevSettings->type == controller->type)
|
|
|
|
&& (prevSettings->boomLength == controller->boomLength)
|
|
|
|
&& (prevSettings->boomPitch == controller->boomPitch)
|
|
|
|
&& (prevSettings->viewPitch == controller->viewPitch)
|
|
|
|
&& (prevSettings->flag != controller->flag)
|
|
|
|
&& (prevSettings->points.two.Ax == controller->points.two.Ax)
|
2023-03-02 09:32:54 +01:00
|
|
|
&& (prevSettings->points.two.Az == controller->points.two.Az)
|
|
|
|
) {
|
2022-08-25 12:18:04 +02:00
|
|
|
*interpAlpha = 1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_CONSTRAIN_TO_LINE:
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->flag == 0) {
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 posAx;
|
|
|
|
f32 posBx;
|
|
|
|
f32 posCx;
|
|
|
|
f32 posCz;
|
|
|
|
f32 posAz;
|
|
|
|
f32 posBz;
|
2023-03-02 02:16:55 +01:00
|
|
|
f32 Tx, Tz;
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
posAx = controller->points.three.Ax;
|
|
|
|
posAz = controller->points.three.Az;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
posBx = controller->points.three.Bx;
|
|
|
|
posBz = controller->points.three.Bz;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
posCx = controller->points.three.Cx;
|
2023-03-03 02:42:48 +01:00
|
|
|
posCz = controller->points.three.Cz;
|
2023-03-02 02:16:55 +01:00
|
|
|
|
|
|
|
if (posAx == posBx && posAz == posBz) {
|
|
|
|
posAx = posCx;
|
|
|
|
posAz = posCz;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
if ((posBx - posCx) == 0.0f) {
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 BAx = posBx - posAx;
|
|
|
|
f32 BCx = posBx - posCx;
|
|
|
|
f32 BCz = posBz - posCz;
|
2023-03-03 02:42:48 +01:00
|
|
|
f32 ABz = posAz - posBz;
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 Q = BCx * BAx / BCz - ABz;
|
|
|
|
f32 V = (x - posBx) + (posBz - z) * BCx / BCz;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
Tx = ABz * V / Q + x;
|
|
|
|
Tz = BAx * V / Q + z;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 BAx = posBx - posAx;
|
|
|
|
f32 ABz = posAz - posBz;
|
|
|
|
f32 BCx = posBx - posCx;
|
|
|
|
f32 BCz = posBz - posCz;
|
|
|
|
f32 Q = ABz * BCz / BCx - BAx;
|
|
|
|
f32 V = (z - posBz) + (posBx - x) * BCz / BCx;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
Tx = ABz * V / Q + x;
|
2023-03-02 02:16:55 +01:00
|
|
|
Tz = BAx * V / Q + z;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = Tx;
|
2023-03-03 02:42:48 +01:00
|
|
|
configuration->targetPos.y = y;
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.z = Tz;
|
2022-08-25 12:18:04 +02:00
|
|
|
|
|
|
|
if (changingMap) {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = controller->points.two.Bx - controller->points.two.Ax;
|
|
|
|
dz = controller->points.two.Bz - controller->points.two.Az;
|
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dx, dz);
|
2023-03-02 02:16:55 +01:00
|
|
|
boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
if (boomLength < 0.0f) {
|
|
|
|
boomLength = -boomLength;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomLength = boomLength;
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (changingMap) {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = controller->points.two.Bx - controller->points.two.Ax;
|
|
|
|
dz = controller->points.two.Bz - controller->points.two.Az;
|
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dx, dz);
|
2023-03-02 02:16:55 +01:00
|
|
|
boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
if (boomLength < 0.0f) {
|
|
|
|
boomLength = -boomLength;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomLength = boomLength;
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
|
|
|
configuration->targetPos.x = controller->points.two.Bx;
|
|
|
|
configuration->targetPos.z = controller->points.two.Bz;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else if (changingZone) {
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = oldConfiguration->targetPos.x;
|
|
|
|
configuration->targetPos.z = oldConfiguration->targetPos.z;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.y = y;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
*prevController = (CameraControlSettings*) CAMERA_SETTINGS_PTR_MINUS_1;
|
2022-08-25 12:18:04 +02:00
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_LOOK_AT_POINT_CONSTAIN_TO_LINE:
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->flag == 0) {
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 var3 = x - controller->points.three.Cx;
|
|
|
|
f32 var4 = z - controller->points.three.Cz;
|
|
|
|
f32 var1 = controller->points.three.Bx - controller->points.three.Cx;
|
|
|
|
f32 var2 = controller->points.three.Bz - controller->points.three.Cz;
|
2023-03-02 02:16:55 +01:00
|
|
|
temp_f4_13 = SQ(var1) + SQ(var2);
|
|
|
|
temp_f4_13 = (var3 * var1 + var4 * var2) / temp_f4_13;
|
2023-03-02 09:32:54 +01:00
|
|
|
temp_f2_7 = temp_f4_13 * var1 + controller->points.three.Cx;
|
|
|
|
temp_f4_14 = temp_f4_13 * var2 + controller->points.three.Cz;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = temp_f2_7;
|
2023-03-03 02:42:48 +01:00
|
|
|
configuration->targetPos.y = y;
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.z = temp_f4_14;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->boomLength < 0.0f) {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = temp_f2_7 - controller->points.three.Ax;
|
|
|
|
dz = temp_f4_14 - controller->points.three.Az;
|
|
|
|
configuration->boomLength = -controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = controller->points.three.Ax - temp_f2_7;
|
|
|
|
dz = controller->points.three.Az - temp_f4_14;
|
|
|
|
configuration->boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dx, dz);
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
|
|
|
if (changingMap) {
|
2023-03-02 02:16:55 +01:00
|
|
|
if (controller->boomLength < 0.0f) {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = controller->points.three.Bx - controller->points.three.Ax;
|
|
|
|
dz = controller->points.three.Bz - controller->points.three.Az;
|
|
|
|
configuration->boomLength = -controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
dx = controller->points.three.Ax - controller->points.three.Bx;
|
|
|
|
dz = controller->points.three.Az - controller->points.three.Bz;
|
|
|
|
configuration->boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dx, dz);
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
|
|
|
configuration->targetPos.x = controller->points.three.Bx;
|
|
|
|
configuration->targetPos.z = controller->points.three.Bz;
|
2022-08-25 12:18:04 +02:00
|
|
|
} else if (changingZone) {
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.x = controller->points.three.Bx;
|
|
|
|
configuration->targetPos.z = controller->points.three.Bz;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->targetPos.y = y;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
*prevController = (CameraControlSettings*) CAMERA_SETTINGS_PTR_MINUS_1;
|
2022-08-25 12:18:04 +02:00
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_FOLLOW_PLAYER:
|
|
|
|
configuration->targetPos.x = x;
|
|
|
|
configuration->targetPos.y = y;
|
|
|
|
configuration->targetPos.z = z;
|
2022-08-25 12:18:04 +02:00
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_FIXED_POS_AND_ORIENTATION:
|
|
|
|
do {
|
|
|
|
dx = controller->points.two.Bx - controller->points.two.Ax;
|
|
|
|
dz = controller->points.two.Bz - controller->points.two.Az;
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomYaw = atan2(0.0f, 0.0f, dx, dz);
|
|
|
|
} while (0);
|
2023-03-02 02:16:55 +01:00
|
|
|
boomLength = controller->boomLength;
|
2022-08-25 12:18:04 +02:00
|
|
|
if (boomLength < 0.0f) {
|
|
|
|
boomLength = -boomLength;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
configuration->boomLength = boomLength;
|
|
|
|
configuration->boomPitch = controller->boomPitch;
|
|
|
|
configuration->viewPitch = controller->viewPitch;
|
|
|
|
configuration->targetPos.x = controller->points.two.Bx;
|
|
|
|
configuration->targetPos.y = controller->points.two.By;
|
|
|
|
configuration->targetPos.z = controller->points.two.Bz;
|
|
|
|
*prevController = (CameraControlSettings*) CAMERA_SETTINGS_PTR_MINUS_2;
|
2022-08-25 12:18:04 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (changingZone
|
|
|
|
&& ((controller->type == CAM_CONTROL_LOOK_AT_POINT_CONSTAIN_TO_LINE) || (oldConfiguration->boomYaw != newConfiguration->boomYaw))
|
|
|
|
&& (fabsf(oldConfiguration->boomYaw - newConfiguration->boomYaw) < 3.0f)
|
|
|
|
&& (fabsf(oldConfiguration->boomLength - newConfiguration->boomLength) < 10.0f)
|
|
|
|
&& (fabsf(oldConfiguration->boomPitch - newConfiguration->boomPitch) < 1.0f)
|
|
|
|
&& (fabsf(oldConfiguration->viewPitch - newConfiguration->viewPitch) < 1.0f)
|
|
|
|
&& (fabsf(oldConfiguration->targetPos.x - newConfiguration->targetPos.x) < 10.0f)
|
|
|
|
&& (fabsf(oldConfiguration->targetPos.y - newConfiguration->targetPos.y) < 10.0f)
|
|
|
|
&& (fabsf(oldConfiguration->targetPos.z - newConfiguration->targetPos.z) < 10.0f)
|
|
|
|
) {
|
2022-08-25 12:18:04 +02:00
|
|
|
*interpAlpha = 1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (*prevController == (CameraControlSettings*) CAMERA_SETTINGS_PTR_MINUS_1) {
|
2022-08-25 12:18:04 +02:00
|
|
|
if (changingZone) {
|
2023-03-02 09:32:54 +01:00
|
|
|
D_800A08E4 = oldConfiguration->targetPos.x - newConfiguration->targetPos.x;
|
|
|
|
D_800A08E8 = oldConfiguration->targetPos.y - newConfiguration->targetPos.y;
|
|
|
|
D_800A08EC = oldConfiguration->targetPos.z - newConfiguration->targetPos.z;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
oldConfiguration->targetPos.x = newConfiguration->targetPos.x + D_800A08E4;
|
|
|
|
oldConfiguration->targetPos.y = newConfiguration->targetPos.y + D_800A08E8;
|
|
|
|
oldConfiguration->targetPos.z = newConfiguration->targetPos.z + D_800A08EC;
|
2022-08-25 12:18:04 +02:00
|
|
|
}
|
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-09-22 13:17:46 +02:00
|
|
|
void update_camera_zone_interp(Camera* camera) {
|
2022-03-28 11:29:47 +02:00
|
|
|
CameraControlSettings* currentController;
|
2021-09-22 13:17:46 +02:00
|
|
|
CameraControlSettings* cs;
|
2022-03-28 11:29:47 +02:00
|
|
|
CameraControlSettings* cs2;
|
2021-09-22 13:17:46 +02:00
|
|
|
f32 targetX;
|
|
|
|
f32 targetY;
|
|
|
|
f32 targetZ;
|
|
|
|
f32 deltaX;
|
|
|
|
f32 deltaY;
|
|
|
|
f32 deltaZ;
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 maxDelta;
|
|
|
|
f32 delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
f32 deltaSqSum;
|
|
|
|
f32 panPhase;
|
|
|
|
f32 temp_f20_2;
|
2022-03-28 11:29:47 +02:00
|
|
|
f32 panRad;
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 cosAngle;
|
|
|
|
f32 sinAngle;
|
2021-09-22 13:17:46 +02:00
|
|
|
f32 temp_f24;
|
|
|
|
f32 temp_f24_2;
|
|
|
|
f32 temp_f26;
|
|
|
|
f32 temp_f4_4;
|
|
|
|
f32 interpAlpha;
|
|
|
|
f32 interpAlphaInv;
|
|
|
|
f32 temp_f8_2;
|
|
|
|
f64 temp_f22_2;
|
|
|
|
s32 cond2;
|
|
|
|
f32 posX;
|
|
|
|
f32 posY;
|
|
|
|
f32 posZ;
|
|
|
|
f32 tX;
|
|
|
|
f32 tY;
|
|
|
|
f32 tZ;
|
|
|
|
s32 changingZone;
|
|
|
|
f32 dist;
|
2023-03-02 09:32:54 +01:00
|
|
|
f32 tempX;
|
|
|
|
f32 tempZ;
|
2021-09-22 13:17:46 +02:00
|
|
|
|
|
|
|
targetX = camera->targetPos.x;
|
|
|
|
targetY = camera->targetPos.y;
|
|
|
|
targetZ = camera->targetPos.z;
|
|
|
|
changingZone = FALSE;
|
|
|
|
|
2022-12-29 06:48:27 +01:00
|
|
|
if (camera->isChangingMap) {
|
2023-07-30 07:08:07 +02:00
|
|
|
camera->curController = NULL;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->prevController = NULL;
|
|
|
|
camera->linearInterp = 0.0f;
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->yinterpGoal = 0.0f;
|
|
|
|
camera->yinterpCur = targetY;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->unk_98 = 0;
|
|
|
|
camera->unk_9C = 0;
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->prevTargetPos.x = 0.0f;
|
|
|
|
camera->prevTargetPos.y = 0.0f;
|
|
|
|
camera->prevTargetPos.z = 0.0f;
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->prevPrevFollowPlayer = FALSE;
|
|
|
|
camera->prevFollowPlayer = FALSE;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->panPhase = 0.0f;
|
|
|
|
D_800A08DC = 0.0f;
|
|
|
|
D_800A08E0 = 0.0f;
|
|
|
|
camera->interpAlpha = 1.0f;
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->yinterpAlpha = 1.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->linearInterpScale = 1.0f;
|
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
tempX = targetX;
|
2022-10-01 03:44:48 +02:00
|
|
|
if (camera->moveFlags & CAMERA_MOVE_IGNORE_PLAYER_Y) {
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->yinterpAlpha = 0.0f;
|
|
|
|
} else if (camera->yinterpGoal != targetY) {
|
|
|
|
camera->yinterpGoal = targetY;
|
|
|
|
camera->yinterpAlpha = 0.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
// always follow player moving down with no interp
|
|
|
|
if (targetY < camera->yinterpGoal && targetY <= camera->yinterpCur) {
|
|
|
|
camera->yinterpGoal = targetY;
|
|
|
|
camera->yinterpAlpha = 1.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->yinterpAlpha += (1.01 - camera->yinterpAlpha) / camera->yinterpRate;
|
2021-09-22 13:17:46 +02:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
if (camera->yinterpAlpha > 1.0) {
|
|
|
|
camera->yinterpAlpha = 1.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-01-12 03:09:13 +01:00
|
|
|
if (camera->moveFlags & CAMERA_MOVE_FLAG_4) {
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->yinterpAlpha += 0.3;
|
|
|
|
if (camera->yinterpAlpha >= 1.0) {
|
|
|
|
camera->yinterpAlpha = 1.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-12 03:09:13 +01:00
|
|
|
if (!(camera->moveFlags & CAMERA_MOVE_FLAG_2)) {
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->yinterpCur += (camera->yinterpGoal - camera->yinterpCur) * camera->yinterpAlpha;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
tempZ = targetZ;
|
|
|
|
if (camera->panActive
|
|
|
|
|| camera->prevTargetPos.x != targetX
|
|
|
|
|| camera->prevTargetPos.y != targetY
|
|
|
|
|| camera->prevTargetPos.z != targetZ
|
|
|
|
|| camera->isChangingMap
|
|
|
|
) {
|
2021-09-22 13:17:46 +02:00
|
|
|
|
|
|
|
if (camera->followPlayer) {
|
|
|
|
cs = &camera->controlSettings;
|
|
|
|
} else {
|
|
|
|
cs = test_ray_zone_aabb(targetX, targetY + 10.0f, targetZ);
|
|
|
|
}
|
|
|
|
|
|
|
|
cond2 = FALSE;
|
2022-03-28 11:29:47 +02:00
|
|
|
cs2 = cs;
|
2023-07-30 07:08:07 +02:00
|
|
|
currentController = camera->curController;
|
2023-03-02 09:32:54 +01:00
|
|
|
if (cs != NULL
|
|
|
|
&& currentController != NULL
|
|
|
|
&& cs->type == currentController->type
|
|
|
|
&& cs->flag == currentController->flag
|
|
|
|
&& cs->boomLength == currentController->boomLength
|
|
|
|
&& cs->boomPitch == currentController->boomPitch
|
|
|
|
&& cs->viewPitch == currentController->viewPitch
|
|
|
|
) {
|
2021-09-22 13:17:46 +02:00
|
|
|
switch (cs->type) {
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_FIXED_ORIENTATION:
|
|
|
|
if (cs->points.two.Ax == currentController->points.two.Ax
|
|
|
|
&& cs->points.two.Az == currentController->points.two.Az
|
|
|
|
&& cs->points.two.Bx == currentController->points.two.Bx
|
|
|
|
&& cs->points.two.Bz == currentController->points.two.Bz
|
|
|
|
) {
|
2021-09-22 13:17:46 +02:00
|
|
|
cond2 = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2023-03-02 09:32:54 +01:00
|
|
|
case CAM_CONTROL_LOOK_AT_POINT:
|
2022-03-28 11:29:47 +02:00
|
|
|
switch (cs->flag){
|
|
|
|
case 0:
|
2023-03-02 09:32:54 +01:00
|
|
|
if (cs->points.two.Ax == currentController->points.two.Ax
|
|
|
|
&& cs->points.two.Az == currentController->points.two.Az
|
|
|
|
) {
|
2022-03-28 11:29:47 +02:00
|
|
|
cond2 = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
2023-03-02 09:32:54 +01:00
|
|
|
if (cs->points.two.Ax == currentController->points.two.Ax
|
|
|
|
&& cs->points.two.Az == currentController->points.two.Az
|
|
|
|
&& cs->points.two.Bx == currentController->points.two.Bx
|
|
|
|
&& cs->points.two.Bz == currentController->points.two.Bz
|
|
|
|
) {
|
2022-03-28 11:29:47 +02:00
|
|
|
cond2 = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2023-03-03 02:42:48 +01:00
|
|
|
if (cs2->points.two.Ax == currentController->points.two.Ax
|
|
|
|
&& cs2->points.two.Az == currentController->points.two.Az
|
|
|
|
&& cs2->points.two.Ay == currentController->points.two.Ay
|
|
|
|
&& cs2->points.two.By == currentController->points.two.By
|
|
|
|
&& cs2->points.two.Bx == currentController->points.two.Bx
|
2023-03-02 09:32:54 +01:00
|
|
|
&& cs2->points.two.Bz == currentController->points.two.Bz
|
|
|
|
) {
|
2021-09-22 13:17:46 +02:00
|
|
|
cond2 = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-04 02:56:24 +02:00
|
|
|
if (camera->panActive || (!cond2 && cs2 != currentController)) {
|
2021-09-22 13:17:46 +02:00
|
|
|
if (camera->interpAlpha == 1.0f) {
|
2023-07-30 07:08:07 +02:00
|
|
|
camera->prevController = camera->curController;
|
2021-09-22 13:17:46 +02:00
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->prevController = (CameraControlSettings*) CAMERA_SETTINGS_PTR_MINUS_1;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
changingZone = TRUE;
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->prevConfiguration = gCurrentCamConfiguration;
|
2023-07-30 07:08:07 +02:00
|
|
|
camera->curController = cs;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->interpAlpha = 0.0f;
|
|
|
|
camera->linearInterp = 0.0f;
|
2022-10-04 02:56:24 +02:00
|
|
|
camera->panActive = FALSE;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->linearInterpScale = camera->moveSpeed;
|
2023-10-14 21:43:12 +02:00
|
|
|
camera->prevPrevFollowPlayer = camera->prevFollowPlayer;
|
|
|
|
camera->prevFollowPlayer = camera->followPlayer;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->prevPrevMovePos.x = camera->prevMovePos.x;
|
|
|
|
camera->prevPrevMovePos.y = camera->prevMovePos.y;
|
|
|
|
camera->prevPrevMovePos.z = camera->prevMovePos.z;
|
|
|
|
camera->prevMovePos.x = camera->movePos.x;
|
|
|
|
camera->prevMovePos.y = camera->movePos.y;
|
|
|
|
camera->prevMovePos.z = camera->movePos.z;
|
|
|
|
}
|
|
|
|
}
|
2023-03-03 02:42:48 +01:00
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
if (camera->prevPrevFollowPlayer) {
|
2021-09-22 13:17:46 +02:00
|
|
|
posX = camera->prevPrevMovePos.x;
|
|
|
|
posY = camera->prevPrevMovePos.y;
|
|
|
|
posZ = camera->prevPrevMovePos.z;
|
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
posX = tempX;
|
2023-10-14 21:43:12 +02:00
|
|
|
posY = camera->yinterpCur;
|
2023-03-02 09:32:54 +01:00
|
|
|
posZ = tempZ;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-10-14 21:43:12 +02:00
|
|
|
if (camera->prevFollowPlayer) {
|
|
|
|
camera->yinterpCur = camera->prevMovePos.y;
|
2021-09-22 13:17:46 +02:00
|
|
|
tX = camera->prevMovePos.x;
|
2023-10-14 21:43:12 +02:00
|
|
|
tY = camera->yinterpCur;
|
2021-09-22 13:17:46 +02:00
|
|
|
tZ = camera->prevMovePos.z;
|
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
tX = tempX;
|
2023-10-14 21:43:12 +02:00
|
|
|
tY = camera->yinterpCur;
|
2023-03-02 09:32:54 +01:00
|
|
|
tZ = tempZ;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
update_camera_from_controller(camera, &camera->prevConfiguration, &camera->prevController,
|
2023-07-30 07:08:07 +02:00
|
|
|
&camera->goalConfiguration, &camera->curController, posX, posY, posZ, tX, tY, tZ,
|
2022-12-29 06:48:27 +01:00
|
|
|
camera->isChangingMap, &camera->interpAlpha, changingZone);
|
2021-09-22 13:17:46 +02:00
|
|
|
|
2022-12-29 06:48:27 +01:00
|
|
|
if (camera->isChangingMap) {
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->prevConfiguration = camera->goalConfiguration;
|
2022-12-29 06:48:27 +01:00
|
|
|
camera->isChangingMap = FALSE;
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->interpAlpha = 1.0f;
|
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (camera->prevConfiguration.boomYaw - camera->goalConfiguration.boomYaw > 180.0f) {
|
|
|
|
camera->prevConfiguration.boomYaw -= 360.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (camera->prevConfiguration.boomYaw - camera->goalConfiguration.boomYaw < -180.0f) {
|
|
|
|
camera->prevConfiguration.boomYaw += 360.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
delta = camera->prevConfiguration.boomYaw - camera->goalConfiguration.boomYaw;
|
|
|
|
if (delta < 0.0f) {
|
|
|
|
delta = -delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (delta > 180.0f) {
|
|
|
|
delta = 360.0f - delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
maxDelta = delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
delta = camera->prevConfiguration.boomPitch - camera->goalConfiguration.boomPitch;
|
|
|
|
if (delta < 0.0f) {
|
|
|
|
delta = -delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (delta > 180.0f) {
|
|
|
|
delta = 360.0f - delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (maxDelta < delta) {
|
|
|
|
maxDelta = delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
delta = camera->prevConfiguration.viewPitch - camera->goalConfiguration.viewPitch;
|
|
|
|
if (delta < 0.0f) {
|
|
|
|
delta = -delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (delta > 180.0f) {
|
|
|
|
delta = 360.0f - delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (maxDelta < delta) {
|
|
|
|
maxDelta = delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
delta = camera->prevConfiguration.boomLength - camera->goalConfiguration.boomLength;
|
|
|
|
if (delta < 0.0f) {
|
|
|
|
delta = -delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (maxDelta < delta) {
|
|
|
|
maxDelta = delta;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
deltaX = camera->prevConfiguration.targetPos.x - camera->goalConfiguration.targetPos.x;
|
|
|
|
deltaY = camera->prevConfiguration.targetPos.y - camera->goalConfiguration.targetPos.y;
|
|
|
|
deltaZ = camera->prevConfiguration.targetPos.z - camera->goalConfiguration.targetPos.z;
|
|
|
|
delta = SQ(deltaX);
|
|
|
|
delta += SQ(deltaY);
|
|
|
|
delta += SQ(deltaZ);
|
2021-09-22 13:17:46 +02:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (delta != 0.0f) {
|
|
|
|
delta = sqrtf(delta) * 0.2;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (maxDelta < delta) {
|
|
|
|
maxDelta = delta;
|
|
|
|
delta++;
|
|
|
|
delta--;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (maxDelta > 90.0f) {
|
|
|
|
maxDelta = 90.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
if (maxDelta < 20.0f) {
|
|
|
|
maxDelta = 20.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (maxDelta != 0.0f) {
|
|
|
|
camera->linearInterp += (1.0f / maxDelta) * camera->linearInterpScale;
|
2021-09-22 13:17:46 +02:00
|
|
|
if (camera->linearInterp > 1.0f) {
|
|
|
|
camera->linearInterp = 1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (camera->interpAlpha < 1.0) {
|
|
|
|
panPhase = camera->panPhase;
|
2022-03-28 11:29:47 +02:00
|
|
|
panRad = panPhase * PI_D;
|
|
|
|
temp_f24 = 2.0f / (cos_rad(panRad) + 1.0f);
|
|
|
|
temp_f22_2 = cos_rad((camera->linearInterp * PI_D * (1.0f - panPhase)) + panRad);
|
2023-03-02 09:32:54 +01:00
|
|
|
cosAngle = (temp_f22_2 + (1.0 - cos_rad(panRad)) * 0.5) * temp_f24;
|
|
|
|
cosAngle = (2.0f - (cosAngle + 1.0f)) * 0.5001;
|
|
|
|
camera->interpAlpha = cosAngle;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (camera->interpAlpha >= 1.0f) {
|
|
|
|
camera->interpAlpha = 1.0f;
|
|
|
|
camera->linearInterp = 0.0f;
|
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->prevTargetPos.x = targetX;
|
|
|
|
camera->prevTargetPos.y = targetY;
|
|
|
|
camera->prevTargetPos.z = targetZ;
|
|
|
|
|
2021-09-22 13:17:46 +02:00
|
|
|
interpAlpha = camera->interpAlpha;
|
|
|
|
interpAlphaInv = 1.0f - interpAlpha;
|
2023-03-02 09:32:54 +01:00
|
|
|
gCurrentCamConfiguration.boomYaw = (camera->prevConfiguration.boomYaw * interpAlphaInv) + (camera->goalConfiguration.boomYaw * interpAlpha);
|
|
|
|
gCurrentCamConfiguration.boomLength = (camera->prevConfiguration.boomLength * interpAlphaInv) + (camera->goalConfiguration.boomLength * interpAlpha);
|
|
|
|
gCurrentCamConfiguration.boomPitch = (camera->prevConfiguration.boomPitch * interpAlphaInv) + (camera->goalConfiguration.boomPitch * interpAlpha);
|
|
|
|
gCurrentCamConfiguration.viewPitch = (camera->prevConfiguration.viewPitch * interpAlphaInv) + (camera->goalConfiguration.viewPitch * interpAlpha);
|
|
|
|
gCurrentCamConfiguration.targetPos.x = (camera->prevConfiguration.targetPos.x * interpAlphaInv) + (camera->goalConfiguration.targetPos.x * interpAlpha);
|
|
|
|
gCurrentCamConfiguration.targetPos.y = (camera->prevConfiguration.targetPos.y * interpAlphaInv) + (camera->goalConfiguration.targetPos.y * interpAlpha);
|
|
|
|
gCurrentCamConfiguration.targetPos.z = (camera->prevConfiguration.targetPos.z * interpAlphaInv) + (camera->goalConfiguration.targetPos.z * interpAlpha);
|
|
|
|
gCurrentCamConfiguration.boomLength *= camera->zoomPercent;
|
|
|
|
gCurrentCamConfiguration.boomLength *= 0.01;
|
2021-09-22 13:17:46 +02:00
|
|
|
|
|
|
|
func_80030450(camera);
|
2023-03-02 09:32:54 +01:00
|
|
|
temp_f20_2 = gCurrentCamConfiguration.boomYaw + D_800A08E0;
|
2021-09-22 13:17:46 +02:00
|
|
|
temp_f26 = sin_deg(temp_f20_2);
|
|
|
|
temp_f24_2 = -cos_deg(temp_f20_2);
|
2023-03-02 09:32:54 +01:00
|
|
|
cosAngle = cos_deg(gCurrentCamConfiguration.boomPitch + D_800A08DC);
|
|
|
|
sinAngle = sin_deg(gCurrentCamConfiguration.boomPitch + D_800A08DC);
|
2021-09-22 13:17:46 +02:00
|
|
|
|
2023-01-12 03:09:13 +01:00
|
|
|
if (!(camera->moveFlags & CAMERA_MOVE_FLAG_2)) {
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->lookAt_eye.y = gCurrentCamConfiguration.targetPos.y + (gCurrentCamConfiguration.boomLength * sinAngle);
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->lookAt_eye.x = gCurrentCamConfiguration.targetPos.x - (temp_f26 * gCurrentCamConfiguration.boomLength * cosAngle);
|
|
|
|
camera->lookAt_eye.z = gCurrentCamConfiguration.targetPos.z - (temp_f24_2 * gCurrentCamConfiguration.boomLength * cosAngle);
|
|
|
|
cosAngle = cos_deg(-gCurrentCamConfiguration.viewPitch);
|
|
|
|
sinAngle = sin_deg(-gCurrentCamConfiguration.viewPitch);
|
2021-09-22 13:17:46 +02:00
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
if (camera->lookAt_eye.x == gCurrentCamConfiguration.targetPos.x && camera->lookAt_eye.z == gCurrentCamConfiguration.targetPos.z) {
|
2021-09-22 13:17:46 +02:00
|
|
|
dist = 0.0f;
|
|
|
|
} else {
|
2023-03-02 09:32:54 +01:00
|
|
|
dist = dist2D(camera->lookAt_eye.x, camera->lookAt_eye.z, gCurrentCamConfiguration.targetPos.x, gCurrentCamConfiguration.targetPos.z);
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
|
|
|
|
2023-03-02 09:32:54 +01:00
|
|
|
temp_f8_2 = gCurrentCamConfiguration.targetPos.y - camera->lookAt_eye.y;
|
2023-01-12 03:09:13 +01:00
|
|
|
if (!(camera->moveFlags & CAMERA_MOVE_FLAG_2)) {
|
2023-03-02 09:32:54 +01:00
|
|
|
camera->lookAt_obj.y = camera->lookAt_eye.y + ((dist * sinAngle) + (temp_f8_2 * cosAngle));
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|
2023-03-02 09:32:54 +01:00
|
|
|
temp_f4_4 = (dist * cosAngle) - (temp_f8_2 * sinAngle);
|
2021-09-22 13:17:46 +02:00
|
|
|
camera->lookAt_obj.x = camera->lookAt_eye.x + (temp_f26 * temp_f4_4);
|
|
|
|
camera->lookAt_obj.z = camera->lookAt_eye.z + (temp_f24_2 * temp_f4_4);
|
2023-07-30 07:08:07 +02:00
|
|
|
camera->curYaw = gCurrentCamConfiguration.boomYaw + D_800A08E0;
|
|
|
|
camera->trueRot.x = camera->curYaw;
|
|
|
|
camera->curBoomLength = gCurrentCamConfiguration.boomLength;
|
|
|
|
camera->curBlendedYawNegated = -gCurrentCamConfiguration.boomYaw;
|
|
|
|
camera->curPitch = -gCurrentCamConfiguration.boomPitch - gCurrentCamConfiguration.viewPitch;
|
2022-10-01 03:44:48 +02:00
|
|
|
camera->lookAt_obj_target.x = camera->lookAt_obj.x;
|
|
|
|
camera->lookAt_obj_target.y = camera->lookAt_obj.y;
|
|
|
|
camera->lookAt_obj_target.z = camera->lookAt_obj.z;
|
2023-07-30 07:08:07 +02:00
|
|
|
camera->curYOffset = 0.0f;
|
2021-09-22 13:17:46 +02:00
|
|
|
}
|