Merge branch 'brushbsp' of https://github.com/ericwa/ericw-tools into brushbsp

This commit is contained in:
Jonathan 2023-06-20 19:36:15 -04:00
commit db4a205537
2 changed files with 33 additions and 26 deletions

View File

@ -93,7 +93,7 @@ testresults_t QbspVisLight_Q2(
return QbspVisLight_Common(name, {"-q2bsp"}, extra_light_args, run_vis);
}
TEST_CASE("-world_units_per_luxel, -lightgrid" * doctest::may_fail())
TEST_CASE("-world_units_per_luxel, -lightgrid")
{
auto [bsp, bspx] = QbspVisLight_Q2("q2_lightmap_custom_scale.map", {"-lightgrid"});
@ -123,7 +123,6 @@ TEST_CASE("-world_units_per_luxel, -lightgrid" * doctest::may_fail())
{
INFO("sky gets an optimized lightmap");
// FIXME: this currently fails, see Face_IsLightmapped
auto *sky_face = BSP_FindFaceAtPoint(&bsp, &bsp.dmodels[0], {256, 240, 84}, {0, -1, 0});
CHECK(sky_face->styles[0] == 255);
@ -529,7 +528,7 @@ TEST_CASE("light channel mask / dirt interaction")
CheckFaceLuxelAtPoint(&bsp, &bsp.dmodels[1], {19, 19, 19}, {1236, 1308, 960});
}
TEST_CASE("surface lights minlight")
TEST_CASE("surface lights minlight" * doctest::may_fail())
{
auto [bsp, bspx, lit] = QbspVisLight_Q1("q1_surflight_minlight.map", {});
@ -630,7 +629,7 @@ TEST_CASE("q2_light_origin_brush_shadow")
CheckFaceLuxelAtPoint(&bsp, &bsp.dmodels[0], {100, 100, 100}, at_origin);
}
TEST_CASE("q2_surface_lights_culling")
TEST_CASE("q2_surface_lights_culling" * doctest::may_fail())
{
auto [bsp, bspx] = QbspVisLight_Q2("q2_surface_lights_culling.map", {});

View File

@ -20,7 +20,7 @@
#include <common/log.hh>
#include <vis/vis.hh>
#include <common/bsputils.hh>
#include <common/parallel.hh>
/*
Some textures (sky, water, slime, lava) are considered ambien sound emiters.
@ -60,45 +60,51 @@ void CalcAmbientSounds(mbsp_t *bsp)
{
logging::funcheader();
const mface_t *surf;
const mtexinfo_t *info;
int i, j, k, l;
mleaf_t *leaf, *hit;
uint8_t *vis;
float d, maxd;
ambient_type_t ambient_type;
float dists[NUM_AMBIENTS];
float vol;
// fast path for -noambient
if (vis_options.noambientsky.value() && vis_options.noambientwater.value() && vis_options.noambientslime.value() &&
vis_options.noambientlava.value()) {
for (int i = 0; i < portalleafs_real; i++) {
mleaf_t *leaf = &bsp->dleafs[i + 1];
for (int j = 0; j < NUM_AMBIENTS; j++) {
leaf->ambient_level[j] = 0;
}
}
return;
}
for (i = 0; i < portalleafs_real; i++) {
leaf = &bsp->dleafs[i + 1];
logging::parallel_for(0, portalleafs_real, [&bsp](int i) {
mleaf_t *leaf = &bsp->dleafs[i + 1];
float dists[NUM_AMBIENTS];
//
// clear ambients
//
for (j = 0; j < NUM_AMBIENTS; j++)
for (int j = 0; j < NUM_AMBIENTS; j++)
dists[j] = 1020;
uint8_t *vis;
if (portalleafs != portalleafs_real) {
vis = &uncompressed[leaf->cluster * leafbytes_real];
} else {
vis = &uncompressed[i * leafbytes_real];
}
for (j = 0; j < portalleafs_real; j++) {
for (int j = 0; j < portalleafs_real; j++) {
if (!(vis[j >> 3] & nth_bit(j & 7)))
continue;
//
// check this leaf for sound textures
//
hit = &bsp->dleafs[j + 1];
mleaf_t *hit = &bsp->dleafs[j + 1];
for (k = 0; k < hit->nummarksurfaces; k++) {
surf = BSP_GetFace(bsp, bsp->dleaffaces[hit->firstmarksurface + k]);
info = &bsp->texinfo[surf->texinfo];
for (int k = 0; k < hit->nummarksurfaces; k++) {
const mface_t *surf = BSP_GetFace(bsp, bsp->dleaffaces[hit->firstmarksurface + k]);
const mtexinfo_t *info = &bsp->texinfo[surf->texinfo];
const auto &miptex = bsp->dtex.textures[info->miptex];
ambient_type_t ambient_type;
if (!Q_strncasecmp(miptex.name.data(), "sky", 3) && !vis_options.noambientsky.value())
ambient_type = AMBIENT_SKY;
else if (!Q_strncasecmp(miptex.name.data(), "*water", 6) && !vis_options.noambientwater.value())
@ -114,8 +120,9 @@ void CalcAmbientSounds(mbsp_t *bsp)
// find distance from source leaf to polygon
aabb3d bounds = SurfaceBBox(bsp, surf);
maxd = 0;
for (l = 0; l < 3; l++) {
float maxd = 0;
for (int l = 0; l < 3; l++) {
float d;
if (bounds.mins()[l] > leaf->maxs[l])
d = bounds.mins()[l] - leaf->maxs[l];
else if (bounds.maxs()[l] < leaf->mins[l])
@ -132,7 +139,8 @@ void CalcAmbientSounds(mbsp_t *bsp)
}
}
for (j = 0; j < NUM_AMBIENTS; j++) {
for (int j = 0; j < NUM_AMBIENTS; j++) {
float vol;
if (dists[j] < 100)
vol = 1.0;
else {
@ -142,7 +150,7 @@ void CalcAmbientSounds(mbsp_t *bsp)
}
leaf->ambient_level[j] = (uint8_t)(vol * 255);
}
}
});
}
/*