Skip to content

Commit

Permalink
renders: use combined mesh flags
Browse files Browse the repository at this point in the history
  • Loading branch information
0lvin committed Dec 15, 2024
1 parent 2a3b4e8 commit e776eba
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 56 deletions.
1 change: 1 addition & 0 deletions src/client/cl_entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ CL_AddPacketEntities(frame_t *frame)
effects = s1->effects;
rr_effects = s1->rr_effects;
renderfx = s1->renderfx;
ent.rr_mesh = s1->rr_mesh;

/* set frame */
if (effects & EF_ANIM01)
Expand Down
5 changes: 5 additions & 0 deletions src/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,14 @@ CL_ParseDelta(const entity_xstate_t *from, entity_xstate_t *to, int number, int

if (bits & U_FM_FLAGS)
{
to->rr_mesh = 0;
for (int i = 0; i < MAX_FM_MESH_NODES; i++)
{
to->fmnodeinfo[i].flags = MSG_ReadShort(&net_message);
if (to->fmnodeinfo[i].flags & FMNI_NO_DRAW)
{
to->rr_mesh |= (1 << i);
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/client/refresh/gl1/gl1_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ R_DrawAliasDrawCommands(const entity_t *currententity, int *order, const int *or
*/
static void
R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp,
vec4_t *s_lerped, const float *shadelight, const float *shadevector,
fmnodeinfo_t *nodeinfo)
vec4_t *s_lerped, const float *shadelight, const float *shadevector)
{
daliasxframe_t *frame, *oldframe;
const dxtrivertx_t *ov;
Expand Down Expand Up @@ -182,7 +181,7 @@ R_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp,

for (i = 0; i < num_mesh_nodes; i++)
{
if (nodeinfo && nodeinfo[i].flags & FMNI_NO_DRAW)
if (currententity->rr_mesh & (1 << i))
{
continue;
}
Expand Down Expand Up @@ -562,7 +561,7 @@ R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel)

R_UpdateGLBuffer(buf_alias, skin->texnum, 0, currententity->flags, 1);
R_DrawAliasFrameLerp(currententity, paliashdr, currententity->backlerp,
s_lerped, shadelight, shadevector, currententity->fmnodeinfo);
s_lerped, shadelight, shadevector);
R_ApplyGLBuffer();

R_TexEnv(GL_REPLACE);
Expand Down
5 changes: 1 addition & 4 deletions src/client/refresh/gl3/gl3_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,6 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight,
int num_mesh_nodes;
dmdxmesh_t *mesh_nodes;
vec4_t *s_lerped;
fmnodeinfo_t *nodeinfo;

nodeinfo = entity->fmnodeinfo;

// draw without texture? used for quad damage effect etc, I think
qboolean colorOnly = 0 != (entity->flags &
Expand Down Expand Up @@ -302,7 +299,7 @@ DrawAliasFrameLerp(dmdx_t *paliashdr, entity_t* entity, vec3_t shadelight,

for (i = 0; i < num_mesh_nodes; i++)
{
if (nodeinfo && nodeinfo[i].flags & FMNI_NO_DRAW)
if (entity->rr_mesh & (1 << i))
{
continue;
}
Expand Down
5 changes: 1 addition & 4 deletions src/client/refresh/soft/sw_alias.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,6 @@ R_AliasPreparePoints(const entity_t *currententity, finalvert_t *verts, const fi
int i, num_mesh_nodes;
qboolean colorOnly;
vec4_t *s_lerped;
fmnodeinfo_t *nodeinfo;

nodeinfo = currententity->fmnodeinfo;

if ((verts + s_pmdl->num_xyz) >= verts_max)
{
Expand Down Expand Up @@ -479,7 +476,7 @@ R_AliasPreparePoints(const entity_t *currententity, finalvert_t *verts, const fi
const dtriangle_t *ptri;
int num_tris;

if (nodeinfo && nodeinfo[i].flags & FMNI_NO_DRAW)
if (currententity->rr_mesh & (1 << i))
{
continue;
}
Expand Down
5 changes: 1 addition & 4 deletions src/client/refresh/vk/vk_mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,6 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp
qboolean colorOnly = 0 != (currententity->flags &
(RF_SHELL_RED | RF_SHELL_GREEN | RF_SHELL_BLUE | RF_SHELL_DOUBLE |
RF_SHELL_HALF_DAM));
fmnodeinfo_t *nodeinfo;

nodeinfo = currententity->fmnodeinfo;

frame = (daliasxframe_t *)((byte *)paliashdr + paliashdr->ofs_frames
+ currententity->frame * paliashdr->framesize);
Expand Down Expand Up @@ -386,7 +383,7 @@ Vk_DrawAliasFrameLerp(entity_t *currententity, dmdx_t *paliashdr, float backlerp

for (i = 0; i < num_mesh_nodes; i++)
{
if (nodeinfo && nodeinfo[i].flags & FMNI_NO_DRAW)
if (currententity->rr_mesh & (1 << i))
{
continue;
}
Expand Down
9 changes: 1 addition & 8 deletions src/client/vid/header/ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef struct entity_s {
float backlerp; /* 0.0 = current, 1.0 = old */
int skinnum; /* also used as RF_BEAM's palette index */
vec3_t scale; /* model scale before render */
unsigned rr_mesh; /* disabled meshes */

int lightstyle; /* for flashing entities */
float alpha; /* ignore if RF_TRANSLUCENT isn't set */
Expand All @@ -77,21 +78,13 @@ typedef struct entity_s {
int flags;

/* Heretic 2 */
float cl_scale; // scale of model - but only for client entity models - not server side models
// required for scaling mins and maxs that are used to cull models - mins and maxs
// are scaled on the server side, but not on the client side when the models are loaded in

float depth; // distance to the camera origin, gets set every
// frame by AddEffectsToView

paletteRGBA_t color;
int spriteType;

// info for fmodels and bmodels
fmnodeinfo_t *fmnodeinfo; // client entities which use a flexible model will need
// to fill this in, and then release it when they die
// happily most client entities are sprites

int swapFrame; // frame to swap clustered verts in for
int oldSwapFrame; // previous frame to swap clustered verts in for

Expand Down
2 changes: 2 additions & 0 deletions src/common/header/shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ typedef struct entity_rrstate_s
/* New protocol fields */
vec3_t scale; /* model scale */
unsigned int effects;
unsigned int mesh;
} entity_rrstate_t;

typedef struct entity_xstate_s
Expand Down Expand Up @@ -1536,6 +1537,7 @@ typedef struct entity_xstate_s
/* New protocol fields, sync with entity_rrstate_t */
vec3_t scale; /* model scale */
unsigned int rr_effects;
unsigned int rr_mesh;
} entity_xstate_t;

/* ============================================== */
Expand Down
7 changes: 1 addition & 6 deletions src/game/effects/client_entities.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ void ClientEntity_delete(client_entity_t *toDelete, centity_t *owner)
CE_DLight_delete(toDelete->dlight);
}

if(toDelete->r.fmnodeinfo)
{
ResMngr_DeallocateResource(&FMNodeInfoMngr, toDelete->r.fmnodeinfo, sizeof(fmnodeinfo_t)*MAX_FM_MESH_NODES);
}

if(owner && toDelete->refMask)
{
DisableRefPoints(owner->referenceInfo, toDelete->refMask);
Expand Down Expand Up @@ -388,7 +383,7 @@ void AddEffect(centity_t* owner, client_entity_t* fx)
}

// copy up the scale on a model so it can be culled properly
fx->r.cl_scale = AVG_VEC3T(fx->r.scale);
VectorCopy(fx->r.scale, fx->r.scale);
}

#define NUM_TRACES 100 // I really, really hope we don't ever see more than _this
Expand Down
16 changes: 6 additions & 10 deletions src/game/effects/fx_debris.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ static void FXBodyPart_Throw(centity_t *owner, int BodyPart, vec3_t origin, floa
{
debris->r.model = fxi.cl->model_draw[modelindex];
}
debris->r.fmnodeinfo = FMNodeInfo_new();
debris->r.rr_mesh = 0;
debris->r.frame = frame;//first frame should be parts frame of a flexmodel
//need to copy base skin also
debris->r.skinnum = owner->current.skinnum;
Expand All @@ -352,21 +352,17 @@ static void FXBodyPart_Throw(centity_t *owner, int BodyPart, vec3_t origin, floa
node_num++;
if(!((int)(BodyPart)&(int)(whichnode)))
{
debris->r.fmnodeinfo[node_num].flags |= FMNI_NO_DRAW;
}
else
{
debris->r.fmnodeinfo[node_num] = owner->current.fmnodeinfo[node_num];//copy skins and flags and colors
debris->r.fmnodeinfo[node_num].flags &= ~FMNI_NO_DRAW;
debris->r.rr_mesh |= (1 << node_num);
}
}
//turn off first node always?
if(modelindex != 255 || (modelindex == 255 && !(BodyPart & 1)))
debris->r.fmnodeinfo[0].flags |= FMNI_NO_DRAW;
{
debris->r.rr_mesh |= (1 << 0);
}
else
{
debris->r.fmnodeinfo[0] = owner->current.fmnodeinfo[0];//copy skins and flags and colors
debris->r.fmnodeinfo[0].flags &= ~FMNI_NO_DRAW;
debris->r.rr_mesh &= ~(1 << 0);
}

debris->flags |= (CEF_CLIP_TO_WORLD | CEF_ABSOLUTE_PARTS);
Expand Down
4 changes: 2 additions & 2 deletions src/game/effects/fx_shrine.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ shrine_player_update(struct client_entity_s *self, centity_t *owner)
{
if (!(--self->SpawnInfo))
{
self->r.fmnodeinfo = NULL;
self->r.rr_mesh = 0;
return false;
}

Expand Down Expand Up @@ -141,7 +141,7 @@ void FXShrinePlayerEffect(centity_t *owner, int type, int flags, vec3_t origin)
VectorSet(shrine_fx->r.scale, 3.0, 3.0, 3.0);
shrine_fx->velocity[2] = -35.5;
shrine_fx->r.flags = RF_TRANSLUCENT ;
shrine_fx->r.fmnodeinfo = &owner->current.fmnodeinfo[0];
shrine_fx->r.rr_mesh = 1 ? (owner->current.fmnodeinfo[0].flags & FMNI_NO_DRAW) : 0;
shrine_fx->Update = shrine_player_update;
shrine_fx->SpawnInfo = PLAYER_FADE_TIME;
shrine_fx->d_alpha = 0.45;
Expand Down
22 changes: 8 additions & 14 deletions src/game/effects/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,6 @@ ParseEffects(centity_t *owner)
}

static entity_t sv_ents[MAX_ENTITIES];
static fmnodeinfo_t sv_ents_fmnodeinfos[MAX_ENTITIES][MAX_FM_MESH_NODES];


static void
AddServerEntities(frame_t *frame)
Expand Down Expand Up @@ -655,18 +653,14 @@ AddServerEntities(frame_t *frame)

// Handle flex-model nodes.

ent->fmnodeinfo = sv_ents_fmnodeinfos[pnum];
// jmarshall - removed legacy prediction.
//if(isPredictedPlayer)
//{
// memcpy(ent->fmnodeinfo,fxi.predictinfo->fmnodeinfo,sizeof(s1->fmnodeinfo));
//}
//else
//{
// memcpy(ent->fmnodeinfo,s1->fmnodeinfo,sizeof(s1->fmnodeinfo));
//}
memcpy(ent->fmnodeinfo, s1->fmnodeinfo, sizeof(s1->fmnodeinfo));
// jmarshall end
ent->rr_mesh = 0;
for (int i = 0; i < MAX_FM_MESH_NODES; i++)
{
if (s1->fmnodeinfo[i].flags & FMNI_NO_DRAW)
{
ent->rr_mesh |= (1 << i);
}
}

// What's going on here?
// jmarshall - removed legacy prediction.
Expand Down

0 comments on commit e776eba

Please sign in to comment.