From 83d8a8383b0d3bd8977fefabafb4a59d34cb1d21 Mon Sep 17 00:00:00 2001 From: Artem Golubikhin Date: Mon, 11 Apr 2016 01:25:59 +0300 Subject: [PATCH] SV_HullForBsp: use hull center instead of corner (CVar sv_rehlds_hull_centering) --- rehlds/engine/server.h | 1 + rehlds/engine/sv_main.cpp | 2 ++ rehlds/engine/world.cpp | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index b0a339e..a86c0e8 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -543,6 +543,7 @@ extern cvar_t sv_echo_unknown_cmd; extern cvar_t sv_auto_precache_sounds_in_models; extern cvar_t sv_delayed_spray_upload; extern cvar_t sv_rehlds_force_dlmax; +extern cvar_t sv_rehlds_hull_centering; #endif extern int sv_playermodel; diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 614a568..bb0f6cb 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -304,6 +304,7 @@ cvar_t sv_auto_precache_sounds_in_models = { "sv_auto_precache_sounds_in_models" cvar_t sv_delayed_spray_upload = { "sv_delayed_spray_upload", "0", 0, 0.0f, nullptr }; cvar_t sv_rehlds_force_dlmax = { "sv_rehlds_force_dlmax", "0", 0, 0.0f, nullptr }; cvar_t listipcfgfile = { "listipcfgfile", "listip.cfg", 0, 0.0f, nullptr }; +cvar_t sv_rehlds_hull_centering = { "sv_rehlds_hull_centering", "0", 0, 0.0f, nullptr }; #endif /* ../engine/sv_main.c:113 */ @@ -7775,6 +7776,7 @@ void SV_Init(void) Cvar_RegisterVariable(&sv_auto_precache_sounds_in_models); Cvar_RegisterVariable(&sv_delayed_spray_upload); Cvar_RegisterVariable(&sv_rehlds_force_dlmax); + Cvar_RegisterVariable(&sv_rehlds_hull_centering); #endif for (int i = 0; i < MAX_MODELS; i++) diff --git a/rehlds/engine/world.cpp b/rehlds/engine/world.cpp index a0517e9..3e0b288 100644 --- a/rehlds/engine/world.cpp +++ b/rehlds/engine/world.cpp @@ -190,8 +190,23 @@ struct hull_s *SV_HullForBsp(edict_t *ent, const vec_t *mins, const vec_t *maxs, else hull = &model->hulls[3]; } +// TODO: add cvar for this? +#ifdef REHLDS_FIXES + if ( sv_rehlds_hull_centering.value + && mins[0] + maxs[0] == 0.0f) + offset[0] = 0.0f; + else + offset[0] = hull->clip_mins[0] - mins[0]; + + if ( sv_rehlds_hull_centering.value + && mins[1] + maxs[1] == 0.0f) + offset[1] = 0.0f; + else + offset[1] = hull->clip_mins[1] - mins[1]; +#else // REHLDS_FIXES offset[0] = hull->clip_mins[0] - mins[0]; offset[1] = hull->clip_mins[1] - mins[1]; +#endif // REHLDS_FIXES offset[2] = hull->clip_mins[2] - mins[2]; } else