Update PuppyCam 2 (2.3) and update raycast

Update puppycam text, hud, opacity, mario inputs, etc

Added puppycam 1 angles (disabled by default)
This commit is contained in:
AloXado320 2023-07-11 00:24:53 -05:00
parent 4cfc330586
commit 2698bf589b
11 changed files with 473 additions and 308 deletions

View file

@ -45,14 +45,14 @@
#define TEXT_OPT_PUPPYON _("PUPPYCAM 2")
#define TEXT_OPT_PUPPYCAM _("PUPPY CAMERA")
#define TEXT_OPT_CAMMOUSE _("CAMERA MOUSE CONTROL")
#define TEXT_OPT_CAMX _("CAMERA X SENSITIVITY")
#define TEXT_OPT_CAMY _("CAMERA Y SENSITIVITY")
#define TEXT_OPT_INVERTX _("INVERT X AXIS")
#define TEXT_OPT_INVERTY _("INVERT Y AXIS")
#define TEXT_OPT_CAMC _("CAMERA CENTRE SPEED")
#define TEXT_OPT_CAMX _("CAMERA SENSITIVITY")
#define TEXT_OPT_CAMY _("VERTICAL CAMERA SENSITIVITY")
#define TEXT_OPT_INVERTX _("INVERT CAMERA")
#define TEXT_OPT_INVERTY _("VERTICAL INVERT CAMERA")
#define TEXT_OPT_CAMTURN _("CAMERA AUTO TURN")
#define TEXT_OPT_CAMOPA _("OPAQUE CLOSE UP")
#define TEXT_OPT_ANALOGUE _("ANALOGUE CAMERA")
#define TEXT_OPT_CAMSCHEME _("CONTROL SCHEME")
#define TEXT_OPT_OPA_TYPE _("OPACITY TYPE")
#define TEXT_OPT_DBG_CAM _("DEBUG CAMERA")
#define TEXT_OPT_CAM_SCH1 _("DOUBLE TAP")
@ -122,14 +122,14 @@
#define TEXT_OPT_PUPPYON _("PuppyCam 2")
#define TEXT_OPT_PUPPYCAM _("PUPPY CAMERA")
#define TEXT_OPT_CAMMOUSE _("Camera Mouse Control")
#define TEXT_OPT_CAMX _("Camera X Sensitivity")
#define TEXT_OPT_CAMY _("Camera Y Sensitivity")
#define TEXT_OPT_INVERTX _("Invert X Axis")
#define TEXT_OPT_INVERTY _("Invert Y Axis")
#define TEXT_OPT_CAMC _("Camera Centre Speed")
#define TEXT_OPT_CAMX _("Camera Sensitivity")
#define TEXT_OPT_CAMY _("Vertical Camera Sensitivity")
#define TEXT_OPT_INVERTX _("Invert Camera")
#define TEXT_OPT_INVERTY _("Vertical Invert Camera")
#define TEXT_OPT_CAMTURN _("Canera Auto Turn")
#define TEXT_OPT_CAMOPA _("Opaque Close Up")
#define TEXT_OPT_ANALOGUE _("Analogue Camera")
#define TEXT_OPT_CAMSCHEME _("Control Scheme")
#define TEXT_OPT_OPA_TYPE _("Opacity Type")
#define TEXT_OPT_DBG_CAM _("Debug Camera")
#define TEXT_OPT_CAM_SCH1 _("Double Tap")

View file

