Skip to content

Commit

Permalink
ExtBounds support
Browse files Browse the repository at this point in the history
hi
  • Loading branch information
FazanaJ committed Jul 31, 2020
1 parent 01de702 commit 6d186bd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
5 changes: 5 additions & 0 deletions enhancements/puppycam.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
38 changes: 23 additions & 15 deletions enhancements/puppycam_collision.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand All @@ -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++)
{
Expand All @@ -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
}
3 changes: 1 addition & 2 deletions src/pc/configfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6d186bd

Please sign in to comment.