-
Notifications
You must be signed in to change notification settings - Fork 192
Reonucam and camera collision defines #778
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
base: develop/3.0.0
Are you sure you want to change the base?
Changes from all commits
f880be6
69606ac
fc86b11
111a5a7
8b54cf6
3c49d2f
ba9fb41
54727ce
b91fb42
54bd5bc
8875cc3
d794f3a
835f877
1555667
b8b86cc
ccb9a8e
af17caf
2a40167
5db1d1d
5ce4797
f4ec430
56f4b9c
725596d
32e904c
1b7df11
32ad8ee
d440b12
e3ec7e5
b284156
e15a57e
24743f6
86134d2
eb78b1c
bedd59a
e99a038
2dc732e
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,26 @@ | |
| #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) | ||
|
Collaborator
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. "An explanation OF the features..." |
||
| */ | ||
| #define REONUCAM | ||
|
|
||
| /** | ||
| * 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 | ||
|
|
||
| /**********************************/ | ||
| /***** Vanilla config options *****/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,6 +139,34 @@ | |
| #define FLYING_CAMERA_MODE CAMERA_MODE_BEHIND_MARIO | ||
| #endif // !FLYING_CAMERA_MODE | ||
|
|
||
| // Reonucam overrides | ||
| #ifdef REONUCAM | ||
| // Use course default mode | ||
| #ifdef USE_COURSE_DEFAULT_MODE | ||
| #undef USE_COURSE_DEFAULT_MODE | ||
| #define USE_COURSE_DEFAULT_MODE | ||
| #endif | ||
|
Comment on lines
+145
to
+148
Collaborator
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. Is this doing what you think it's doing? This code seems completely useless lol. I assume what you meant to do was force camera default mode to always be on, in which case just get rid of the ifdef/endif lines completely. Same goes for the 4 lines after this, only that ifdef is actually not broken this time so it matters a bit less lol. |
||
|
|
||
| // 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 | ||
|
|
||
| // Disable camera sounds | ||
| #define play_sound_cbutton_up() | ||
| #define play_sound_cbutton_down() | ||
| #define play_sound_cbutton_side() | ||
| #define play_sound_if_cam_switched_to_lakitu_or_mario() | ||
| #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,128 @@ 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) { | ||
Reonu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 = yaw; | ||
| } | ||
| else { | ||
| c->yaw = atan2s(c->pos[2] - gMarioState->pos[2], c->pos[0] - gMarioState->pos[0]); | ||
| } | ||
|
|
||
| } | ||
| #endif | ||
|
|
||
| #ifdef REONUCAM | ||
| f32 reonucamSpeeds[5] = {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(struct Camera *c) { | ||
| Vec3f pos; | ||
| s16 oldAreaYaw = sAreaYaw; | ||
| // Get the camera speed based on the user's setting | ||
| f32 cameraSpeed = reonucamSpeeds[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; | ||
| } | ||
| } | ||
|
|
||
| radial_camera_input(c); | ||
|
|
||
| lakitu_zoom(400.f, 0x900); | ||
| c->nextYaw = update_8_directions_camera(c, c->focus, pos); | ||
|
|
||
| set_camera_height(c, pos[1]); | ||
|
|
||
| c->pos[0] = pos[0]; | ||
| c->pos[2] = pos[2]; | ||
| sAreaYawChange = sAreaYaw - oldAreaYaw; | ||
| eight_dir_collision_handler(c); | ||
| } | ||
| #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 | ||
|
Collaborator
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
Contributor
Author
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
Collaborator
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
Contributor
Author
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. Is this ok now @arthurtilly |
||
| reonucam_handler(c); | ||
| #else | ||
| radial_camera_input(c); | ||
|
|
||
| if (gPlayer1Controller->buttonPressed & R_CBUTTONS) { | ||
|
|
@@ -1149,13 +1287,16 @@ void mode_8_directions_camera(struct Camera *c) { | |
| s8DirModeYawOffset = snap_to_45_degrees(s8DirModeYawOffset); | ||
| } | ||
| #endif | ||
|
|
||
| lakitu_zoom(400.f, 0x900); | ||
| c->nextYaw = update_8_directions_camera(c, c->focus, pos); | ||
| c->pos[0] = pos[0]; | ||
| c->pos[2] = pos[2]; | ||
| sAreaYawChange = sAreaYaw - oldAreaYaw; | ||
| #ifdef EIGHT_DIR_CAMERA_COLLISION | ||
| eight_dir_collision_handler(c); | ||
| #endif | ||
| set_camera_height(c, pos[1]); | ||
| #endif | ||
|
Collaborator
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: inconsistent indentation (also add a comment clarifying it's a REONUCAM endif) |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -2751,6 +2892,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,11 +3026,18 @@ 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) { | ||
Reonu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
| } | ||
| } | ||
| play_sound_if_cam_switched_to_lakitu_or_mario(); | ||
Reonu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
@@ -4544,6 +4695,7 @@ void play_camera_buzz_if_c_sideways(void) { | |
| } | ||
| } | ||
|
|
||
| #ifndef REONUCAM | ||
| void play_sound_cbutton_up(void) { | ||
| play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource); | ||
| } | ||
|
|
@@ -4556,14 +4708,6 @@ void play_sound_cbutton_side(void) { | |
| play_sound(SOUND_MENU_CAMERA_TURN, gGlobalSoundSource); | ||
| } | ||
|
|
||
| void play_sound_button_change_blocked(void) { | ||
| play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); | ||
| } | ||
|
|
||
| void play_sound_rbutton_changed(void) { | ||
| play_sound(SOUND_MENU_CLICK_CHANGE_VIEW, gGlobalSoundSource); | ||
| } | ||
|
|
||
| void play_sound_if_cam_switched_to_lakitu_or_mario(void) { | ||
| if (sCameraSoundFlags & CAM_SOUND_MARIO_ACTIVE) { | ||
| play_sound_rbutton_changed(); | ||
|
|
@@ -4574,6 +4718,16 @@ void play_sound_if_cam_switched_to_lakitu_or_mario(void) { | |
| sCameraSoundFlags &= ~(CAM_SOUND_MARIO_ACTIVE | CAM_SOUND_NORMAL_ACTIVE); | ||
| } | ||
|
|
||
| #endif | ||
|
|
||
| void play_sound_button_change_blocked(void) { | ||
| play_sound(SOUND_MENU_CAMERA_BUZZ, gGlobalSoundSource); | ||
| } | ||
|
|
||
| void play_sound_rbutton_changed(void) { | ||
| play_sound(SOUND_MENU_CLICK_CHANGE_VIEW, gGlobalSoundSource); | ||
| } | ||
|
|
||
| /** | ||
| * Handles input for radial, outwards radial, parallel tracking, and 8 direction mode. | ||
| */ | ||
|
|
@@ -4652,7 +4806,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(); | ||
|
|
||
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.
Wants a newline.