vk: patch func_wall model/ents visible offsets

Fixes #335

Patching is still done using "model" key, using "_xvk_ent_id" needs
complete overhaul of how patching is done
This commit is contained in:
Ivan Avdeev 2023-04-18 12:18:27 -07:00 committed by Ivan Avdeev
parent 7c6e22bb2c
commit ca2a794341
3 changed files with 14 additions and 1 deletions

View File

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

View File

@ -86,6 +86,7 @@ typedef struct {
#define MAX_MAPENT_TARGETS 256
typedef struct {
int entity_index;
string model;
int rendermode, renderamt, renderfx;
color24 rendercolor;

View File

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