@ -1623,10 +1623,10 @@ s32 anim_spline_poll(Vec3f result) {
return hasEnded;
}
s16 lenght_sins(s16 length, s16 direction) {
s16 length_sins(s16 length, s16 direction) {
return (length * sins(direction));
}
s16 lenght_coss(s16 length, s16 direction) {
s16 length_coss(s16 length, s16 direction) {
return (length * coss(direction));
}

View file

@ -705,9 +705,13 @@ void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c);
void anim_spline_init(Vec4s *keyFrames);
s32 anim_spline_poll(Vec3f result);
// Misc
s16 lenght_sins(s16 length, s16 direction);
s16 lenght_coss(s16 length, s16 direction);
s16 length_sins(s16 length, s16 direction);
s16 length_coss(s16 length, s16 direction);
float smooth_step(float edge0, float edge1, float x);
float soft_clamp(float x, float a, float b);
ALWAYS_INLINE f32 remap(f32 x, f32 fromA, f32 toA, f32 fromB, f32 toB) {
return (x - fromA) / (toA - fromA) * (toB - fromB) + fromB;
}
#endif // MATH_UTIL_H

View file

@ -1142,7 +1142,6 @@ void debug_surface_list_info(f32 xPos, f32 zPos) {
* RAYCASTING *
**************************************************/
#define RAY_OFFSET 30.0f /* How many units to extrapolate surfaces when testing for a raycast */
#define RAY_STEPS 4 /* How many steps to do when casting rays, default to quartersteps. */
s32 ray_surface_intersect(Vec3f orig, Vec3f dir, f32 dir_length, struct Surface *surface, Vec3f hit_pos, f32 *length)
@ -1162,18 +1161,6 @@ s32 ray_surface_intersect(Vec3f orig, Vec3f dir, f32 dir_length, struct Surface
vec3s_to_vec3f(v1, surface->vertex2);
vec3s_to_vec3f(v2, surface->vertex3);
// Get surface normal and extend it by RAY_OFFSET.
Vec3f norm;
norm[0] = surface->normal.x;
norm[1] = surface->normal.y;
norm[2] = surface->normal.z;
vec3_mul_val(norm, RAY_OFFSET);
// Move the face forward by RAY_OFFSET.
vec3f_add(v0, norm);
vec3f_add(v1, norm);
vec3f_add(v2, norm);
// Make 'e1' (edge 1) the vector from vertex 0 to vertex 1.
Vec3f e1;
vec3f_diff(e1, v1, v0);
@ -1277,7 +1264,7 @@ void find_surface_on_ray_cell(s32 cellX, s32 cellZ, Vec3f orig, Vec3f normalized
}
}
void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags) {
f32 find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags) {
Vec3f normalized_dir;
f32 step;
s32 i;
@ -1304,7 +1291,7 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
// Don't do DDA if straight down
if ((normalized_dir[1] >= NEAR_ONE) || (normalized_dir[1] <= -NEAR_ONE)) {
find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
return;
return max_length;
}
// Get cells we cross using DDA
@ -1335,6 +1322,7 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve
find_surface_on_ray_cell(cellPrevX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length, flags);
}
}
return max_length;
}
void find_surface_on_ray_between_points(Vec3f pos1, Vec3f pos2, struct Surface **hit_surface, Vec3f hit_pos, s32 flags) {

View file

@ -75,7 +75,7 @@ s32 find_water_level_and_floor(s32 x, s32 z, struct Surface **pfloor);
f32 find_water_level(f32 x, f32 z);
f32 find_poison_gas_level(f32 x, f32 z);
void debug_surface_list_info(f32 xPos, f32 zPos);
void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags);
f32 find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos, s32 flags);
void find_surface_on_ray_between_points(Vec3f pos1, Vec3f pos2, struct Surface **hit_surface, Vec3f hit_pos, s32 flags);
void raycast_collision_walls(Vec3f pos, Vec3f intendedPos, f32 yOffset);

File diff suppressed because it is too large Load diff

View file

