Merge pull request #591 from w23/everything-is-smooth

vk: patch: allow smoothing entire brush model
This commit is contained in:
NightFox 2023-10-05 22:00:39 +03:00 committed by GitHub
commit 56737fd05f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 6 deletions

View File

@ -63,7 +63,12 @@
{
"_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
"_light" "70 200 110 4000" // color from hack light
}
{
_xvk_ent_id "321 322 323 324"
_xvk_smooth_entire_model "1"
}

View File

@ -850,7 +850,7 @@ static int getSurfaceTexture(const msurface_t *surf, int surface_index) {
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;
// Filter explicit exclusion
@ -863,6 +863,9 @@ static qboolean shouldSmoothLinkSurfaces(const model_t* mod, int surf1, int surf
return false;
}
if (smooth_entire_model)
return true;
for (int i = 0; i < g_map_entities.smoothing.groups_count; ++i) {
const xvk_smoothing_group_t *g = g_map_entities.smoothing.groups + i;
uint32_t bits = 0;
@ -949,7 +952,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);
}
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 (g_brush.conn.edges)
Mem_Free(g_brush.conn.edges);
@ -983,7 +986,7 @@ static void connectVertices( const model_t *mod ) {
cedge->first_surface = surface_index;
} else {
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[1]);
}
@ -1065,9 +1068,9 @@ static qboolean fillBrushSurfaces(fill_geometries_args_t args) {
uint16_t *p_ind = args.out_indices;
int index_offset = args.base_index_offset;
connectVertices(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
// 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]);
}
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) {
const char *s = props->_xvk_map_material;
while (*s) {

View File

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