-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reonucam and camera collision defines #778
base: develop/3.0.0
Are you sure you want to change the base?
Changes from all commits
88dfc23
9caac98
ad5d751
bbd23d5
6ec51dc
52f8488
dfab25b
137af2c
367d2eb
b6ca569
3cab72c
f842bc5
6593a03
5ae9364
455d013
3d0b1e5
97c1e29
cb7c949
78a9e66
d954465
fcd9efd
5a43423
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,21 +40,25 @@ | |
#define FAST_VERTICAL_CAMERA_MOVEMENT | ||
|
||
/** | ||
* Enables "parallel lakitu camera" or "aglab cam" which lets you move the camera smoothly with the D-pad. | ||
* Enables camera collision for 8 direction camera and, by extension, to Parallel Lakitu cam or Reonucam if enabled. | ||
* If you enable it, please consider using surface types with the SURFACE_FLAG_NO_CAM_COLLISION flag for small obstacles, | ||
* such as fences, pillars, signs, etc, in order to make your game more enjoyable and not let the camera get in the way of gameplay. | ||
*/ | ||
#define PARALLEL_LAKITU_CAM | ||
#define EIGHT_DIR_CAMERA_COLLISION | ||
|
||
/** | ||
* Enables Puppy Camera 2, a rewritten camera that can be freely configured and modified. | ||
* Enables "parallel lakitu camera" or "aglab cam" which lets you move the camera smoothly with the D-pad. Will be disabled if Reonucam is enabled. | ||
*/ | ||
// #define PUPPYCAM | ||
#define PARALLEL_LAKITU_CAM | ||
|
||
// Enables Reonucam, a custom camera that aims to be a more feature-rich "aglabcam" that doesn't use a single button more than the vanilla camera. | ||
// An explanation the features can be seen here: https://www.youtube.com/watch?v=TQNkznX9Z3k (please note that the analog feature shown at the end is no longer present) | ||
//#define REONUCAM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
|
||
/** | ||
* Note: Reonucam is available, but because we had no time to test it properly, it's included as a patch rather than being in the code by default. | ||
* Run this command to apply the patch if you want to use it: | ||
* tools/apply_patch.sh enhancements/reonucam.patch | ||
* Consider it a beta, but it should work fine. Please report any bugs with it. Applying the patch will simply add a define here, so you can still turn it off even after patching. | ||
* Enables Puppy Camera 2, a rewritten camera that can be freely configured and modified. | ||
*/ | ||
//#define PUPPYCAM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably should have been a bit more clear; the commented defines in the other files do use a space here. Space is also better because it's consistent with VSCode's commenting shortcut (Ctrl + /). |
||
|
||
/**********************************/ | ||
/***** Vanilla config options *****/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,6 +139,27 @@ | |
#define FLYING_CAMERA_MODE CAMERA_MODE_BEHIND_MARIO | ||
#endif // !FLYING_CAMERA_MODE | ||
|
||
// Reonucam overrides | ||
#ifdef REONUCAM | ||
// Use course default mode | ||
#ifndef USE_COURSE_DEFAULT_MODE | ||
#define USE_COURSE_DEFAULT_MODE | ||
#endif | ||
Comment on lines
+145
to
+147
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
|
||
// Force camera mode to 8 Dir | ||
#ifdef FORCED_CAMERA_MODE | ||
#undef FORCED_CAMERA_MODE | ||
#endif | ||
#define FORCED_CAMERA_MODE CAMERA_MODE_8_DIRECTIONS | ||
|
||
// Disable vanilla cam processing | ||
#undef ENABLE_VANILLA_CAM_PROCESSING | ||
|
||
// Disable aglab cam | ||
#undef PARALLEL_LAKITU_CAM | ||
#endif | ||
|
||
|
||
|
||
/***************** | ||
* config_game.h | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,10 @@ | |
* | ||
*/ | ||
|
||
#ifdef REONUCAM | ||
struct ReonucamState gReonucamState = { 2, FALSE, FALSE, FALSE, 0, 0, }; | ||
#endif | ||
|
||
// BSS | ||
/** | ||
* Stores Lakitu's position from the last frame, used for transitioning in next_lakitu_state() | ||
|
@@ -875,6 +879,25 @@ s32 update_8_directions_camera(struct Camera *c, Vec3f focus, Vec3f pos) { | |
f32 yOff = 125.f; | ||
f32 baseDist = 1000.f; | ||
|
||
#ifdef REONUCAM | ||
if (gMarioState->action & ACT_FLAG_SWIMMING) { | ||
yOff = -125.f; | ||
} else if (gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING) { | ||
yOff = 325.f; | ||
} else { | ||
yOff = 125.f; | ||
} | ||
|
||
if ((gPlayer1Controller->buttonDown & R_TRIG) && (gPlayer1Controller->buttonDown & U_CBUTTONS)) { | ||
gReonucamState.keepCliffCam = 1; | ||
pitch = DEGREES(60); | ||
} else if (((gPlayer1Controller->buttonDown & U_CBUTTONS) || (gPlayer1Controller->buttonDown & R_TRIG)) && gReonucamState.keepCliffCam) { | ||
pitch = DEGREES(60); | ||
} else { | ||
gReonucamState.keepCliffCam = 0; | ||
} | ||
#endif | ||
|
||
sAreaYaw = camYaw; | ||
calc_y_to_curr_floor(&posY, 1.f, 200.f, &focusY, 0.9f, 200.f); | ||
focus_on_mario(focus, pos, posY + yOff, focusY + yOff, sLakituDist + baseDist, pitch, camYaw); | ||
|
@@ -1116,13 +1139,117 @@ s32 snap_to_45_degrees(s16 angle) { | |
return angle; | ||
} | ||
|
||
#ifdef EIGHT_DIR_CAMERA_COLLISION | ||
|
||
#define MIN_CAMERA_DISTANCE 300.0f // Minimum distance between Mario and the camera. | ||
#define VERTICAL_RAY_OFFSET 300.0f // The ray is cast from 300 units above Mario in order to prevent small obstacles from constantly snapping the camera | ||
|
||
void eight_dir_collision_handler(struct Camera *c) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would like some lines of spacing between parts of the code in this function and the below function, its a little hard to read There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mark it as resolved if you think it's ok now |
||
struct Surface *surf; | ||
|
||
Vec3f camdir; | ||
Vec3f origin; | ||
Vec3f thick; | ||
Vec3f hitpos; | ||
|
||
vec3f_copy(origin,gMarioState->pos); | ||
|
||
origin[1] += VERTICAL_RAY_OFFSET; | ||
camdir[0] = c->pos[0] - origin[0]; | ||
camdir[1] = c->pos[1] - origin[1]; | ||
camdir[2] = c->pos[2] - origin[2]; | ||
|
||
find_surface_on_ray(origin, camdir, &surf, hitpos, (RAYCAST_FIND_FLOOR | RAYCAST_FIND_WALL | RAYCAST_FIND_CEIL)); | ||
|
||
if (surf) { | ||
f32 distFromSurf = 100.0f; | ||
f32 dist; | ||
f32 yDist = 0; | ||
Vec3f camToMario; | ||
vec3f_diff(camToMario, gMarioState->pos, hitpos); | ||
s16 yaw = atan2s(camToMario[2], camToMario[0]); | ||
vec3f_get_lateral_dist(hitpos,gMarioState->pos, &dist); | ||
if (dist < MIN_CAMERA_DISTANCE) { | ||
distFromSurf += (dist - MIN_CAMERA_DISTANCE); // If Mario runs right up to the screen, the camera pull back slightly... | ||
yDist = MIN_CAMERA_DISTANCE - CLAMP(dist, 0, MIN_CAMERA_DISTANCE); // ...and also up slightly. | ||
} | ||
thick[0] = sins(yaw) * distFromSurf; | ||
thick[1] = yDist; | ||
thick[2] = coss(yaw) * distFromSurf; | ||
vec3f_add(hitpos,thick); | ||
vec3f_copy(c->pos,hitpos); | ||
} | ||
|
||
c->yaw = atan2s(c->pos[2] - gMarioState->pos[2], c->pos[0] - gMarioState->pos[0]); | ||
|
||
} | ||
#endif | ||
|
||
#ifdef REONUCAM | ||
f32 cameraSpeeds[] = {0.5f, 1.f, 1.5f, 2.f, 3.5f}; // The camera speed settings, from slowest to fastest. | ||
#define R_DOUBLE_TAP_WINDOW 5 // How many frames the player has to double tap R in order to ender Mario cam mode. | ||
|
||
void reonucam_handler(void) { | ||
// Get the camera speed based on the user's setting | ||
f32 cameraSpeed = cameraSpeeds[gReonucamState.speed]; | ||
|
||
//45º rotations | ||
if ((gPlayer1Controller->buttonPressed & L_CBUTTONS) && !(gPlayer1Controller->buttonDown & R_TRIG)) { | ||
s8DirModeBaseYaw = snap_to_45_degrees(s8DirModeBaseYaw - DEGREES(45)); | ||
} else if ((gPlayer1Controller->buttonPressed & R_CBUTTONS) && !(gPlayer1Controller->buttonDown & R_TRIG)) { | ||
s8DirModeBaseYaw = snap_to_45_degrees(s8DirModeBaseYaw + DEGREES(45)); | ||
} | ||
|
||
//Smooth rotation | ||
if (gPlayer1Controller->buttonDown & R_TRIG) { | ||
if (gPlayer1Controller->buttonDown & L_CBUTTONS) { | ||
s8DirModeBaseYaw -= DEGREES(cameraSpeed); | ||
} else if (gPlayer1Controller->buttonDown & R_CBUTTONS) { | ||
s8DirModeBaseYaw += DEGREES(cameraSpeed); | ||
} | ||
if (gReonucamState.rButtonCounter++ > 100) { // This increses whenever R is held. | ||
gReonucamState.rButtonCounter = 100; | ||
} | ||
} else { | ||
if (gReonucamState.rButtonCounter > 0 && gReonucamState.rButtonCounter <= R_DOUBLE_TAP_WINDOW && !((gPlayer1Controller->buttonDown & L_CBUTTONS) || (gPlayer1Controller->buttonDown & R_CBUTTONS) || (gMarioState->action & ACT_FLAG_SWIMMING_OR_FLYING))) { | ||
// This centers the camera behind mario. It triggers when you let go of R in less than 5 frames. | ||
s8DirModeYawOffset = 0; | ||
s8DirModeBaseYaw = gMarioState->faceAngle[1]-0x8000; | ||
gMarioState->area->camera->yaw = s8DirModeBaseYaw; | ||
play_sound_rbutton_changed(); | ||
} | ||
gReonucamState.rButtonCounter = 0; | ||
} | ||
|
||
if (gPlayer1Controller->buttonPressed & R_TRIG) { | ||
if (gReonucamState.rButtonCounter2 <= R_DOUBLE_TAP_WINDOW) { | ||
set_cam_angle(CAM_ANGLE_MARIO); // Enter mario cam if R is pressed 2 times in less than 5 frames | ||
gReonucamState.rButtonCounter2 = R_DOUBLE_TAP_WINDOW + 1; | ||
} else { | ||
gReonucamState.rButtonCounter2 = 0; | ||
} | ||
} else { | ||
if (gReonucamState.rButtonCounter2++ > 100) { | ||
gReonucamState.rButtonCounter2 = 100; | ||
} | ||
} | ||
|
||
print_text_fmt_int(20, 40, "R %d", gReonucamState.rButtonCounter); | ||
print_text_fmt_int(20, 20, "R %d", gReonucamState.rButtonCounter2); | ||
|
||
} | ||
#endif | ||
|
||
/** | ||
* A mode that only has 8 camera angles, 45 degrees apart | ||
*/ | ||
void mode_8_directions_camera(struct Camera *c) { | ||
Vec3f pos; | ||
s16 oldAreaYaw = sAreaYaw; | ||
|
||
#ifdef REONUCAM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for this function i think it might be better if reonucam_handler was expanded to include the other parts of this function and then it would be a replacement for this function rather than being full of ifdefs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense, will look into it tomorrow There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still havent done this smh |
||
reonucam_handler(); | ||
radial_camera_input(c); | ||
#else | ||
radial_camera_input(c); | ||
|
||
if (gPlayer1Controller->buttonPressed & R_CBUTTONS) { | ||
|
@@ -1149,13 +1276,21 @@ void mode_8_directions_camera(struct Camera *c) { | |
s8DirModeYawOffset = snap_to_45_degrees(s8DirModeYawOffset); | ||
} | ||
#endif | ||
|
||
#endif | ||
lakitu_zoom(400.f, 0x900); | ||
c->nextYaw = update_8_directions_camera(c, c->focus, pos); | ||
#ifdef REONUCAM | ||
set_camera_height(c, pos[1]); | ||
#endif | ||
c->pos[0] = pos[0]; | ||
c->pos[2] = pos[2]; | ||
sAreaYawChange = sAreaYaw - oldAreaYaw; | ||
#ifdef EIGHT_DIR_CAMERA_COLLISION | ||
eight_dir_collision_handler(c); | ||
#endif | ||
#ifndef REONUCAM | ||
set_camera_height(c, pos[1]); | ||
#endif | ||
} | ||
|
||
/** | ||
|
@@ -2751,6 +2886,9 @@ void set_camera_mode(struct Camera *c, s16 mode, s16 frames) { | |
#ifndef ENABLE_VANILLA_CAM_PROCESSING | ||
if (mode == CAMERA_MODE_8_DIRECTIONS) { | ||
// Helps transition from any camera mode to 8dir | ||
#ifdef REONUCAM | ||
s8DirModeBaseYaw = 0; | ||
#endif | ||
s8DirModeYawOffset = snap_to_45_degrees(c->yaw); | ||
} | ||
#endif | ||
|
@@ -2882,14 +3020,23 @@ void update_camera(struct Camera *c) { | |
// Only process R_TRIG if 'fixed' is not selected in the menu | ||
if (cam_select_alt_mode(CAM_SELECTION_NONE) == CAM_SELECTION_MARIO) { | ||
if (gPlayer1Controller->buttonPressed & R_TRIG) { | ||
#ifdef REONUCAM | ||
if (set_cam_angle(0) == CAM_ANGLE_MARIO) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be in the cam handler not here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unless thats not possible with how the cam angle stuff works idk |
||
s8DirModeBaseYaw = snap_to_45_degrees(s8DirModeBaseYaw); | ||
set_cam_angle(CAM_ANGLE_LAKITU); | ||
} | ||
#else | ||
if (set_cam_angle(0) == CAM_ANGLE_LAKITU) { | ||
set_cam_angle(CAM_ANGLE_MARIO); | ||
} else { | ||
set_cam_angle(CAM_ANGLE_LAKITU); | ||
} | ||
#endif | ||
} | ||
} | ||
#ifndef REONUCAM | ||
play_sound_if_cam_switched_to_lakitu_or_mario(); | ||
#endif | ||
} | ||
|
||
// Initialize the camera | ||
|
@@ -4545,15 +4692,21 @@ void play_camera_buzz_if_c_sideways(void) { | |
} | ||
|
||
void play_sound_cbutton_up(void) { | ||
#ifndef REONUCAM | ||
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); | ||
#endif | ||
} | ||
|
||
void play_sound_cbutton_down(void) { | ||
#ifndef REONUCAM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleaner (both codewise and optimization wise) to ifdef this whole block and then if reonucam is defined instead do |
||
play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource); | ||
#endif | ||
} | ||
|
||
void play_sound_cbutton_side(void) { | ||
#ifndef REONUCAM | ||
play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); | ||
#endif | ||
} | ||
|
||
void play_sound_button_change_blocked(void) { | ||
|
@@ -4652,7 +4805,11 @@ void radial_camera_input(struct Camera *c) { | |
} | ||
|
||
// Zoom in / enter C-Up | ||
#ifdef REONUCAM | ||
if ((gPlayer1Controller->buttonPressed & U_CBUTTONS) && !(gPlayer1Controller->buttonDown & R_TRIG)) { | ||
#else | ||
if (gPlayer1Controller->buttonPressed & U_CBUTTONS) { | ||
#endif | ||
if (gCameraMovementFlags & CAM_MOVE_ZOOMED_OUT) { | ||
gCameraMovementFlags &= ~CAM_MOVE_ZOOMED_OUT; | ||
play_sound_cbutton_up(); | ||
|
@@ -4741,6 +4898,7 @@ void handle_c_button_movement(struct Camera *c) { | |
} | ||
} | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get this formatting change outta here!!!!!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think arceveti took over my pc |
||
/** | ||
* Zero the 10 cvars. | ||
*/ | ||
|
@@ -5210,7 +5368,11 @@ void set_camera_mode_8_directions(struct Camera *c) { | |
if (c->mode != CAMERA_MODE_8_DIRECTIONS) { | ||
c->mode = CAMERA_MODE_8_DIRECTIONS; | ||
sStatusFlags &= ~CAM_FLAG_SMOOTH_MOVEMENT; | ||
#ifdef REONUCAM | ||
s8DirModeBaseYaw = snap_to_45_degrees(s8DirModeBaseYaw); | ||
#else | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this seems weird, how do you know what s8DirModeBaseYaw is here? that variable is not used outside of 8 direction camera afaik so i don't know if this has the effect you think it does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're right and this is completely unnecessary |
||
s8DirModeBaseYaw = 0; | ||
#endif | ||
s8DirModeYawOffset = 0; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this last time, but this should use a block comment rather than line comments like the rest of the file.