@ -5,6 +5,8 @@
#include "level_commands.h"
//#define PUPPYCAM_SAMPLES
//How many times to store the terrain pitch. This stores it over 10 frames to help smooth over changes in curvature.
#define NUM_PITCH_ITERATIONS 10
@ -38,20 +40,12 @@ enum PuppyVolumeShapes {
PUPPYVOLUME_SHAPE_CYLINDER,
};
enum PuppyCamInputTypes
{
enum PuppyCamInputTypes {
PUPPYCAM_INPUT_TYPE_DOUBLE_TAP,
PUPPYCAM_INPUT_TYPE_SINGLE_PRESS,
PUPPYCAM_INPUT_TYPE_CLASSIC
};
enum PuppyCamOpacityTypes
{
PUPPYCAM_OPACITY_TYPE_OFF,
PUPPYCAM_OPACITY_TYPE_FADE,
PUPPYCAM_OPACITY_TYPE_POP
};
#include "include/command_macros_base.h"
#include "options_menu.h"
@ -76,9 +70,9 @@ struct gPuppyOptions
s16 sensitivityY;
s16 invertX;
s16 invertY;
s16 turnAggression;
s16 turnHelper;
s16 opaque;
s16 inputType;
s16 opacityType;
s16 debugCam;
};
@ -91,13 +85,12 @@ struct gPuppyStruct
s16 pitchTarget; // Vertical Direction that pitch tries to be.
f32 pitchAcceleration; // Vertical Direction that sets pitchTarget.
s16 zoom; // How far the camera is currently zoomed out
u8 zoomSet; // The current setting of which zoompoint to set the target to.
s16 zoomTarget; // The value that zoom tries to be.
s16 zoomPoints[3]; // An array containing distances.
s16 targetFloorHeight; // Mario's current floor height
s16 lastTargetFloorHeight; // Mirror's mario's floor height when his velocity is not above 0.
Vec3s pos; // Where the camera is
Vec3s focus; // Where the camera's looking
Vec3f pos; // Where the camera is
Vec3f focus; // Where the camera's looking
Vec3s pan; // An offset of the camera's focus
s32 intendedFlags; // The flagset the camera tries to be when it's not held hostage.
s32 flags; // Behaviour flags that affect different properties of the camera's behaviour
@ -118,7 +111,7 @@ struct gPuppyStruct
s16 edgePitch; // Pitch adjustment that's applied when stood near an edge. All pitch adjustment is clamped.
s16 moveZoom; // A small zoom value that's added on top of the regular zoom when moving. It's pretty subtle, but gives the feeling of a bit of speed.
u8 mode3Flags; // A flagset for classic mode.
u8 moveFlagAdd; // A bit that multiplies movement rate of axes when moving, to centre them faster.
u8 movementPitchVel; // A bit that multiplies movement rate of axes when moving, to centre them faster.
s16 targetDist[2]; // Used with secondary view targets to smooth out the between status.
s16 intendedTerrainPitch; // The pitch that the game wants the game to tilt towards, following the terrain.
s16 terrainPitch; // The pitch the game tilts towards, when following terrain inclines.
@ -153,9 +146,9 @@ struct sPuppyAngles
// Structurally, it's exactly the same as CutsceneSplinePoint
struct sPuppySpline
{
Vec3s pos; // The vector pos of the spline index itself.
s8 index; // The index of the spline. Ends with -1
u8 speed; // The amount of frames it takes to get through this index.
Vec3s pos; // The vector pos of the spline index itself.
};
// A bounding volume for activating puppycamera scripts and angles.
@ -225,6 +218,59 @@ extern void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacement
extern s32 puppycam_move_spline(struct sPuppySpline splinePos[], struct sPuppySpline splineFocus[], s32 mode, s32 index);
extern void puppycam_script_clear(void);
extern void puppycam_hud(void);
extern void puppycam_mario_inputs(struct MarioState *m);
/**
* Backwards compatability additions from Puppycam 1.
* This adds support for the original volume format, so you can directly import them in
* without having to make any further changes.
* Naturally, because it's the old format, they will be severely more limited in flexibility.
*/
#define NC_FLAG_XTURN PUPPYCAM_BEHAVIOUR_YAW_ROTATION
#define NC_FLAG_YTURN PUPPYCAM_BEHAVIOUR_PITCH_ROTATION
#define NC_FLAG_ZOOM 0 // Stub
#define NC_FLAG_8D PUPPYCAM_BEHAVIOUR_INPUT_8DIR
#define NC_FLAG_4D PUPPYCAM_BEHAVIOUR_INPUT_4DIR
#define NC_FLAG_2D PUPPYCAM_BEHAVIOUR_INPUT_2D
#define NC_FLAG_FOCUSX PUPPYCAM_BEHAVIOUR_X_MOVEMENT
#define NC_FLAG_FOCUSY PUPPYCAM_BEHAVIOUR_Y_MOVEMENT
#define NC_FLAG_FOCUSZ PUPPYCAM_BEHAVIOUR_Z_MOVEMENT
#define NC_FLAG_POSX PUPPYCAM_BEHAVIOUR_X_MOVEMENT
#define NC_FLAG_POSY PUPPYCAM_BEHAVIOUR_Y_MOVEMENT
#define NC_FLAG_POSZ PUPPYCAM_BEHAVIOUR_Z_MOVEMENT
#define NC_FLAG_COLLISION PUPPYCAM_BEHAVIOUR_COLLISION
#define NC_FLAG_SLIDECORRECT 0 // Stub
#define NC_MODE_NORMAL 1
#define NC_MODE_SLIDE 2
#define NC_MODE_FIXED 3
#define NC_MODE_2D 4
#define NC_MODE_8D 5
#define NC_MODE_FIXED_NOMOVE 6
#define NC_MODE_FIXED_NOTURN 7
#define NC_MODE_NOROTATE 8
struct newcam_hardpos {
u8 newcam_hard_levelID;
u8 newcam_hard_areaID;
u8 newcam_hard_permaswap;
u16 newcam_hard_modeset;
void *newcam_hard_script;
s16 newcam_hard_X1;
s16 newcam_hard_Y1;
s16 newcam_hard_Z1;
s16 newcam_hard_X2;
s16 newcam_hard_Y2;
s16 newcam_hard_Z2;
s16 newcam_hard_camX;
s16 newcam_hard_camY;
s16 newcam_hard_camZ;
s16 newcam_hard_lookX;
s16 newcam_hard_lookY;
s16 newcam_hard_lookZ;
};
extern struct newcam_hardpos newcam_fixedcam[];
#endif
#endif // BETTERCAMERA_H

