From 93cfab086a37bc0518adbf7fa025c49fff5d872f Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 16 May 2020 20:28:36 +0300 Subject: [PATCH] bettercam: add adjustable camera deceleration --- include/text_strings.h.in | 1 + src/game/bettercamera.inc.h | 12 ++++++------ src/game/options_menu.c | 2 ++ src/pc/configfile.c | 2 ++ src/pc/configfile.h | 1 + 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/text_strings.h.in b/include/text_strings.h.in index a577a161..3246699e 100644 --- a/include/text_strings.h.in +++ b/include/text_strings.h.in @@ -9,6 +9,7 @@ #define TEXT_OPT_INVERTY _("Invert Y Axis") #define TEXT_OPT_CAMC _("Camera Centre Aggression") #define TEXT_OPT_CAMP _("Camera Pan Level") +#define TEXT_OPT_CAMD _("Camera Deceleration") #define TEXT_OPT_ENABLED _("Enabled") #define TEXT_OPT_DISABLED _("Disabled") #define TEXT_OPT_BUTTON1 _("[R]: Options") diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index 3ef627a8..0f58b2e8 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -28,8 +28,6 @@ NC_MODE_NOTURN: Disables horizontal and vertical control of the camera. //#define NEWCAM_DEBUG //Some print values for puppycam. Not useful anymore, but never hurts to keep em around. //#define nosound //If for some reason you hate the concept of audio, you can disable it. //#define noaccel //Disables smooth movement of the camera with the C buttons. -#define DEGRADE 0.1f //What percent of the remaining camera movement is degraded. Default is 10% - //!Hardcoded camera angle stuff. They're essentially area boxes that when Mario is inside, will trigger some view changes. ///Don't touch this btw, unless you know what you're doing, this has to be above for religious reasons. @@ -88,6 +86,7 @@ s16 newcam_yaw_target; // The yaw value the camera tries to set itself to when t f32 newcam_turnwait; // The amount of time to wait after landing before allowing the camera to turn again f32 newcam_pan_x; f32 newcam_pan_z; +f32 newcam_degrade = 0.1f; //What percent of the remaining camera movement is degraded. Default is 10% u8 newcam_cstick_down = 0; //Just a value that triggers true when the player 2 stick is moved in 8 direction move to prevent holding it down. u8 newcam_target; @@ -155,6 +154,7 @@ void newcam_init_settings(void) newcam_invertY = (u8)configCameraInvertY; newcam_mouse = (u8)configCameraMouse; newcam_analogue = (u8)configEnableCamera; + newcam_degrade = (f32)configCameraDegrade / 100.0f; } /** Mathematic calculations. This stuffs so basic even *I* understand it lol @@ -268,7 +268,7 @@ static void newcam_rotate_button(void) #ifdef noaccel newcam_yaw_acc = 0; #else - newcam_yaw_acc -= (newcam_yaw_acc*(DEGRADE)); + newcam_yaw_acc -= (newcam_yaw_acc*newcam_degrade); #endif } @@ -280,7 +280,7 @@ static void newcam_rotate_button(void) #ifdef noaccel newcam_tilt_acc = 0; #else - newcam_tilt_acc -= (newcam_tilt_acc*(DEGRADE)); + newcam_tilt_acc -= (newcam_tilt_acc*newcam_degrade); #endif newcam_framessincec[0] += 1; @@ -346,13 +346,13 @@ static void newcam_rotate_button(void) else { newcam_cstick_down = 0; - newcam_yaw_acc -= (newcam_yaw_acc*(DEGRADE)); + newcam_yaw_acc -= (newcam_yaw_acc*newcam_degrade); } if (ABS(gPlayer2Controller->stickY) > 20 && newcam_modeflags & NC_FLAG_YTURN) newcam_tilt_acc = newcam_adjust_value(newcam_tilt_acc,(-gPlayer2Controller->stickY/4)); else - newcam_tilt_acc -= (newcam_tilt_acc*(DEGRADE)); + newcam_tilt_acc -= (newcam_tilt_acc*newcam_degrade); } if (newcam_mouse == 1) diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 81c56c0f..37bce584 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -59,6 +59,7 @@ static const u8 optsCameraStr[][32] = { { TEXT_OPT_CAMP }, { TEXT_OPT_ANALOGUE }, { TEXT_OPT_MOUSE }, + { TEXT_OPT_CAMD }, }; static const u8 optsVideoStr[][32] = { @@ -174,6 +175,7 @@ static struct Option optsCamera[] = { DEF_OPT_SCROLL( optsCameraStr[1], &configCameraYSens, 10, 250, 1 ), DEF_OPT_SCROLL( optsCameraStr[4], &configCameraAggr, 0, 100, 1 ), DEF_OPT_SCROLL( optsCameraStr[5], &configCameraPan, 0, 100, 1 ), + DEF_OPT_SCROLL( optsCameraStr[8], &configCameraDegrade, 0, 100, 1 ), }; #endif diff --git a/src/pc/configfile.c b/src/pc/configfile.c index df05b1d5..3c2735c2 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -59,6 +59,7 @@ unsigned int configCameraXSens = 50; unsigned int configCameraYSens = 50; unsigned int configCameraAggr = 0; unsigned int configCameraPan = 0; +unsigned int configCameraDegrade = 10; // 0 - 100% bool configCameraInvertX = false; bool configCameraInvertY = false; bool configEnableCamera = false; @@ -93,6 +94,7 @@ static const struct ConfigOption options[] = { {.name = "bettercam_ysens", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraYSens}, {.name = "bettercam_aggression", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraAggr}, {.name = "bettercam_pan_level", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraPan}, + {.name = "bettercam_degrade", .type = CONFIG_TYPE_UINT, .uintValue = &configCameraDegrade}, #endif {.name = "skip_intro", .type = CONFIG_TYPE_UINT, .uintValue = &configSkipIntro}, // Add this back! }; diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 39a020e8..8dc69e27 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -31,6 +31,7 @@ extern unsigned int configCameraXSens; extern unsigned int configCameraYSens; extern unsigned int configCameraAggr; extern unsigned int configCameraPan; +extern unsigned int configCameraDegrade; extern bool configCameraInvertX; extern bool configCameraInvertY; extern bool configEnableCamera;