[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.
This commit is contained in:
Bill Currie 2023-09-14 20:35:45 +09:00
parent e535fd51b7
commit cb72769aa9
9 changed files with 32 additions and 43 deletions

View file

@ -374,15 +374,17 @@ typedef enum {
mod_num_types mod_num_types
} modtype_t; } modtype_t;
#define EF_ROCKET 1 // leave a trail typedef enum {
#define EF_GRENADE 2 // leave a trail ME_ROCKET = 1, // leave a trail
#define EF_GIB 4 // leave a trail ME_GRENADE = 2, // leave a trail
#define EF_ROTATE 8 // rotate (bonus items) ME_GIB = 4, // leave a trail
#define EF_TRACER 16 // green split trail ME_ROTATE = 8, // rotate (bonus items)
#define EF_ZOMGIB 32 // small blood trail ME_TRACER = 16, // green split trail
#define EF_TRACER2 64 // orange split trail + rotate ME_ZOMGIB = 32, // small blood trail
#define EF_TRACER3 128 // purple trail ME_TRACER2 = 64, // orange split trail + rotate
#define EF_GLOWTRAIL 4096 // glowcolor particle trail ME_TRACER3 = 128, // purple trail
ME_GLOWTRAIL = 4096, // glowcolor particle trail
} modeffects_t;
typedef struct model_s { typedef struct model_s {
//FIXME use pointers. needs care in bsp submodel loading //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 const struct vpath_s *vpath;// virtual path where this model was found
bool needload; // bmodels and sprites don't cache normally bool needload; // bmodels and sprites don't cache normally
aliashdr_t *aliashdr; // if not null, alias model is not cached aliashdr_t *aliashdr; // if not null, alias model is not cached
bool hasfullbrights;
modtype_t type; modtype_t type;
int numframes; int numframes;
synctype_t synctype; synctype_t synctype;
int flags; modeffects_t effects;
// lighting info // lighting info
float min_light; float min_light;
@ -409,10 +410,6 @@ typedef struct model_s {
// FIXME: bbox cruft has to stay until sw rendering gets updated // FIXME: bbox cruft has to stay until sw rendering gets updated
vec3_t mins, maxs; vec3_t mins, maxs;
// solid volume for clipping
bool clipbox;
vec3_t clipmins, clipmaxs;
// brush model // brush model
//FIXME should be a pointer (submodels make things tricky) //FIXME should be a pointer (submodels make things tricky)
mod_brush_t brush; mod_brush_t brush;

View file

@ -170,7 +170,7 @@ CL_ModelEffects (entity_t ent, int glow_color, double time)
vec4f_t ent_origin = Transform_GetWorldPosition (transform); vec4f_t ent_origin = Transform_GetWorldPosition (transform);
// add automatic particle trails // add automatic particle trails
if (model->flags & EF_ROCKET) { if (model->effects & ME_ROCKET) {
uint32_t light = attach_light_ent (ent); uint32_t light = attach_light_ent (ent);
Ent_SetComponent (light, scene_dynlight, ent.reg, &(dlight_t) { Ent_SetComponent (light, scene_dynlight, ent.reg, &(dlight_t) {
.origin = ent_origin, .origin = ent_origin,
@ -182,19 +182,19 @@ CL_ModelEffects (entity_t ent, int glow_color, double time)
Light_LinkLight (cl_world.scene->lights, light); Light_LinkLight (cl_world.scene->lights, light);
clp_funcs->RocketTrail (*old_origin, ent_origin); clp_funcs->RocketTrail (*old_origin, ent_origin);
renderer->noshadows = 1; renderer->noshadows = 1;
} else if (model->flags & EF_GRENADE) } else if (model->effects & ME_GRENADE)
clp_funcs->GrenadeTrail (*old_origin, ent_origin); 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); 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); 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); 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); 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); 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); clp_funcs->GlowTrail (*old_origin, ent_origin, glow_color);
} }

View file

@ -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); Sys_MaskPrintf (SYS_glt, "%s %d\n", name->str, texnum);
skindesc->texnum = texnum; skindesc->texnum = texnum;
skindesc->fb_texnum = fb_texnum; skindesc->fb_texnum = fb_texnum;
alias_ctx->mod->hasfullbrights = fb_texnum;
dstring_delete (name); dstring_delete (name);
// alpha param was true for non group skins // alpha param was true for non group skins
} }

View file

@ -272,7 +272,7 @@ Mod_LoadAliasModel (model_t *mod, void *buffer, cache_allocator_t allocator)
header->crc = crc; 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 // endian-adjust and copy the data, starting with the alias model header
pmodel->ident = LittleLong (pinmodel->ident); pmodel->ident = LittleLong (pinmodel->ident);

View file

