vk: patch: allow smoothing entire brush model

fixes #589
This commit is contained in:
Ivan Avdeev 2023-10-02 11:18:22 -04:00
parent 737cd944bb
commit 1bbcf44864
4 changed files with 22 additions and 6 deletions

View File

@ -63,7 +63,12 @@
{ {
"_xvk_ent_id" "267 266" // remove hack lights entity "_xvk_ent_id" "267 266" // remove hack lights entity
} }
{ // FIXME: color should take from translucent texture { // FIXME: color should take from translucent texture
"_xvk_surface_id" "9" // +0LAB1_W6B 150 160 210 4000 "_xvk_surface_id" "9" // +0LAB1_W6B 150 160 210 4000
"_light" "70 200 110 4000" // color from hack light "_light" "70 200 110 4000" // color from hack light
} }
{
_xvk_ent_id "321 322 323 324"
_xvk_smooth_entire_model "1"
}

View File

@ -858,7 +858,7 @@ static int getSurfaceTexture(const msurface_t *surf, int surface_index) {
return surf->texinfo->texture->gl_texturenum; return surf->texinfo->texture->gl_texturenum;
} }
static qboolean shouldSmoothLinkSurfaces(const model_t* mod, int surf1, int surf2) { static qboolean shouldSmoothLinkSurfaces(const model_t* mod, qboolean smooth_entire_model, int surf1, int surf2) {
//return Q_min(surf1, surf2) == 741 && Q_max(surf1, surf2) == 743; //return Q_min(surf1, surf2) == 741 && Q_max(surf1, surf2) == 743;
// Filter explicit exclusion // Filter explicit exclusion
@ -871,6 +871,9 @@ static qboolean shouldSmoothLinkSurfaces(const model_t* mod, int surf1, int surf
return false; return false;
} }
if (smooth_entire_model)
return true;
for (int i = 0; i < g_map_entities.smoothing.groups_count; ++i) { for (int i = 0; i < g_map_entities.smoothing.groups_count; ++i) {
const xvk_smoothing_group_t *g = g_map_entities.smoothing.groups + i; const xvk_smoothing_group_t *g = g_map_entities.smoothing.groups + i;
uint32_t bits = 0; uint32_t bits = 0;
@ -957,7 +960,7 @@ static void linkSmoothSurfaces(const model_t* mod, int surf1, int surf2, int ver
v->surfs[Q_max(i1, i2)].link = Q_min(i1, i2); v->surfs[Q_max(i1, i2)].link = Q_min(i1, i2);
} }
static void connectVertices( const model_t *mod ) { static void connectVertices( const model_t *mod, qboolean smooth_entire_model ) {
if (mod->numedges > g_brush.conn.edges_capacity) { if (mod->numedges > g_brush.conn.edges_capacity) {
if (g_brush.conn.edges) if (g_brush.conn.edges)
Mem_Free(g_brush.conn.edges); Mem_Free(g_brush.conn.edges);
@ -991,7 +994,7 @@ static void connectVertices( const model_t *mod ) {
cedge->first_surface = surface_index; cedge->first_surface = surface_index;
} else { } else {
const medge_t *edge = mod->edges + iedge; const medge_t *edge = mod->edges + iedge;
if (shouldSmoothLinkSurfaces(mod, cedge->first_surface, surface_index)) { if (shouldSmoothLinkSurfaces(mod, smooth_entire_model, cedge->first_surface, surface_index)) {
linkSmoothSurfaces(mod, cedge->first_surface, surface_index, edge->v[0]); linkSmoothSurfaces(mod, cedge->first_surface, surface_index, edge->v[0]);
linkSmoothSurfaces(mod, cedge->first_surface, surface_index, edge->v[1]); linkSmoothSurfaces(mod, cedge->first_surface, surface_index, edge->v[1]);
} }
@ -1073,9 +1076,9 @@ static qboolean fillBrushSurfaces(fill_geometries_args_t args) {
uint16_t *p_ind = args.out_indices; uint16_t *p_ind = args.out_indices;
int index_offset = args.base_index_offset; int index_offset = args.base_index_offset;
connectVertices(args.mod);
const xvk_mapent_func_any_t *const entity_patch = getModelFuncAnyPatch(args.mod); const xvk_mapent_func_any_t *const entity_patch = getModelFuncAnyPatch(args.mod);
connectVertices(args.mod, entity_patch ? entity_patch->smooth_entire_model : false);
// Load sorted by gl_texturenum // Load sorted by gl_texturenum
// TODO this does not make that much sense in vulkan (can sort later) // TODO this does not make that much sense in vulkan (can sort later)

View File

@ -507,6 +507,11 @@ static void patchFuncAnyEntity( const entity_props_t *props, uint32_t have_field
DEBUG("Patching ent=%d func_any=%d %f %f %f", e->entity_index, index, e->origin[0], e->origin[1], e->origin[2]); DEBUG("Patching ent=%d func_any=%d %f %f %f", e->entity_index, index, e->origin[0], e->origin[1], e->origin[2]);
} }
if (have_fields & Field__xvk_smooth_entire_model) {
DEBUG("Patching ent=%d func_any=%d smooth_entire_model =%d", e->entity_index, index, props->_xvk_smooth_entire_model);
e->smooth_entire_model = props->_xvk_smooth_entire_model;
}
if (have_fields & Field__xvk_map_material) { if (have_fields & Field__xvk_map_material) {
const char *s = props->_xvk_map_material; const char *s = props->_xvk_map_material;
while (*s) { while (*s) {

View File

@ -36,6 +36,7 @@
X(24, int_array_t, _xvk_smoothing_group, IntArray) \ X(24, int_array_t, _xvk_smoothing_group, IntArray) \
X(25, string, _xvk_map_material, String) \ X(25, string, _xvk_map_material, String) \
X(26, int, rendermode, Int) \ X(26, int, rendermode, Int) \
X(27, int, _xvk_smooth_entire_model, Int) \
/* NOTE: not used /* NOTE: not used
X(23, int, renderamt, Int) \ X(23, int, renderamt, Int) \
@ -116,6 +117,8 @@ typedef struct {
int rendermode; int rendermode;
qboolean smooth_entire_model;
/* NOTE: not used. Might be needed for #118 in the future. /* NOTE: not used. Might be needed for #118 in the future.
int renderamt, renderfx; int renderamt, renderfx;
color24 rendercolor; color24 rendercolor;