From bb9f7eb51acf8187cc4d7a5b3a6010d681c54a2d Mon Sep 17 00:00:00 2001 From: Shpoike Date: Tue, 8 Aug 2023 19:17:18 +0100 Subject: [PATCH] Add r_nolerp_list (matching QS) for people who insist on breaking lerping on eg wall torches. Also add a dupe cvar name to provide compat with QS's r_noshadow_list. --- engine/client/cl_ents.c | 6 ++++++ engine/common/com_mesh.c | 12 ++++++++++-- engine/gl/gl_alias.c | 2 +- engine/gl/gl_model.c | 23 ++++++++++++++++------- engine/gl/gl_model.h | 6 +++--- 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/engine/client/cl_ents.c b/engine/client/cl_ents.c index 327158477..377b4c371 100644 --- a/engine/client/cl_ents.c +++ b/engine/client/cl_ents.c @@ -4303,6 +4303,12 @@ void CL_LinkPacketEntities (void) Con_DPrintf("Bad modelindex (%i)\n", state->modelindex); continue; } + if (model->loadstate != MLS_LOADED) + { + if (model->loadstate == MLS_NOTLOADED) + Mod_LoadModel(model, MLV_WARN); + continue; //still waiting for it to load, don't poke anything here + } //DP extension. .modelflags (which is sent in the high parts of effects) allows to specify exactly the q1-compatible flags. //the extra bit allows for setting to 0. diff --git a/engine/common/com_mesh.c b/engine/common/com_mesh.c index e44b96b4e..9442a9b81 100644 --- a/engine/common/com_mesh.c +++ b/engine/common/com_mesh.c @@ -1992,7 +1992,7 @@ qboolean Alias_GAliasBuildMesh(mesh_t *mesh, vbo_t **vbop, galiasinfo_t *inf, in frame1=floor(lerp); frame2=frame1+1; lerp-=frame1; - if (r_noframegrouplerp.ival) + if (r_noframegrouplerp.ival || (e->model->engineflags&MDLF_NOLERP)) lerp = 0; if (g1->loop) { @@ -2006,7 +2006,15 @@ qboolean Alias_GAliasBuildMesh(mesh_t *mesh, vbo_t **vbop, galiasinfo_t *inf, in } } else //don't bother with a four way lerp. Yeah, this will produce jerkyness with models with just framegroups. - { //FIXME: find the two poses with the strongest influence. + { + if (e->model->engineflags&MDLF_NOLERP) + { + if (lerp > 0.5) + g2 = g1; + else + g1 = g2; + } + //FIXME: find the two poses with the strongest influence. frame1=0; frame2=0; } diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index b15689d21..14d1e9f48 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -2185,7 +2185,7 @@ void R_DrawGAliasShadowVolume(entity_t *e, vec3_t lightpos, float radius) if (qrenderer != QR_OPENGL) return; - if (clmodel->engineflags & (MDLF_FLAME | MDLF_BOLT)) + if (clmodel->engineflags & MDLF_NOSHADOWS) return; if (r_noaliasshadows.ival) return; diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index 6a73da339..68181dd97 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -43,8 +43,9 @@ cvar_t mod_lightpoint_distance = CVARD("mod_lightpoint_distance", "8192", "Th #ifdef SPRMODELS cvar_t r_sprite_backfacing = CVARD ("r_sprite_backfacing", "0", "Make oriented sprites face backwards relative to their orientation, for compat with q1."); #endif +cvar_t r_nolerp_list = CVARFD ("r_nolerp_list"/*qs*/, "", CVAR_RENDERERLATCH, "Models in this list will not interpolate. Any models included here should be considered bad."); #ifdef RTLIGHTS -cvar_t r_noEntityCastShadowList = CVARD ("r_noEntityCastShadowList", "progs/missile.mdl,progs/flame.mdl,progs/flame2.mdl,progs/lavaball.mdl,progs/grenade.mdl,progs/spike.mdl,progs/s_spike.mdl,progs/laser.mdl,progs/lspike.mdl,progs/candle.mdl", "Models in this list will not cast shadows."); +cvar_t r_noshadow_list = CVARAFD ("r_noshadow_list"/*qs*/, "r_noEntityCastShadowList", "progs/missile.mdl,progs/flame.mdl,progs/flame2.mdl,progs/lavaball.mdl,progs/grenade.mdl,progs/spike.mdl,progs/s_spike.mdl,progs/laser.mdl,progs/lspike.mdl,progs/candle.mdl", CVAR_RENDERERLATCH, "Models in this list will not cast shadows."); #endif #ifdef SERVERONLY cvar_t gl_overbright, gl_specular, gl_load24bit, r_replacemodels, gl_miptexLevel, r_fb_bmodels; //all of these can/should default to 0 @@ -676,8 +677,9 @@ void Mod_Init (qboolean initial) Cvar_Register(&mod_lightpoint_distance, NULL); Cvar_Register (&r_meshpitch, "Gamecode"); Cvar_Register (&r_meshroll, "Gamecode"); + Cvar_Register(&r_nolerp_list, "Graphical Nicaties"); #ifdef RTLIGHTS - Cvar_Register(&r_noEntityCastShadowList, "Graphical Nicaties"); + Cvar_Register(&r_noshadow_list, "Graphical Nicaties"); #endif Cmd_AddCommandD("sv_saveentfile", Mod_SaveEntFile_f, "Dumps a copy of the map's entities to disk, so that it can be edited and used as a replacement for slightly customised maps."); Cmd_AddCommandD("mod_showent", Mod_ShowEnt_f, "Allows you to quickly search through a map's entities."); @@ -1140,7 +1142,7 @@ static void Mod_LoadModelWorker (void *ctx, void *data, size_t a, size_t b) || !strcmp(mod->publicname, "models/cflmtrch.mdl") //hexen2 wall torch #endif ) - mod->engineflags |= MDLF_FLAME; + mod->engineflags |= MDLF_FLAME|MDLF_NOSHADOWS; else if (!strcmp(mod->publicname, "progs/bolt.mdl") || !strcmp(mod->publicname, "progs/bolt2.mdl") || !strcmp(mod->publicname, "progs/bolt3.mdl") @@ -1151,7 +1153,7 @@ static void Mod_LoadModelWorker (void *ctx, void *data, size_t a, size_t b) || !strcmp(mod->publicname, "models/stice.mdl") #endif ) - mod->engineflags |= MDLF_BOLT; + mod->engineflags |= MDLF_NOSHADOWS; else if (!strcmp(mod->publicname, "progs/backpack.mdl")) mod->engineflags |= MDLF_NOTREPLACEMENTS; else if (!strcmp(mod->publicname, "progs/eyes.mdl")) @@ -1368,13 +1370,20 @@ model_t *Mod_LoadModel (model_t *mod, enum mlverbosity_e verbose) { if (mod->loadstate == MLS_NOTLOADED && *mod->name != '*') { -#ifdef RTLIGHTS - char *s = strstr(r_noEntityCastShadowList.string, mod->publicname); + const char *s = strstr(r_nolerp_list.string, mod->publicname); COM_AssertMainThread("Mod_LoadModel"); if (s) { size_t l = strlen(mod->publicname); - if ((s == r_noEntityCastShadowList.string || s[-1]==',') && (s[l] == 0 || s[l] == ',')) + if ((s == r_nolerp_list.string || s[-1]==',') && (s[l] == 0 || s[l] == ',')) + mod->engineflags |= MDLF_NOLERP; + } +#ifdef RTLIGHTS + s = strstr(r_noshadow_list.string, mod->publicname); + if (s) + { + size_t l = strlen(mod->publicname); + if ((s == r_noshadow_list.string || s[-1]==',') && (s[l] == 0 || s[l] == ',')) mod->engineflags |= MDLF_NOSHADOWS; } #endif diff --git a/engine/gl/gl_model.h b/engine/gl/gl_model.h index 2c3db8984..4c88ac9a1 100644 --- a/engine/gl/gl_model.h +++ b/engine/gl/gl_model.h @@ -972,6 +972,7 @@ typedef struct model_s char name[MAX_QPATH]; //actual name on disk char publicname[MAX_QPATH]; //name that the gamecode etc sees int datasequence; //if it gets old enough, we can purge it. + int engineflags; // int loadstate; //MLS_ qboolean tainted; // differs from the server's version. this model will be invisible as a result, to avoid spiked models. qboolean pushdepth; // bsp submodels have this flag set so you don't get z fighting on co-planar surfaces. @@ -986,7 +987,6 @@ typedef struct model_s synctype_t synctype; int flags; - int engineflags; int particleeffect; int particletrail; int traildefaultindex; @@ -1135,10 +1135,10 @@ typedef struct model_s #define MDLF_FLAME 0x0020 // can be excluded with r_drawflame, fullbright render hack #define MDLF_DOCRC 0x0040 // model needs CRC built #define MDLF_NEEDOVERBRIGHT 0x0080 // only overbright these models with gl_overbright_all set -#define MDLF_BOLT 0x0100 // doesn't produce shadows +#define MDLF_NOSHADOWS 0x0100 // doesn't produce shadows for one reason or another #define MDLF_NOTREPLACEMENTS 0x0200 // can be considered a cheat, disable texture replacements #define MDLF_EZQUAKEFBCHEAT 0x0400 // this is a blatent cheat, one that can disadvantage us fairly significantly if we don't support it. -#define MDLF_NOSHADOWS 0x0800 // do not cast shadows from this entity, ever. +#define MDLF_NOLERP 0x0800 // doesn't lerp, ever. for dodgy models that don't scale to nothingness before jumping. #define MDLF_RECALCULATERAIN 0x1000 // particles changed, recalculate any sky polys //============================================================================