@ -240,7 +240,6 @@ Mod_RealLoadModel (model_t *mod, bool crash, cache_allocator_t allocator)
// call the apropriate loader // call the apropriate loader
mod->needload = false; mod->needload = false;
mod->hasfullbrights = false;
switch (LittleLong (*buf)) { switch (LittleLong (*buf)) {
case IQM_SMAGIC: case IQM_SMAGIC:

View file

@ -168,7 +168,7 @@ CL_RelinkEntities (void)
entity_state_t *new, *old; entity_state_t *new, *old;
float bobjrotate, frac, f; float bobjrotate, frac, f;
int i, j; int i, j;
int model_flags; int model_effects;
// determine partial update time // determine partial update time
frac = CL_LerpPoint (); frac = CL_LerpPoint ();
@ -254,9 +254,9 @@ CL_RelinkEntities (void)
VectorCopy (ent_colormod[new->colormod], renderer->colormod); VectorCopy (ent_colormod[new->colormod], renderer->colormod);
renderer->colormod[3] = ENTALPHA_DECODE (new->alpha); renderer->colormod[3] = ENTALPHA_DECODE (new->alpha);
model_flags = 0; model_effects = 0;
if (renderer->model) { if (renderer->model) {
model_flags = renderer->model->flags; model_effects = renderer->model->effects;
} }
if (SET_TEST_MEMBER (&cl_forcelink, i)) { if (SET_TEST_MEMBER (&cl_forcelink, i)) {
@ -284,7 +284,7 @@ CL_RelinkEntities (void)
// interpolate the origin and angles // interpolate the origin and angles
vec3_t angles, d; vec3_t angles, d;
vec4f_t origin = old->origin + f * delta; vec4f_t origin = old->origin + f * delta;
if (!(model_flags & EF_ROTATE)) { if (!(model_effects & ME_ROTATE)) {
VectorSubtract (new->angles, old->angles, d); VectorSubtract (new->angles, old->angles, d);
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
if (d[j] > 180) if (d[j] > 180)
@ -307,7 +307,7 @@ CL_RelinkEntities (void)
&& !chase_active); && !chase_active);
// rotate binary objects locally // rotate binary objects locally
if (model_flags & EF_ROTATE) { if (model_effects & ME_ROTATE) {
vec3_t angles; vec3_t angles;
VectorCopy (new->angles, angles); VectorCopy (new->angles, angles);
angles[YAW] = bobjrotate; angles[YAW] = bobjrotate;
@ -333,7 +333,7 @@ CL_RelinkEntities (void)
if (VectorDistance_fast (old->origin, org) > (256 * 256)) { if (VectorDistance_fast (old->origin, org) > (256 * 256)) {
old->origin = org; old->origin = org;
} }
if (model_flags & ~EF_ROTATE) if (model_effects & ~ME_ROTATE)
CL_ModelEffects (ent, new->glow_color, cl.time); CL_ModelEffects (ent, new->glow_color, cl.time);
SET_REMOVE (&cl_forcelink, i); SET_REMOVE (&cl_forcelink, i);

View file

@ -263,12 +263,7 @@ PF_setmodel (progs_t *pr, void *data)
mod = sv.models[i]; mod = sv.models[i];
if (mod) { if (mod) {
// FIXME disabled for now as setting clipmins/maxs is currently SetMinMaxSize (pr, e, mod->mins, mod->maxs, true);
// too messy
//if (mod->type == mod_brush)
// SetMinMaxSize (pr, e, mod->clipmins, mod->clipmaxs, true);
//else
SetMinMaxSize (pr, e, mod->mins, mod->maxs, true);
} else { } else {
SetMinMaxSize (pr, e, vec3_origin, vec3_origin, true); SetMinMaxSize (pr, e, vec3_origin, vec3_origin, true);
} }

View file

@ -550,8 +550,7 @@ CL_SetSolidEntities (void)
continue; continue;
if (!cl_world.models.a[state->modelindex]) if (!cl_world.models.a[state->modelindex])
continue; continue;
if (cl_world.models.a[state->modelindex]->brush.hulls[1].firstclipnode if (cl_world.models.a[state->modelindex]->brush.hulls[1].firstclipnode){
|| cl_world.models.a[state->modelindex]->clipbox) {
if (pmove.numphysent == MAX_PHYSENTS) { if (pmove.numphysent == MAX_PHYSENTS) {
Sys_Printf ("WARNING: entity physent overflow, email " Sys_Printf ("WARNING: entity physent overflow, email "
"quakeforge-devel@lists.quakeforge.net\n"); "quakeforge-devel@lists.quakeforge.net\n");

View file

@ -263,7 +263,7 @@ CL_LinkPacketEntities (void)
CL_TransformEntity (ent, new->scale / 16, new->angles, CL_TransformEntity (ent, new->scale / 16, new->angles,
new->origin); new->origin);
animation->pose1 = animation->pose2 = -1; animation->pose1 = animation->pose2 = -1;
} else if (!(renderer->model->flags & EF_ROTATE)) { } else if (!(renderer->model->effects & ME_ROTATE)) {
vec3_t angles, d; vec3_t angles, d;
vec4f_t origin = old->origin + f * delta; vec4f_t origin = old->origin + f * delta;
// interpolate the origin and angles // interpolate the origin and angles
@ -286,7 +286,7 @@ CL_LinkPacketEntities (void)
} }
// rotate binary objects locally // rotate binary objects locally
if (renderer->model->flags & EF_ROTATE) { if (renderer->model->effects & ME_ROTATE) {
vec3_t angles; vec3_t angles;
angles[PITCH] = 0; angles[PITCH] = 0;
angles[YAW] = anglemod (100 * cl.time); angles[YAW] = anglemod (100 * cl.time);
@ -298,7 +298,7 @@ CL_LinkPacketEntities (void)
vec4f_t org = Transform_GetWorldPosition (transform); vec4f_t org = Transform_GetWorldPosition (transform);
if (VectorDistance_fast (old->origin, org) > (256 * 256)) if (VectorDistance_fast (old->origin, org) > (256 * 256))
old->origin = org; old->origin = org;
if (renderer->model->flags & ~EF_ROTATE) { if (renderer->model->effects & ~ME_ROTATE) {
CL_ModelEffects (ent, new->glow_color, cl.time); CL_ModelEffects (ent, new->glow_color, cl.time);
} }
} }