View file

@ -0,0 +1,27 @@
#include "../bettercamera.h"
///This is the bit that defines where the angles happen. They're basically environment boxes that dictate camera behaviour.
///Permaswap is a boolean that simply determines wether or not when the camera changes at this point it stays changed. 0 means it resets when you leave, and 1 means it stays changed.
///The camera position fields accept "32767" as an ignore flag.
///The script supports anything that does not take an argument. It's reccomended to keep the scripts in puppycam_scripts.inc.c for the sake of cleanliness.
///If you do not wish to use a script in the angle, then just leave the field as 0.
struct newcam_hardpos newcam_fixedcam[] =
{
#ifdef PUPPYCAM_SAMPLES
// Example Scripts
{/*Level ID*/ 16,/*Area ID*/ 1,/*Permaswap*/ 0,/*Mode*/ NC_MODE_FIXED_NOMOVE,/*Script*/ 0, //Standard params.
/*X begin*/ -540,/*Y begin*/ 800,/*Z begin*/ -3500, //Where the activation box begins
/*X end*/ 540,/*Y end*/ 2000,/*Z end*/ -1500, //Where the activation box ends.
/*Cam X*/ 0,/*Cam Y*/ 1500,/*Cam Z*/ -1000, //The position the camera gets placed for NC_MODE_FIXED and NC_MODE_FIXED_NOMOVE
/*Look X*/ 0,/*Look Y*/ 800,/*Look Z*/ -2500}, //The position the camera looks at for NC_MODE_FIXED_NOMOVE
///Another example angle. This activates a script that slowly rotates the camera around the area.
{/*Level ID*/ 16,/*Area ID*/ 1,/*Permaswap*/ 0,/*Mode*/ NC_MODE_NOROTATE,/*Script*/ 0, //Standard params.
/*X begin*/ 5716,/*Y begin*/ 400,/*Z begin*/ -859, //Where the activation box begins
/*X end*/ 6908,/*Y end*/ 1000,/*Z end*/ 62, //Where the activation box ends.
/*Cam X*/ 32767,/*Cam Y*/ 32767,/*Cam Z*/ 32767, //The position the camera gets placed for NC_MODE_FIXED and NC_MODE_FIXED_NOMOVE
/*Look X*/ 32767,/*Look Y*/ 32767,/*Look Z*/ 32767}, //The position the camera looks at for NC_MODE_FIXED_NOMOVE
#endif
};

