12 f32 hitDepth = 32767.0f;
14 s32 zoneID =
test_ray_zones(x, y, z, 0.0f, -1.0f, 0.0f, &hitX, &hitY, &hitZ, &hitDepth, &nx, &ny, &nz);
31 f32 Ax = controller->
points.two.Ax;
32 f32 Az = controller->
points.two.Az;
33 f32 Bx = controller->
points.two.Bx;
34 f32 Bz = controller->
points.two.Bz;
39 if (controller->
flag) {
40 f32 perpdot = ABx * (z - Bz) - ABz * (x - Bx);
41 f32 dist2 =
SQ(ABx) +
SQ(ABz);
44 configuration->
targetPos.
x = Bx - ABz * (perpdot / dist2);
46 configuration->
targetPos.
z = Bz + ABx * (perpdot / dist2);
58 f32 x1, f32 y1, f32 z1,
59 f32 x2, f32 y2, f32 z2,
60 f32* interpAlpha,
b32 changingMap,
b32 changingZone)
69 curSettings = *prevSettingsPtr;
80 switch (curSettings->
type) {
89 if (curSettings->
flag) {
90 f32 Ax = curSettings->
points.two.Ax;
91 f32 Az = curSettings->
points.two.Az;
92 f32 Bx = curSettings->
points.two.Bx;
93 f32 Bz = curSettings->
points.two.Bz;
98 f32 perpdot = ABx * (z - Bz) - ABz * (x - Bx);
99 f32 dist2 =
SQ(ABx) +
SQ(ABz);
102 curRig->
targetPos.
x = Bx - ABz * (perpdot / dist2);
104 curRig->
targetPos.
z = Bz + ABx * (perpdot / dist2);
113 f32 Ax = curSettings->
points.two.Ax;
114 f32 Az = curSettings->
points.two.Az;
115 f32 Bx = curSettings->
points.two.Bx;
116 f32 Bz = curSettings->
points.two.Bz;
122 f32 t = (ABx * (x - Ax) + ABz * (z - Az)) / (
SQ(ABx) +
SQ(ABz));
123 f32 Px = Ax + t * ABx;
124 f32 Pz = Az + t * ABz;
134 }
else if (t > 1.0f) {
138 if (!curSettings->
flag) {
149 if (curSettings->
flag) {
150 f32 Ax = curSettings->
points.two.Ax;
151 f32 Az = curSettings->
points.two.Az;
152 f32 Bx = curSettings->
points.two.Bx;
153 f32 Bz = curSettings->
points.two.Bz;
157 f32 camRadius =
sqrtf(
SQ(ABx) +
SQ(ABz));
164 if (curRadius != 0.0f) {
166 curRig->
targetPos.
x = Ax + dx * (camRadius / curRadius);
168 curRig->
targetPos.
z = Az + dz * (camRadius / curRadius);
185 curSettings = *curSettingsPtr;
190 if (curSettings == NULL) {
195 switch (curSettings->
type) {
203 f32 Ax = curSettings->
points.two.Ax;
204 f32 Az = curSettings->
points.two.Az;
205 f32 Bx = curSettings->
points.two.Bx;
206 f32 By = curSettings->
points.two.By;
207 f32 Bz = curSettings->
points.two.Bz;
223 dx = curSettings->
points.two.Bx - curSettings->
points.two.Ax;
224 dz = curSettings->
points.two.Bz - curSettings->
points.two.Az;
230 if (curSettings->
flag) {
231 f32 Ax = curSettings->
points.two.Ax;
232 f32 Az = curSettings->
points.two.Az;
233 f32 Bx = curSettings->
points.two.Bx;
234 f32 Bz = curSettings->
points.two.Bz;
239 f32 perpdot = ABx * (z - Bz) - ABz * (x - Bx);
240 f32 dist2 =
SQ(ABx) +
SQ(ABz);
243 curRig->
targetPos.
x = Bx - ABz * (perpdot / dist2);
245 curRig->
targetPos.
z = Bz + ABx * (perpdot / dist2);
253 if (*interpAlpha != 1.0f) {
254 prevSettings = *prevSettingsPtr;
258 && prevSettings->
type == curSettings->
type
262 && prevSettings->
flag != curSettings->
flag
271 f32 Ax = curSettings->
points.two.Ax;
272 f32 Az = curSettings->
points.two.Az;
273 f32 Bx = curSettings->
points.two.Bx;
274 f32 Bz = curSettings->
points.two.Bz;
285 f32 t = (ABx * (x - Ax) + ABz * (z - Az)) / (
SQ(ABx) +
SQ(ABz));
286 f32 Px = Ax + t * ABx;
287 f32 Pz = Az + t * ABz;
297 }
else if (t > 1.0f) {
301 if (!curSettings->
flag) {
311 if (*interpAlpha != 1.0f) {
312 prevSettings = *prevSettingsPtr;
316 && (prevSettings->
type == curSettings->
type)
320 && (prevSettings->
flag != curSettings->
flag)
330 f32 Ax = curSettings->
points.two.Ax;
331 f32 Az = curSettings->
points.two.Az;
332 f32 Bx = curSettings->
points.two.Bx;
333 f32 Bz = curSettings->
points.two.Bz;
337 f32 camRadius =
sqrtf(
SQ(ABx) +
SQ(ABz));
338 f32 curRadius, dx, dz;
354 if (curSettings->
flag) {
360 if (curRadius != 0.0f) {
362 curRig->
targetPos.
x = Ax + dx * (camRadius / curRadius);
364 curRig->
targetPos.
z = Az + dz * (camRadius / curRadius);
373 if (*interpAlpha != 1.0f) {
374 prevSettings = *prevSettingsPtr;
378 && (prevSettings->
type == curSettings->
type)
382 && (prevSettings->
flag != curSettings->
flag)
383 && (prevSettings->
points.two.Ax == curSettings->
points.two.Ax)
384 && (prevSettings->
points.two.Az == curSettings->
points.two.Az)
394 f32 Ax = curSettings->
points.three.Ax;
395 f32 Az = curSettings->
points.three.Az;
396 f32 Bx = curSettings->
points.three.Bx;
397 f32 Bz = curSettings->
points.three.Bz;
398 f32 Cx = curSettings->
points.three.Cx;
399 f32 Cz = curSettings->
points.three.Cz;
401 if (!curSettings->
flag) {
404 if (Ax == Bx && Az == Bz) {
415 f32 Q = CBx * ABx / CBz + BAz;
416 f32 V = (x - Bx) - (z - Bz) * CBx / CBz;
418 Tx = x - BAz * V / Q;
419 Tz = z + ABx * V / Q;
421 f32 Q = BAz * CBz / CBx + ABx;
422 f32 V = (z - Bz) - (x - Bx) * CBz / CBx;
424 Tx = x + BAz * V / Q;
425 Tz = z + ABx * V / Q;
451 }
else if (changingZone) {
463 f32 Ax = curSettings->
points.three.Ax;
464 f32 Az = curSettings->
points.three.Az;
465 f32 Bx = curSettings->
points.three.Bx;
466 f32 Bz = curSettings->
points.three.Bz;
467 f32 Cx = curSettings->
points.three.Cx;
468 f32 Cz = curSettings->
points.three.Cz;
470 if (!curSettings->
flag) {
473 f32 dist2 =
SQ(CBx) +
SQ(CBz);
474 dist2 = (CBx * (x - Cx) + CBz * (z - Cz)) / dist2;
475 f32 Px = Cx + dist2 * CBx;
476 f32 Pz = Cz + dist2 * CBz;
511 }
else if (changingZone) {
557 if (targetY < camera->yinterpGoal && targetY <= camera->yinterpCur) {
584 f32 deltaX, deltaY, deltaZ;
587 if (curDelta > 180.0f) {
588 curDelta = 360.0f - curDelta;
593 if (curDelta > 180.0f) {
594 curDelta = 360.0f - curDelta;
596 if (maxDelta < curDelta) {
601 if (curDelta > 180.0f) {
602 curDelta = 360.0f - curDelta;
604 if (maxDelta < curDelta) {
609 if (maxDelta < curDelta) {
616 curDelta =
SQ(deltaX) +
SQ(deltaY) +
SQ(deltaZ);
617 if (curDelta != 0.0f) {
619 curDelta =
sqrtf(curDelta) * 0.2;
621 if (maxDelta < curDelta) {
626 if (maxDelta > 90.0f) {
629 if (maxDelta < 20.0f) {
659 f32 dr =
SQ(dx) +
SQ(dz);
666 f32 projectedRadius = (dy * sinViewPitch) + (dr * cosViewPitch);
707 changingZone = FALSE;
745 allParamsMatch = FALSE;
747 if (nextSettings != NULL
748 && curSettings != NULL
749 && nextSettings->
type == curSettings->
type
750 && nextSettings->
flag == curSettings->
flag
755 switch (nextSettings->
type) {
757 if (nextSettings->
points.two.Ax == curSettings->
points.two.Ax
758 && nextSettings->
points.two.Az == curSettings->
points.two.Az
759 && nextSettings->
points.two.Bx == curSettings->
points.two.Bx
760 && nextSettings->
points.two.Bz == curSettings->
points.two.Bz
762 allParamsMatch = TRUE;
766 if (nextSettings->
flag) {
767 if (nextSettings->
points.two.Ax == curSettings->
points.two.Ax
768 && nextSettings->
points.two.Az == curSettings->
points.two.Az
769 && nextSettings->
points.two.Bx == curSettings->
points.two.Bx
770 && nextSettings->
points.two.Bz == curSettings->
points.two.Bz
772 allParamsMatch = TRUE;
775 if (nextSettings->
points.two.Ax == curSettings->
points.two.Ax
776 && nextSettings->
points.two.Az == curSettings->
points.two.Az
778 allParamsMatch = TRUE;
783 if (nextSettings->
points.two.Ax == curSettings->
points.two.Ax
784 && nextSettings->
points.two.Az == curSettings->
points.two.Az
785 && nextSettings->
points.two.Ay == curSettings->
points.two.Ay
786 && nextSettings->
points.two.By == curSettings->
points.two.By
787 && nextSettings->
points.two.Bx == curSettings->
points.two.Bx
788 && nextSettings->
points.two.Bz == curSettings->
points.two.Bz
790 allParamsMatch = TRUE;
796 if (camera->
panActive || (nextSettings != curSettings && !allParamsMatch)) {
858 posX, posY, posZ, tX, tY, tZ,
890 f32 minusCos = (1.0f -
cos_rad(
PI_D * phi)) * 0.5f;
892 f32 beta =
cos_rad(
PI_D * (alpha * (1.0f - phi) + phi));
893 f32 gamma = (beta + minusCos) / plusCos;
905 #define CAM_INTERP(field) CurrentCamRig.field = \
906 (camera->prevRig.field * (1.0f - camera->interpAlpha)) + (camera->nextRig.field * camera->interpAlpha)
void interp_camera_y_position(Camera *camera, f32 targetY)
BSS CameraRig CurrentCamRig
void update_camera_zone_interp(Camera *camera)
f32 get_maximum_interp_delta(Camera *camera)
@ CAMERA_SETTINGS_PTR_MINUS_1
@ CAMERA_SETTINGS_PTR_MINUS_2
@ CAMERA_SETTINGS_PTR_NULL
void update_camera_from_controller(Camera *camera, CameraRig *prevRig, CameraControlSettings **prevSettingsPtr, CameraRig *newRig, CameraControlSettings **curSettingsPtr, f32 x1, f32 y1, f32 z1, f32 x2, f32 y2, f32 z2, f32 *interpAlpha, b32 changingMap, b32 changingZone)
CameraControlSettings * test_ray_zone_aabb(f32 x, f32 y, f32 z)
void set_camera_from_rig(Camera *camera, CameraRig *rig)
void apply_fixed_orientation(CameraControlSettings *controller, CameraRig *configuration, f32 x, f32 y, f32 z)
#define CAM_INTERP(field)
union CameraControlSettings::@14 points
@ CAM_CONTROL_FIXED_ORIENTATION
@ CAM_CONTROL_FIXED_POS_AND_ORIENTATION
@ CAM_CONTROL_CONSTRAIN_TO_LINE
@ CAM_CONTROL_FOLLOW_PLAYER
@ CAM_CONTROL_CONSTAIN_BETWEEN_POINTS
@ CAM_CONTROL_LOOK_AT_POINT
@ CAM_CONTROL_LOOK_AT_POINT_CONSTAIN_TO_LINE
@ CAMERA_MOVE_IGNORE_PLAYER_Y
@ CAMERA_MOVE_ACCEL_INTERP_Y
@ CAMERA_MOVE_NO_INTERP_Y
s32 test_ray_zones(f32 startX, f32 startY, f32 startZ, f32 dirX, f32 dirY, f32 dirZ, f32 *hitX, f32 *hitY, f32 *hitZ, f32 *hitDepth, f32 *nx, f32 *ny, f32 *nz)
CameraControlSettings * curSettings
f32 interpEasingParameter
CameraControlSettings * prevSettings
CameraControlSettings overrideSettings
CollisionData gZoneCollisionData