From b1ae2b76d55c87133bc0c17bf7ef8b7545b759d0 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sat, 15 Apr 2023 18:46:48 +0300 Subject: knee height bug fix --- src/player.c | 2 +- src/sector.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/player.c b/src/player.c index 6ea618b..d81cc52 100644 --- a/src/player.c +++ b/src/player.c @@ -3,7 +3,6 @@ #define DEFAULT_STAND_HEIGHT 6.0f #define DEFAULT_DUCK_HEIGHT 2.5f - #define DEFAULT_HEAD_MARGIN 1.0f #define DEFAULT_KNEE_HEIGHT 2.0f @@ -18,6 +17,7 @@ void player_default(player_t *player) player->stand_height = DEFAULT_STAND_HEIGHT; player->duck_height = DEFAULT_DUCK_HEIGHT; player->head_margin = DEFAULT_HEAD_MARGIN; + player->knee_height = DEFAULT_KNEE_HEIGHT; player->ducking = false; } diff --git a/src/sector.c b/src/sector.c index f43ab86..2f1a7fe 100644 --- a/src/sector.c +++ b/src/sector.c @@ -175,7 +175,7 @@ void map_detect_collision(map_t *map) // slide along the wall if(sect->neighbors[i] == (size_t)-1 || hole_high < player->pos.z + player->head_margin - || hole_low - player->pos.z > player->knee_height) { + || hole_low - (player->pos.z - eyeheight ) > player->knee_height) { // formula from wikipedia float xd = vert(s1).x - vert(s0).x, yd = vert(s1).y - vert(s0).y; player->velocity.x = xd * (dx*xd + yd*dy) / (xd*xd + yd*yd); -- cgit v1.2.3