Skip to content

Commit

Permalink
ref: soft: search parent in both entity lists when drawing MOVETYPE_F…
Browse files Browse the repository at this point in the history
…OLLOW entities

Fixes the issue in Brutal Half-Life beta 2 with invisible scientist skin.

Fixes: 6862b14 ("ref: soft: only draw MOVETYPE_FOLLOW studio model if it's parent is visible")
  • Loading branch information
a1batross committed May 19, 2024
1 parent 85b0699 commit b8417fa
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions ref/soft/r_studio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3326,6 +3326,19 @@ static void R_StudioDrawModelInternal( cl_entity_t *e, int flags )
}
}

static cl_entity_t *R_FindParentEntity( cl_entity_t *e, cl_entity_t **entities, uint num_entities )
{
uint i;

for( i = 0; i < num_entities; i++ )
{
if( entities[i]->index == e->curstate.aiment )
return entities[i];
}

return NULL;
}

/*
=================
R_DrawStudioModel
Expand All @@ -3342,38 +3355,27 @@ void R_DrawStudioModel( cl_entity_t *e )
{
R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
}
else if( e->curstate.movetype == MOVETYPE_FOLLOW && e->curstate.aiment > 0 )
else if( e->curstate.movetype == MOVETYPE_FOLLOW )
{
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment ), **entities;
uint i, num_entities;
cl_entity_t *parent = CL_GetEntityByIndex( e->curstate.aiment );

if( !parent || !parent->model || parent->model->type != mod_studio )
return;

if( R_OpaqueEntity( parent ))
{
entities = tr.draw_list->solid_entities;
num_entities = tr.draw_list->num_solid_entities;
}
else
{
entities = tr.draw_list->trans_entities;
num_entities = tr.draw_list->num_solid_entities;
}
parent = R_FindParentEntity( e, tr.draw_list->solid_entities, tr.draw_list->num_solid_entities );

for( i = 0; i < num_entities; i++ )
{
if( (*entities)[i].index != e->curstate.aiment )
continue;
if( !parent )
parent = R_FindParentEntity( e, tr.draw_list->trans_entities, tr.draw_list->num_trans_entities );

RI.currententity = &(*entities)[i];
if( parent )
{
RI.currententity = parent;
R_StudioDrawModelInternal( RI.currententity, 0 );
VectorCopy( RI.currententity->curstate.origin, e->curstate.origin );
VectorCopy( RI.currententity->origin, e->origin );
RI.currententity = e;

R_StudioDrawModelInternal( e, STUDIO_RENDER|STUDIO_EVENTS );
break;
}
}
else
Expand Down

0 comments on commit b8417fa

Please sign in to comment.