Skip to content

Commit

Permalink
vk: patch func_wall model/ents visible offsets
Browse files Browse the repository at this point in the history
Fixes #335

Patching is still done using "model" key, using "_xvk_ent_id" needs
complete overhaul of how patching is done
  • Loading branch information
w23 committed Apr 18, 2023
1 parent 7c6b45b commit cfa56c3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ref/vk/vk_mapents.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ static void readFuncWall( const entity_props_t *const props, uint32_t have_field
xvk_mapent_func_wall_t *const e = g_map_entities.func_walls + (g_map_entities.func_walls_count++);

*e = (xvk_mapent_func_wall_t){0};

e->rendercolor.r = 255;
e->rendercolor.g = 255;
e->rendercolor.b = 255;
Expand All @@ -346,7 +347,6 @@ static void readFuncWall( const entity_props_t *const props, uint32_t have_field
if (have_fields & Field_renderfx)
e->renderfx = props->renderfx;


if (have_fields & Field_rendermode)
e->rendermode = props->rendermode;

Expand All @@ -355,6 +355,8 @@ static void readFuncWall( const entity_props_t *const props, uint32_t have_field
e->rendercolor.g = props->rendercolor[1];
e->rendercolor.b = props->rendercolor[2];
}

e->entity_index = g_map_entities.entity_count;
}

static void addPatchSurface( const entity_props_t *props, uint32_t have_fields ) {
Expand Down
1 change: 1 addition & 0 deletions ref/vk/vk_mapents.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ typedef struct {
#define MAX_MAPENT_TARGETS 256

typedef struct {
int entity_index;
string model;
int rendermode, renderamt, renderfx;
color24 rendercolor;
Expand Down
10 changes: 10 additions & 0 deletions ref/vk/vk_scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,16 @@ static void drawEntity( cl_entity_t *ent, int render_mode )
{
case mod_brush:
R_RotateForEntity( model, ent );

// Patch func_wall offsets
// TODO universal entity patching by index O(1); don't loop like that
for (int i = 0; i < g_map_entities.func_walls_count; ++i) {
xvk_mapent_func_wall_t *const fw = g_map_entities.func_walls + i;
if (fw->entity_index == ent->index + 1) {
Matrix4x4_ConcatTranslate(model, fw->offset[0], fw->offset[1], fw->offset[2]);
break;
}
}
VK_RenderStateSetMatrixModel( model );
VK_BrushModelDraw( ent, render_mode, blend, model );
break;
Expand Down

0 comments on commit cfa56c3

Please sign in to comment.