View file

@ -1484,25 +1484,11 @@ void update_mario_inputs(struct MarioState *m) {
update_mario_geometry_inputs(m);
debug_print_speed_action_normal(m);
#ifdef CHEATS_ACTIONS
cheats_mario_inputs(m);
#endif
#ifdef BETTERCAMERA
if (gPuppyCam.enabled && (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE && gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS)) {
m->input = INPUT_FIRST_PERSON;
}
if (gPuppyCam.enabled && (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ENTER_FIRST_PERSON)
&& (gPuppyCam.options.inputType == PUPPYCAM_INPUT_TYPE_CLASSIC)) {
m->input |= INPUT_FIRST_PERSON;
} else if (!gPuppyCam.enabled || gPuppyCam.options.inputType != PUPPYCAM_INPUT_TYPE_CLASSIC) {
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ZOOMED_IN) {
gPuppyCam.mode3Flags |= PUPPYCAM_MODE3_ZOOMED_MED;
gPuppyCam.mode3Flags &= ~(PUPPYCAM_MODE3_ZOOMED_IN | PUPPYCAM_MODE3_ENTER_FIRST_PERSON);
}
}
puppycam_mario_inputs(m);
#endif
if (gCameraMovementFlags & CAM_MOVE_C_UP_MODE) {

View file

@ -123,11 +123,11 @@ ConfigPuppyCam configPuppyCam = {
#endif
.invertX = true,
.invertY = true,
.sensX = 100,
.sensY = 100,
.aggression = 50,
.scheme = 0, // PUPPYCAM_INPUT_TYPE_DOUBLE_TAB
.opacity = 1, // PUPPYCAM_OPACITY_TYPE_FADE
.sensX = 5,
.sensY = 5,
.helper = true,
.opaque = true,
.input = 0, // PUPPYCAM_INPUT_TYPE_DOUBLE_TAB
.debug = false,
};
#endif
@ -194,9 +194,9 @@ static const struct ConfigOption options[] = {
{.name = "bettercam_inverty", .type = CONFIG_TYPE_BOOL, .boolValue = &configPuppyCam.invertY},
{.name = "bettercam_xsens", .type = CONFIG_TYPE_UINT, .uintValue = &configPuppyCam.sensX},
{.name = "bettercam_ysens", .type = CONFIG_TYPE_UINT, .uintValue = &configPuppyCam.sensY},
{.name = "bettercam_aggression", .type = CONFIG_TYPE_UINT, .uintValue = &configPuppyCam.aggression},
{.name = "bettercam_scheme", .type = CONFIG_TYPE_UINT, .uintValue = &configPuppyCam.scheme},
{.name = "bettercam_opacity", .type = CONFIG_TYPE_UINT, .uintValue = &configPuppyCam.opacity},
{.name = "bettercam_turnhelper", .type = CONFIG_TYPE_BOOL, .boolValue = &configPuppyCam.helper},
{.name = "bettercam_opaque", .type = CONFIG_TYPE_BOOL, .boolValue = &configPuppyCam.opaque},
{.name = "bettercam_inputtype", .type = CONFIG_TYPE_UINT, .uintValue = &configPuppyCam.input},
{.name = "bettercam_debug", .type = CONFIG_TYPE_BOOL, .boolValue = &configPuppyCam.debug},
#endif
};

View file

@ -78,11 +78,11 @@ typedef struct {
#endif
bool invertX;
bool invertY;
bool helper;
bool opaque;
unsigned int sensX;
unsigned int sensY;
unsigned int aggression;
unsigned int scheme;
unsigned int opacity;
unsigned int input;
bool debug;
} ConfigPuppyCam;