From cb72769aa9117eb78810b4d6314f23aa2c99c63f Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 14 Sep 2023 20:35:45 +0900 Subject: [PATCH] [model] Clean up the model struct a little Mostly just removing some (near) dead fields and making the flags/effects more clear on what it's for. --- include/QF/model.h | 27 ++++++++++++--------------- libs/client/cl_effects.c | 16 ++++++++-------- libs/models/alias/gl_model_alias.c | 1 - libs/models/alias/model_alias.c | 2 +- libs/models/model.c | 1 - nq/source/cl_ents.c | 12 ++++++------ nq/source/sv_pr_cmds.c | 7 +------ qw/source/cl_entparse.c | 3 +-- qw/source/cl_ents.c | 6 +++--- 9 files changed, 32 insertions(+), 43 deletions(-) diff --git a/include/QF/model.h b/include/QF/model.h index 2e01dd1f9..e6f796224 100644 --- a/include/QF/model.h +++ b/include/QF/model.h @@ -374,15 +374,17 @@ typedef enum { mod_num_types } modtype_t; -#define EF_ROCKET 1 // leave a trail -#define EF_GRENADE 2 // leave a trail -#define EF_GIB 4 // leave a trail -#define EF_ROTATE 8 // rotate (bonus items) -#define EF_TRACER 16 // green split trail -#define EF_ZOMGIB 32 // small blood trail -#define EF_TRACER2 64 // orange split trail + rotate -#define EF_TRACER3 128 // purple trail -#define EF_GLOWTRAIL 4096 // glowcolor particle trail +typedef enum { + ME_ROCKET = 1, // leave a trail + ME_GRENADE = 2, // leave a trail + ME_GIB = 4, // leave a trail + ME_ROTATE = 8, // rotate (bonus items) + ME_TRACER = 16, // green split trail + ME_ZOMGIB = 32, // small blood trail + ME_TRACER2 = 64, // orange split trail + rotate + ME_TRACER3 = 128, // purple trail + ME_GLOWTRAIL = 4096, // glowcolor particle trail +} modeffects_t; typedef struct model_s { //FIXME use pointers. needs care in bsp submodel loading @@ -391,13 +393,12 @@ typedef struct model_s { const struct vpath_s *vpath;// virtual path where this model was found bool needload; // bmodels and sprites don't cache normally aliashdr_t *aliashdr; // if not null, alias model is not cached - bool hasfullbrights; modtype_t type; int numframes; synctype_t synctype; - int flags; + modeffects_t effects; // lighting info float min_light; @@ -409,10 +410,6 @@ typedef struct model_s { // FIXME: bbox cruft has to stay until sw rendering gets updated vec3_t mins, maxs; -// solid volume for clipping - bool clipbox; - vec3_t clipmins, clipmaxs; - // brush model //FIXME should be a pointer (submodels make things tricky) mod_brush_t brush; diff --git a/libs/client/cl_effects.c b/libs/client/cl_effects.c index 9ef28f0d7..04863e93d 100644 --- a/libs/client/cl_effects.c +++ b/libs/client/cl_effects.c @@ -170,7 +170,7 @@ CL_ModelEffects (entity_t ent, int glow_color, double time) vec4f_t ent_origin = Transform_GetWorldPosition (transform); // add automatic particle trails - if (model->flags & EF_ROCKET) { + if (model->effects & ME_ROCKET) { uint32_t light = attach_light_ent (ent); Ent_SetComponent (light, scene_dynlight, ent.reg, &(dlight_t) { .origin = ent_origin, @@ -182,19 +182,19 @@ CL_ModelEffects (entity_t ent, int glow_color, double time) Light_LinkLight (cl_world.scene->lights, light); clp_funcs->RocketTrail (*old_origin, ent_origin); renderer->noshadows = 1; - } else if (model->flags & EF_GRENADE) + } else if (model->effects & ME_GRENADE) clp_funcs->GrenadeTrail (*old_origin, ent_origin); - else if (model->flags & EF_GIB) + else if (model->effects & ME_GIB) clp_funcs->BloodTrail (*old_origin, ent_origin); - else if (model->flags & EF_ZOMGIB) + else if (model->effects & ME_ZOMGIB) clp_funcs->SlightBloodTrail (*old_origin, ent_origin); - else if (model->flags & EF_TRACER) + else if (model->effects & ME_TRACER) clp_funcs->WizTrail (*old_origin, ent_origin); - else if (model->flags & EF_TRACER2) + else if (model->effects & ME_TRACER2) clp_funcs->FlameTrail (*old_origin, ent_origin); - else if (model->flags & EF_TRACER3) + else if (model->effects & ME_TRACER3) clp_funcs->VoorTrail (*old_origin, ent_origin); - else if (model->flags & EF_GLOWTRAIL) + else if (model->effects & ME_GLOWTRAIL) clp_funcs->GlowTrail (*old_origin, ent_origin, glow_color); } diff --git a/libs/models/alias/gl_model_alias.c b/libs/models/alias/gl_model_alias.c index 4dee2b98e..96f3b26fa 100644 --- a/libs/models/alias/gl_model_alias.c +++ b/libs/models/alias/gl_model_alias.c @@ -98,7 +98,6 @@ gl_Mod_LoadSkin (mod_alias_ctx_t *alias_ctx, byte *texels, Sys_MaskPrintf (SYS_glt, "%s %d\n", name->str, texnum); skindesc->texnum = texnum; skindesc->fb_texnum = fb_texnum; - alias_ctx->mod->hasfullbrights = fb_texnum; dstring_delete (name); // alpha param was true for non group skins } diff --git a/libs/models/alias/model_alias.c b/libs/models/alias/model_alias.c index a080fc0e9..0c89e2d65 100644 --- a/libs/models/alias/model_alias.c +++ b/libs/models/alias/model_alias.c @@ -272,7 +272,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator) header->crc = crc; - mod->flags = LittleLong (pinmodel->flags); + mod->effects = LittleLong (pinmodel->flags); // endian-adjust and copy the data, starting with the alias model header pmodel->ident = LittleLong (pinmodel->ident); diff --git a/libs/models/model.c b/libs/models/model.c index 729aa624d..3482fb5c1 100644 --- a/libs/models/model.c +++ b/libs/models/model.c @@ -240,7 +240,6 @@ Mod_RealLoadModel (model_t *mod, bool crash, cache_allocator_t allocator) // call the apropriate loader mod->needload = false; - mod->hasfullbrights = false; switch (LittleLong (*buf)) { case IQM_SMAGIC: diff --git a/nq/source/cl_ents.c b/nq/source/cl_ents.c index e9d3318f8..b725e05cb 100644 --- a/nq/source/cl_ents.c +++ b/nq/source/cl_ents.c @@ -168,7 +168,7 @@ CL_RelinkEntities (void) entity_state_t *new, *old; float bobjrotate, frac, f; int i, j; - int model_flags; + int model_effects; // determine partial update time frac = CL_LerpPoint (); @@ -254,9 +254,9 @@ CL_RelinkEntities (void) VectorCopy (ent_colormod[new->colormod], renderer->colormod); renderer->colormod[3] = ENTALPHA_DECODE (new->alpha); - model_flags = 0; + model_effects = 0; if (renderer->model) { - model_flags = renderer->model->flags; + model_effects = renderer->model->effects; } if (SET_TEST_MEMBER (&cl_forcelink, i)) { @@ -284,7 +284,7 @@ CL_RelinkEntities (void) // interpolate the origin and angles vec3_t angles, d; vec4f_t origin = old->origin + f * delta; - if (!(model_flags & EF_ROTATE)) { + if (!(model_effects & ME_ROTATE)) { VectorSubtract (new->angles, old->angles, d); for (j = 0; j < 3; j++) { if (d[j] > 180) @@ -307,7 +307,7 @@ CL_RelinkEntities (void) && !chase_active); // rotate binary objects locally - if (model_flags & EF_ROTATE) { + if (model_effects & ME_ROTATE) { vec3_t angles; VectorCopy (new->angles, angles); angles[YAW] = bobjrotate; @@ -333,7 +333,7 @@ CL_RelinkEntities (void) if (VectorDistance_fast (old->origin, org) > (256 * 256)) { old->origin = org; } - if (model_flags & ~EF_ROTATE) + if (model_effects & ~ME_ROTATE) CL_ModelEffects (ent, new->glow_color, cl.time); SET_REMOVE (&cl_forcelink, i); diff --git a/nq/source/sv_pr_cmds.c b/nq/source/sv_pr_cmds.c index 757d3a8c7..39e3150ef 100644 --- a/nq/source/sv_pr_cmds.c +++ b/nq/source/sv_pr_cmds.c @@ -263,12 +263,7 @@ PF_setmodel (progs_t *pr, void *data) mod = sv.models[i]; if (mod) { - // FIXME disabled for now as setting clipmins/maxs is currently - // too messy - //if (mod->type == mod_brush) - // SetMinMaxSize (pr, e, mod->clipmins, mod->clipmaxs, true); - //else - SetMinMaxSize (pr, e, mod->mins, mod->maxs, true); + SetMinMaxSize (pr, e, mod->mins, mod->maxs, true); } else { SetMinMaxSize (pr, e, vec3_origin, vec3_origin, true); } diff --git a/qw/source/cl_entparse.c b/qw/source/cl_entparse.c index a8f454410..c7ba67769 100644 --- a/qw/source/cl_entparse.c +++ b/qw/source/cl_entparse.c @@ -550,8 +550,7 @@ CL_SetSolidEntities (void) continue; if (!cl_world.models.a[state->modelindex]) continue; - if (cl_world.models.a[state->modelindex]->brush.hulls[1].firstclipnode - || cl_world.models.a[state->modelindex]->clipbox) { + if (cl_world.models.a[state->modelindex]->brush.hulls[1].firstclipnode){ if (pmove.numphysent == MAX_PHYSENTS) { Sys_Printf ("WARNING: entity physent overflow, email " "quakeforge-devel@lists.quakeforge.net\n"); diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index 371f38884..6dca246d5 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -263,7 +263,7 @@ CL_LinkPacketEntities (void) CL_TransformEntity (ent, new->scale / 16, new->angles, new->origin); animation->pose1 = animation->pose2 = -1; - } else if (!(renderer->model->flags & EF_ROTATE)) { + } else if (!(renderer->model->effects & ME_ROTATE)) { vec3_t angles, d; vec4f_t origin = old->origin + f * delta; // interpolate the origin and angles @@ -286,7 +286,7 @@ CL_LinkPacketEntities (void) } // rotate binary objects locally - if (renderer->model->flags & EF_ROTATE) { + if (renderer->model->effects & ME_ROTATE) { vec3_t angles; angles[PITCH] = 0; angles[YAW] = anglemod (100 * cl.time); @@ -298,7 +298,7 @@ CL_LinkPacketEntities (void) vec4f_t org = Transform_GetWorldPosition (transform); if (VectorDistance_fast (old->origin, org) > (256 * 256)) old->origin = org; - if (renderer->model->flags & ~EF_ROTATE) { + if (renderer->model->effects & ~ME_ROTATE) { CL_ModelEffects (ent, new->glow_color, cl.time); } }