mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fix camera reset bug (#499)
* Move camera down if hanging with romhack camera * Fix camera reset bug From issue #494 * Isaac's suggestions
This commit is contained in:
parent
693a77078d
commit
eb6183e87a
2 changed files with 104 additions and 97 deletions
|
|
@ -122,26 +122,28 @@ s16 newcam_saved_defmode = -1;
|
||||||
extern bool gDjuiInMainMenu;
|
extern bool gDjuiInMainMenu;
|
||||||
|
|
||||||
///This is called at every level initialisation.
|
///This is called at every level initialisation.
|
||||||
void newcam_init(struct Camera *c, UNUSED u8 dv) {
|
void newcam_init(struct Camera *c, u8 isSoftReset) {
|
||||||
newcam_tilt = 1500;
|
newcam_tilt = 1500;
|
||||||
newcam_yaw = -c->yaw+0x4000; //Mario and the camera's yaw have this offset between them.
|
newcam_yaw = -c->yaw+0x4000; //Mario and the camera's yaw have this offset between them.
|
||||||
newcam_mode = NC_MODE_NORMAL;
|
newcam_mode = NC_MODE_NORMAL;
|
||||||
///This here will dictate what modes the camera will start in at the beginning of a level. Below are some examples.
|
///This here will dictate what modes the camera will start in at the beginning of a level. Below are some examples.
|
||||||
switch (gCurrLevelNum) {
|
if (!isSoftReset) {
|
||||||
case LEVEL_BITDW: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break;
|
switch (gCurrLevelNum) {
|
||||||
case LEVEL_BITFS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break;
|
case LEVEL_BITDW: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break;
|
||||||
case LEVEL_BITS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break;
|
case LEVEL_BITFS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break;
|
||||||
case LEVEL_WF: newcam_yaw = 0x4000; newcam_tilt = 2000; break;
|
case LEVEL_BITS: newcam_yaw = 0x4000; /*newcam_mode = NC_MODE_8D;*/ newcam_tilt = 4000; break;
|
||||||
case LEVEL_RR: newcam_yaw = 0x6000; newcam_tilt = 2000; break;
|
case LEVEL_WF: newcam_yaw = 0x4000; newcam_tilt = 2000; break;
|
||||||
case LEVEL_CCM: if (gCurrAreaIndex == 1) {newcam_yaw = -0x4000; newcam_tilt = 2000; } else newcam_mode = NC_MODE_SLIDE; break;
|
case LEVEL_RR: newcam_yaw = 0x6000; newcam_tilt = 2000; break;
|
||||||
case LEVEL_WDW: newcam_yaw = 0x2000; newcam_tilt = 3000; break;
|
case LEVEL_CCM: if (gCurrAreaIndex == 1) {newcam_yaw = -0x4000; newcam_tilt = 2000; } else newcam_mode = NC_MODE_SLIDE; break;
|
||||||
case 27: newcam_mode = NC_MODE_SLIDE; break;
|
case LEVEL_WDW: newcam_yaw = 0x2000; newcam_tilt = 3000; break;
|
||||||
case LEVEL_TTM: if (gCurrAreaIndex == 2) newcam_mode = NC_MODE_SLIDE; break;
|
case 27: newcam_mode = NC_MODE_SLIDE; break;
|
||||||
}
|
case LEVEL_TTM: if (gCurrAreaIndex == 2) newcam_mode = NC_MODE_SLIDE; break;
|
||||||
|
}
|
||||||
|
|
||||||
// clear these out when entering a new level to prevent "camera mode buffering"
|
// clear these out when entering a new level to prevent "camera mode buffering"
|
||||||
newcam_saved_defmode = -1;
|
newcam_saved_defmode = -1;
|
||||||
newcam_saved_mode = -1;
|
newcam_saved_mode = -1;
|
||||||
|
}
|
||||||
|
|
||||||
// this will be set in init_settings() if enabled
|
// this will be set in init_settings() if enabled
|
||||||
newcam_active = 0;
|
newcam_active = 0;
|
||||||
|
|
|
||||||
|
|
@ -3506,103 +3506,106 @@ void init_camera(struct Camera *c) {
|
||||||
marioOffset[2] = 400.f;
|
marioOffset[2] = 400.f;
|
||||||
|
|
||||||
// Set the camera's starting position or start a cutscene for certain levels
|
// Set the camera's starting position or start a cutscene for certain levels
|
||||||
switch (gCurrLevelNum) {
|
if (!sSoftResettingCamera) {
|
||||||
case LEVEL_BOWSER_1:
|
switch (gCurrLevelNum) {
|
||||||
|
case LEVEL_BOWSER_1:
|
||||||
#ifndef VERSION_JP
|
#ifndef VERSION_JP
|
||||||
if (gCurrDemoInput == NULL) {
|
if (gCurrDemoInput == NULL) {
|
||||||
|
// Make sure Bowser is in a state that we'd start speaking to him in.
|
||||||
|
obj = find_object_with_behavior(bhvBowser);
|
||||||
|
if (obj != NULL && obj->oAction != 5) { break; }
|
||||||
|
|
||||||
|
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
||||||
|
} else if (gSecondCameraFocus != NULL) {
|
||||||
|
gSecondCameraFocus->oBowserUnk88 = 2;
|
||||||
|
}
|
||||||
|
#else
|
||||||
// Make sure Bowser is in a state that we'd start speaking to him in.
|
// Make sure Bowser is in a state that we'd start speaking to him in.
|
||||||
obj = find_object_with_behavior(bhvBowser);
|
obj = find_object_with_behavior(bhvBowser);
|
||||||
if (obj != NULL && obj->oAction != 5) { break; }
|
if (obj != NULL && obj->oAction != 5) { break; }
|
||||||
|
|
||||||
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
||||||
} else if (gSecondCameraFocus != NULL) {
|
|
||||||
gSecondCameraFocus->oBowserUnk88 = 2;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Make sure Bowser is in a state that we'd start speaking to him in.
|
|
||||||
obj = find_object_with_behavior(bhvBowser);
|
|
||||||
if (obj != NULL && obj->oAction != 5) { break; }
|
|
||||||
|
|
||||||
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case LEVEL_BOWSER_2:
|
case LEVEL_BOWSER_2:
|
||||||
// Make sure Bowser is in a state that we'd start speaking to him in.
|
// Make sure Bowser is in a state that we'd start speaking to him in.
|
||||||
obj = find_object_with_behavior(bhvBowser);
|
obj = find_object_with_behavior(bhvBowser);
|
||||||
if (obj != NULL && obj->oAction != 5) { break; }
|
if (obj != NULL && obj->oAction != 5) { break; }
|
||||||
|
|
||||||
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
||||||
break;
|
break;
|
||||||
case LEVEL_BOWSER_3:
|
case LEVEL_BOWSER_3:
|
||||||
// Make sure Bowser is in a state that we'd start speaking to him in.
|
// Make sure Bowser is in a state that we'd start speaking to him in.
|
||||||
obj = find_object_with_behavior(bhvBowser);
|
obj = find_object_with_behavior(bhvBowser);
|
||||||
if (obj != NULL && obj->oAction != 5) { break; }
|
if (obj != NULL && obj->oAction != 5) { break; }
|
||||||
|
|
||||||
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
start_cutscene(c, CUTSCENE_ENTER_BOWSER_ARENA);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//! Hardcoded position checks determine which cutscene to play when Mario enters castle grounds.
|
//! Hardcoded position checks determine which cutscene to play when Mario enters castle grounds.
|
||||||
case LEVEL_CASTLE_GROUNDS:
|
case LEVEL_CASTLE_GROUNDS:
|
||||||
if (is_within_100_units_of_mario(-1328.f, 260.f, 4664.f) != 1) {
|
if (is_within_100_units_of_mario(-1328.f, 260.f, 4664.f) != 1) {
|
||||||
marioOffset[0] = -400.f;
|
marioOffset[0] = -400.f;
|
||||||
marioOffset[2] = -800.f;
|
marioOffset[2] = -800.f;
|
||||||
}
|
}
|
||||||
if (is_within_100_units_of_mario(-6901.f, 2376.f, -6509.f) == 1) {
|
if (is_within_100_units_of_mario(-6901.f, 2376.f, -6509.f) == 1) {
|
||||||
start_cutscene(c, CUTSCENE_EXIT_WATERFALL);
|
start_cutscene(c, CUTSCENE_EXIT_WATERFALL);
|
||||||
}
|
}
|
||||||
if (is_within_100_units_of_mario(5408.f, 4500.f, 3637.f) == 1) {
|
if (is_within_100_units_of_mario(5408.f, 4500.f, 3637.f) == 1) {
|
||||||
start_cutscene(c, CUTSCENE_EXIT_FALL_WMOTR);
|
start_cutscene(c, CUTSCENE_EXIT_FALL_WMOTR);
|
||||||
}
|
}
|
||||||
gLakituState.mode = CAMERA_MODE_FREE_ROAM;
|
gLakituState.mode = CAMERA_MODE_FREE_ROAM;
|
||||||
break;
|
break;
|
||||||
case LEVEL_SA:
|
case LEVEL_SA:
|
||||||
marioOffset[2] = 200.f;
|
marioOffset[2] = 200.f;
|
||||||
break;
|
break;
|
||||||
case LEVEL_CASTLE_COURTYARD:
|
case LEVEL_CASTLE_COURTYARD:
|
||||||
marioOffset[2] = -300.f;
|
|
||||||
break;
|
|
||||||
case LEVEL_LLL:
|
|
||||||
gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT;
|
|
||||||
break;
|
|
||||||
case LEVEL_CASTLE:
|
|
||||||
marioOffset[2] = 150.f;
|
|
||||||
break;
|
|
||||||
case LEVEL_RR:
|
|
||||||
vec3f_set(sFixedModeBasePosition, -2985.f, 478.f, -5568.f);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ((c->mode == CAMERA_MODE_8_DIRECTIONS) || c->mode == CAMERA_MODE_ROM_HACK) {
|
|
||||||
gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT;
|
|
||||||
}
|
|
||||||
switch (gCurrLevelArea) {
|
|
||||||
case AREA_SSL_EYEROK:
|
|
||||||
vec3f_set(marioOffset, 0.f, 500.f, -100.f);
|
|
||||||
break;
|
|
||||||
case AREA_CCM_SLIDE:
|
|
||||||
marioOffset[2] = -300.f;
|
|
||||||
break;
|
|
||||||
case AREA_THI_WIGGLER:
|
|
||||||
marioOffset[2] = -300.f;
|
|
||||||
break;
|
|
||||||
case AREA_SL_IGLOO:
|
|
||||||
marioOffset[2] = -300.f;
|
|
||||||
break;
|
|
||||||
case AREA_SL_OUTSIDE:
|
|
||||||
if (is_within_100_units_of_mario(257.f, 2150.f, 1399.f) == 1) {
|
|
||||||
marioOffset[2] = -300.f;
|
marioOffset[2] = -300.f;
|
||||||
}
|
break;
|
||||||
break;
|
case LEVEL_LLL:
|
||||||
case AREA_CCM_OUTSIDE:
|
gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT;
|
||||||
|
break;
|
||||||
|
case LEVEL_CASTLE:
|
||||||
|
marioOffset[2] = 150.f;
|
||||||
|
break;
|
||||||
|
case LEVEL_RR:
|
||||||
|
vec3f_set(sFixedModeBasePosition, -2985.f, 478.f, -5568.f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((c->mode == CAMERA_MODE_8_DIRECTIONS) || c->mode == CAMERA_MODE_ROM_HACK) {
|
||||||
gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT;
|
gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT;
|
||||||
break;
|
}
|
||||||
case AREA_TTM_OUTSIDE:
|
|
||||||
gLakituState.mode = CAMERA_MODE_RADIAL;
|
switch (gCurrLevelArea) {
|
||||||
break;
|
case AREA_SSL_EYEROK:
|
||||||
|
vec3f_set(marioOffset, 0.f, 500.f, -100.f);
|
||||||
|
break;
|
||||||
|
case AREA_CCM_SLIDE:
|
||||||
|
marioOffset[2] = -300.f;
|
||||||
|
break;
|
||||||
|
case AREA_THI_WIGGLER:
|
||||||
|
marioOffset[2] = -300.f;
|
||||||
|
break;
|
||||||
|
case AREA_SL_IGLOO:
|
||||||
|
marioOffset[2] = -300.f;
|
||||||
|
break;
|
||||||
|
case AREA_SL_OUTSIDE:
|
||||||
|
if (is_within_100_units_of_mario(257.f, 2150.f, 1399.f) == 1) {
|
||||||
|
marioOffset[2] = -300.f;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AREA_CCM_OUTSIDE:
|
||||||
|
gCameraMovementFlags |= CAM_MOVE_ZOOMED_OUT;
|
||||||
|
break;
|
||||||
|
case AREA_TTM_OUTSIDE:
|
||||||
|
gLakituState.mode = CAMERA_MODE_RADIAL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sSoftResettingCamera) {
|
if (sSoftResettingCamera) {
|
||||||
c->cutscene = 0;
|
c->cutscene = 0;
|
||||||
sSoftResettingCamera = FALSE;
|
|
||||||
} else {
|
} else {
|
||||||
// Set the camera pos to marioOffset (relative to Mario), added to Mario's position
|
// Set the camera pos to marioOffset (relative to Mario), added to Mario's position
|
||||||
offset_rotated(c->pos, sMarioCamState->pos, marioOffset, sMarioCamState->faceAngle);
|
offset_rotated(c->pos, sMarioCamState->pos, marioOffset, sMarioCamState->faceAngle);
|
||||||
|
|
@ -3627,8 +3630,10 @@ void init_camera(struct Camera *c) {
|
||||||
c->yaw = gLakituState.yaw;
|
c->yaw = gLakituState.yaw;
|
||||||
c->nextYaw = gLakituState.yaw;
|
c->nextYaw = gLakituState.yaw;
|
||||||
|
|
||||||
newcam_init(c, 0);
|
newcam_init(c, sSoftResettingCamera);
|
||||||
newcam_init_settings();
|
newcam_init_settings();
|
||||||
|
|
||||||
|
sSoftResettingCamera = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue