From 6d186bdd4968383828eaf2e8e534a8c6efcd347e Mon Sep 17 00:00:00 2001 From: Fazana Date: Fri, 31 Jul 2020 23:07:18 +0100 Subject: [PATCH] ExtBounds support hi --- enhancements/puppycam.inc.c | 5 ++++ enhancements/puppycam_collision.inc.c | 38 ++++++++++++++++----------- src/pc/configfile.c | 3 +-- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/enhancements/puppycam.inc.c b/enhancements/puppycam.inc.c index 78fd5e8274..eedb206c8a 100644 --- a/enhancements/puppycam.inc.c +++ b/enhancements/puppycam.inc.c @@ -33,6 +33,11 @@ NC_MODE_NOTURN: Disables horizontal and vertical control of the camera. Perfect //#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 EXT_BOUNDS + +#ifdef EXT_BOUNDS + #define MULTI 4.0f +#endif // EXT_BOUNDS //!Hardcoded camera angle stuff. They're essentially area boxes that when Mario is inside, will trigger some view changes. diff --git a/enhancements/puppycam_collision.inc.c b/enhancements/puppycam_collision.inc.c index b4a2cc7aa1..bbccd43f6e 100644 --- a/enhancements/puppycam_collision.inc.c +++ b/enhancements/puppycam_collision.inc.c @@ -2,15 +2,7 @@ #include "engine/surface_load.h" #include "engine/math_util.h" -///Experimental and unfinished, so don't mess with this. -//Compatability support for the popular existing Extended Boundaries hack. -#ifdef EXT_BOUNDS - #define MULTI 4.0f - #define BOUND 0x7FFF -#else - #define MULTI 1.0f - #define BOUND 0x2000 -#endif // EXT_BOUNDS +//#define EXT_BOUNDS /** * Raycast functions @@ -132,6 +124,16 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve f32 step, dx, dz; u32 i; + #ifdef EXT_BOUNDS + orig[0] /= MULTI; + orig[1] /= MULTI; + orig[2] /= MULTI; + + dir[0] /= MULTI; + dir[1] /= MULTI; + dir[2] /= MULTI; + #endif // EXT_BOUNDS + // Set that no surface has been hit *hit_surface = NULL; vec3f_sum(hit_pos, orig, dir); @@ -143,8 +145,8 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve vec3f_normalize(normalized_dir); // Get our cell coordinate - fCellX = (orig[0] + BOUND) / CELL_SIZE / MULTI; - fCellZ = (orig[2] + BOUND) / CELL_SIZE / MULTI; + fCellX = (orig[0] + BOUND) / CELL_SIZE; + fCellZ = (orig[2] + BOUND) / CELL_SIZE; cellX = (s16)fCellX; cellZ = (s16)fCellZ; @@ -157,12 +159,12 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve // Get cells we cross using DDA if (abs(dir[0]) >= abs(dir[2])) - step = abs(dir[0]) / CELL_SIZE / MULTI; + step = abs(dir[0]) / CELL_SIZE; else - step = abs(dir[2]) / CELL_SIZE / MULTI; + step = abs(dir[2]) / CELL_SIZE; - dx = dir[0] / step / CELL_SIZE / MULTI; - dz = dir[2] / step / CELL_SIZE / MULTI; + dx = dir[0] / step / CELL_SIZE; + dz = dir[2] / step / CELL_SIZE; for (i = 0; i < step && *hit_surface == NULL; i++) { @@ -174,4 +176,10 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve cellX = (s16)fCellX; cellZ = (s16)fCellZ; } + + #ifdef EXT_BOUNDS + hit_pos[0] *= MULTI; + hit_pos[1] *= MULTI; + hit_pos[2] *= MULTI; + #endif // EXT_BOUNDS } diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 49488ab7f3..d5f3adcb14 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -77,8 +77,6 @@ static const struct ConfigOption options[] = { {.name = "puppycam_stopping_speed", .type = CONFIG_TYPE_UINT, .uintValue = &puppycam_degrade}, {.name = "puppycam_centre_aggression", .type = CONFIG_TYPE_UINT, .uintValue = &puppycam_aggression}, {.name = "puppycam_pan_amount", .type = CONFIG_TYPE_UINT, .uintValue = &puppycam_panlevel}, - - }; // Reads an entire line from a file (excluding the newline character) and returns an allocated string @@ -225,6 +223,7 @@ void configfile_save(const char *filename) { FILE *file; printf("Saving configuration to '%s'\n", filename); + printf("There should be '%d' options\n", ARRAY_LEN(options)); file = fopen(filename, "w"); if (file == NULL) {