bettercam: add adjustable camera deceleration

This commit is contained in:
fgsfds 2020-05-16 20:28:36 +03:00
parent 1d557e4c4d
commit 93cfab086a
5 changed files with 12 additions and 6 deletions

View File

@ -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")

View File

@ -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)

View File

@ -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

View File

@ -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!
};

View File

@ -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;