vk: brush: do not link pairs that were explicitly excluded in patches
This doesn't work as expected in some cases, as surfaces might still get linked transitively by neighbours. Solving this seems non-trivial for now, but maybe we can just live with it
This commit is contained in:
parent
d8d5019971
commit
61416cfc66
|
@ -809,14 +809,22 @@ static int getSurfaceTexture(const msurface_t *surf, int surface_index) {
|
|||
static qboolean shouldSmoothLinkSurfaces(const model_t* mod, int surf1, int surf2) {
|
||||
//return Q_min(surf1, surf2) == 741 && Q_max(surf1, surf2) == 743;
|
||||
|
||||
// TODO patch filtering
|
||||
|
||||
// Do not join surfaces with different textures. Assume they belong to different objects.
|
||||
const int t1 = getSurfaceTexture(mod->surfaces + surf1, surf1);
|
||||
const int t2 = getSurfaceTexture(mod->surfaces + surf2, surf2);
|
||||
if (t1 != t2)
|
||||
return false;
|
||||
|
||||
// Filter explicit exclusion
|
||||
for (int i = 0; i < g_map_entities.smoothing.excluded_count; i+=2) {
|
||||
const int cand1 = g_map_entities.smoothing.excluded[i];
|
||||
const int cand2 = g_map_entities.smoothing.excluded[i+1];
|
||||
|
||||
if ((cand1 == surf1 && cand2 == surf2)
|
||||
|| (cand1 == surf2 && cand2 == surf1))
|
||||
return false;
|
||||
}
|
||||
|
||||
vec3_t n1, n2;
|
||||
getSurfaceNormal(mod->surfaces + surf1, n1);
|
||||
getSurfaceNormal(mod->surfaces + surf2, n2);
|
||||
|
|
|
@ -518,7 +518,22 @@ static void patchEntity( const entity_props_t *props, uint32_t have_fields ) {
|
|||
WARN("vk_mapents: trying to patch unsupported entity %d class %d", ei, ref->class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void appendExludedPairs(const entity_props_t *props) {
|
||||
if (props->_xvk_smoothing_excluded_pairs.num % 2 != 0) {
|
||||
ERR("vk_mapents: smoothing group exclusion list should be list of pairs -- divisible by 2; cutting the tail");
|
||||
}
|
||||
|
||||
int count = props->_xvk_smoothing_excluded_pairs.num & ~1;
|
||||
if (g_map_entities.smoothing.excluded_count + count > COUNTOF(g_map_entities.smoothing.excluded)) {
|
||||
ERR("vk_mapents: smoothing exclusion group capacity exceeded, go complain in github issues");
|
||||
count = COUNTOF(g_map_entities.smoothing.excluded) - g_map_entities.smoothing.excluded_count;
|
||||
}
|
||||
|
||||
memcpy(g_map_entities.smoothing.excluded + g_map_entities.smoothing.excluded_count, props->_xvk_smoothing_excluded_pairs.values, count * sizeof(int));
|
||||
|
||||
g_map_entities.smoothing.excluded_count += count;
|
||||
}
|
||||
|
||||
static void parseEntities( char *string, qboolean is_patch ) {
|
||||
|
@ -570,8 +585,14 @@ static void parseEntities( char *string, qboolean is_patch ) {
|
|||
addPatchSurface( &values, have_fields );
|
||||
} else if (have_fields & Field__xvk_ent_id) {
|
||||
patchEntity( &values, have_fields );
|
||||
} else if (have_fields & Field__xvk_smoothing_threshold) {
|
||||
g_map_entities.smoothing.threshold = cosf(DEG2RAD(values._xvk_smoothing_threshold));
|
||||
} else {
|
||||
if (have_fields & Field__xvk_smoothing_threshold) {
|
||||
g_map_entities.smoothing.threshold = cosf(DEG2RAD(values._xvk_smoothing_threshold));
|
||||
}
|
||||
|
||||
if (have_fields & Field__xvk_smoothing_excluded_pairs) {
|
||||
appendExludedPairs(&values);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -679,6 +700,7 @@ void XVK_ParseMapEntities( void ) {
|
|||
g_map_entities.entity_count = 0;
|
||||
g_map_entities.func_walls_count = 0;
|
||||
g_map_entities.smoothing.threshold = cosf(DEG2RAD(45.f));
|
||||
g_map_entities.smoothing.excluded_count = 0;
|
||||
|
||||
parseEntities( map->entities, false );
|
||||
orientSpotlights();
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
X(20, vec2_t, _xvk_tex_scale, Vec2) \
|
||||
X(21, string, model, String) \
|
||||
X(22, float, _xvk_smoothing_threshold, Float) \
|
||||
X(23, int_array_t, _xvk_smoothing_excluded_pairs, IntArray) \
|
||||
|
||||
/* NOTE: not used
|
||||
X(22, int, rendermode, Int) \
|
||||
|
@ -132,6 +133,10 @@ typedef struct {
|
|||
|
||||
struct {
|
||||
float threshold;
|
||||
|
||||
#define MAX_EXCLUDED_SMOOTHING_SURFACES_PAIRS 32
|
||||
int excluded[MAX_EXCLUDED_SMOOTHING_SURFACES_PAIRS * 2];
|
||||
int excluded_count;
|
||||
} smoothing;
|
||||
} xvk_map_entities_t;
|
||||
|
||||
|
|
Loading…
Reference in New Issue