From cfa56c3ddc183475b0e2594523eee4fdfccd0237 Mon Sep 17 00:00:00 2001 From: Ivan Avdeev Date: Tue, 18 Apr 2023 12:18:27 -0700 Subject: [PATCH] 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 --- ref/vk/vk_mapents.c | 4 +++- ref/vk/vk_mapents.h | 1 + ref/vk/vk_scene.c | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ref/vk/vk_mapents.c b/ref/vk/vk_mapents.c index d8bb9b27a6..cfa3e46df2 100644 --- a/ref/vk/vk_mapents.c +++ b/ref/vk/vk_mapents.c @@ -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 ) { diff --git a/ref/vk/vk_mapents.h b/ref/vk/vk_mapents.h index b30b6b733c..61b81e371f 100644 --- a/ref/vk/vk_mapents.h +++ b/ref/vk/vk_mapents.h @@ -86,6 +86,7 @@ typedef struct { #define MAX_MAPENT_TARGETS 256 typedef struct { + int entity_index; string model; int rendermode, renderamt, renderfx; color24 rendercolor; diff --git a/ref/vk/vk_scene.c b/ref/vk/vk_scene.c index 59a92aea4e..a7bd596452 100644 --- a/ref/vk/vk_scene.c +++ b/ref/vk/vk_scene.c @@ -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;