Fix crash in move_into_c_up()
This commit is contained in:
parent
ca54f774ab
commit
c5a4c46519
|
@ -2750,20 +2750,21 @@ void move_into_c_up(struct Camera *c) {
|
|||
if (!c) { return; }
|
||||
struct LinearTransitionPoint *start = &sModeInfo.transitionStart;
|
||||
struct LinearTransitionPoint *end = &sModeInfo.transitionEnd;
|
||||
s16 modInfoMax = MAX(sModeInfo.frame, 1);
|
||||
|
||||
f32 dist = end->dist - start->dist;
|
||||
s16 pitch = end->pitch - start->pitch;
|
||||
s16 yaw = end->yaw - start->yaw;
|
||||
|
||||
// Linearly interpolate from start to end position's polar coordinates
|
||||
dist = start->dist + dist * sModeInfo.frame / sModeInfo.max;
|
||||
pitch = start->pitch + pitch * sModeInfo.frame / sModeInfo.max;
|
||||
yaw = start->yaw + yaw * sModeInfo.frame / sModeInfo.max;
|
||||
dist = start->dist + dist * sModeInfo.frame / modInfoMax;
|
||||
pitch = start->pitch + pitch * sModeInfo.frame / modInfoMax;
|
||||
yaw = start->yaw + yaw * sModeInfo.frame / modInfoMax;
|
||||
|
||||
// Linearly interpolate the focus from start to end
|
||||
c->focus[0] = start->focus[0] + (end->focus[0] - start->focus[0]) * sModeInfo.frame / sModeInfo.max;
|
||||
c->focus[1] = start->focus[1] + (end->focus[1] - start->focus[1]) * sModeInfo.frame / sModeInfo.max;
|
||||
c->focus[2] = start->focus[2] + (end->focus[2] - start->focus[2]) * sModeInfo.frame / sModeInfo.max;
|
||||
c->focus[0] = start->focus[0] + (end->focus[0] - start->focus[0]) * sModeInfo.frame / modInfoMax;
|
||||
c->focus[1] = start->focus[1] + (end->focus[1] - start->focus[1]) * sModeInfo.frame / modInfoMax;
|
||||
c->focus[2] = start->focus[2] + (end->focus[2] - start->focus[2]) * sModeInfo.frame / modInfoMax;
|
||||
|
||||
vec3f_add(c->focus, sMarioCamState->pos);
|
||||
vec3f_set_dist_and_angle(c->focus, c->pos, dist, pitch, yaw);
|
||||
|
@ -2772,7 +2773,7 @@ void move_into_c_up(struct Camera *c) {
|
|||
sMarioCamState->headRotation[1] = 0;
|
||||
|
||||
// Finished zooming in
|
||||
if (++sModeInfo.frame == sModeInfo.max) {
|
||||
if (++sModeInfo.frame >= modInfoMax) {
|
||||
gCameraMovementFlags &= ~CAM_MOVING_INTO_MODE;
|
||||
}
|
||||
}
|
||||
|
@ -2965,7 +2966,7 @@ void set_camera_mode(struct Camera *c, s16 mode, s16 frames) {
|
|||
|
||||
sModeInfo.newMode = (mode != -1) ? mode : sModeInfo.lastMode;
|
||||
sModeInfo.lastMode = c->mode;
|
||||
sModeInfo.max = frames;
|
||||
sModeInfo.max = MAX(frames, 1);
|
||||
sModeInfo.frame = 1;
|
||||
|
||||
c->mode = sModeInfo.newMode;
|
||||
|
|
Loading…
Reference in New Issue