[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
} 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;

View File

@ -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);
}

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);
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
}

View File

@ -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);

View File

@ -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:

View File

@ -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);

View File

@ -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);
}

View File

@ -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");

View File

@ -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);
}
}