vk: brush: add explicit smoothing group inclusion
This commit is contained in:
parent
61416cfc66
commit
58ed5e7277
|
@ -809,12 +809,6 @@ 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;
|
||||
|
||||
// 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];
|
||||
|
@ -825,6 +819,29 @@ static qboolean shouldSmoothLinkSurfaces(const model_t* mod, int surf1, int surf
|
|||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
for (int j = 0; j < g->count; ++j) {
|
||||
if (g->surfaces[j] == surf1) {
|
||||
bits |= 1;
|
||||
if (bits == 3)
|
||||
return true;
|
||||
}
|
||||
else if (g->surfaces[j] == surf2) {
|
||||
bits |= 2;
|
||||
if (bits == 3)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
vec3_t n1, n2;
|
||||
getSurfaceNormal(mod->surfaces + surf1, n1);
|
||||
getSurfaceNormal(mod->surfaces + surf2, n2);
|
||||
|
|
|
@ -536,6 +536,24 @@ static void appendExludedPairs(const entity_props_t *props) {
|
|||
g_map_entities.smoothing.excluded_count += count;
|
||||
}
|
||||
|
||||
static void addSmoothingGroup(const entity_props_t *props) {
|
||||
if (g_map_entities.smoothing.groups_count == MAX_INCLUDED_SMOOTHING_GROUPS) {
|
||||
ERR("vk_mapents: limit of %d smoothing groups reached", MAX_INCLUDED_SMOOTHING_GROUPS);
|
||||
return;
|
||||
}
|
||||
|
||||
xvk_smoothing_group_t *g = g_map_entities.smoothing.groups + (g_map_entities.smoothing.groups_count++);
|
||||
|
||||
int count = props->_xvk_smoothing_group.num;
|
||||
if (count > MAX_INCLUDED_SMOOTHING_SURFACES_IN_A_GROUP) {
|
||||
ERR("vk_mapents: too many surfaces in a smoothing group. Max %d, got %d. Culling", MAX_INCLUDED_SMOOTHING_SURFACES_IN_A_GROUP, props->_xvk_smoothing_group.num);
|
||||
count = MAX_INCLUDED_SMOOTHING_SURFACES_IN_A_GROUP;
|
||||
}
|
||||
|
||||
memcpy(g->surfaces, props->_xvk_smoothing_group.values, sizeof(int) * count);
|
||||
g->count = count;
|
||||
}
|
||||
|
||||
static void parseEntities( char *string, qboolean is_patch ) {
|
||||
unsigned have_fields = 0;
|
||||
int props_count = 0;
|
||||
|
@ -593,6 +611,10 @@ static void parseEntities( char *string, qboolean is_patch ) {
|
|||
if (have_fields & Field__xvk_smoothing_excluded_pairs) {
|
||||
appendExludedPairs(&values);
|
||||
}
|
||||
|
||||
if (have_fields & Field__xvk_smoothing_group) {
|
||||
addSmoothingGroup(&values);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
X(21, string, model, String) \
|
||||
X(22, float, _xvk_smoothing_threshold, Float) \
|
||||
X(23, int_array_t, _xvk_smoothing_excluded_pairs, IntArray) \
|
||||
X(24, int_array_t, _xvk_smoothing_group, IntArray) \
|
||||
|
||||
/* NOTE: not used
|
||||
X(22, int, rendermode, Int) \
|
||||
|
@ -111,6 +112,12 @@ typedef struct {
|
|||
int index;
|
||||
} xvk_mapent_ref_t;
|
||||
|
||||
#define MAX_INCLUDED_SMOOTHING_SURFACES_IN_A_GROUP 16
|
||||
typedef struct {
|
||||
int count;
|
||||
int surfaces[MAX_INCLUDED_SMOOTHING_SURFACES_IN_A_GROUP];
|
||||
} xvk_smoothing_group_t;
|
||||
|
||||
typedef struct {
|
||||
int num_lights;
|
||||
vk_light_entity_t lights[256];
|
||||
|
@ -137,6 +144,10 @@ typedef struct {
|
|||
#define MAX_EXCLUDED_SMOOTHING_SURFACES_PAIRS 32
|
||||
int excluded[MAX_EXCLUDED_SMOOTHING_SURFACES_PAIRS * 2];
|
||||
int excluded_count;
|
||||
|
||||
#define MAX_INCLUDED_SMOOTHING_GROUPS 32
|
||||
int groups_count;
|
||||
xvk_smoothing_group_t groups[MAX_INCLUDED_SMOOTHING_GROUPS];
|
||||
} smoothing;
|
||||
} xvk_map_entities_t;
|
||||
|
||||
|
|
Loading…
Reference in New Issue