From 1e9f8ec5f415213537c1d34b69e1e50e2f44b64f Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 25 Sep 2020 21:40:59 -0700 Subject: [PATCH] Make bettercam/puppycam respect NO_CAM_COLLISION --- src/engine/surface_collision.c | 6 +++++- src/game/bettercamera.inc.h | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index aed34e276..ee54327d8 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -909,6 +909,10 @@ void find_surface_on_ray_list(struct SurfaceNode *list, Vec3f orig, Vec3f dir, f if (list->surface->lowerY > top || list->surface->upperY < bottom) continue; + // Reject no-cam collision surfaces + if (gCheckingSurfaceCollisionsForCamera && (list->surface->flags & SURFACE_FLAG_NO_CAM_COLLISION)) + continue; + // Check intersection between the ray and this surface if ((hit = ray_surface_intersect(orig, dir, dir_length, list->surface, chk_hit_pos, &length)) != 0) { @@ -978,7 +982,7 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve } // increase collision checking precision (normally 1) - f32 precision = 5; + f32 precision = 3; // Get cells we cross using DDA if (absx(dir[0]) >= absx(dir[2])) diff --git a/src/game/bettercamera.inc.h b/src/game/bettercamera.inc.h index 3ab7067cf..f428eeac3 100644 --- a/src/game/bettercamera.inc.h +++ b/src/game/bettercamera.inc.h @@ -10,6 +10,7 @@ #include "engine/surface_collision.h" #include "pc/configfile.h" #include "pc/controller/controller_mouse.h" + #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) //quick and dirty fix for some older MinGW.org mingwrt #else @@ -18,7 +19,7 @@ #define NEW_CAM_BOUNDING_BOX_RAYS 4 #define NEW_CAM_BOUNDING_BOX_HRADIUS 250 -#define NEW_CAM_BOUNDING_BOX_VRADIUS 50 +#define NEW_CAM_BOUNDING_BOX_VRADIUS 100 /** Quick explanation of the camera modes @@ -527,6 +528,7 @@ static void newcam_collision(void) { camdir[2] = newcam_pos[2]-newcam_lookat[2]; find_surface_on_ray(newcam_pos_target, camdir, &surf, hitpos); + newcam_coldist = sqrtf((newcam_pos_target[0] - hitpos[0]) * (newcam_pos_target[0] - hitpos[0]) + (newcam_pos_target[1] - hitpos[1]) * (newcam_pos_target[1] - hitpos[1]) + (newcam_pos_target[2] - hitpos[2]) * (newcam_pos_target[2] - hitpos[2])); if (surf) {