code formatting pass

This commit is contained in:
Eric Wasylishen 2023-06-25 18:29:48 -06:00
parent 36e157254c
commit fbea58d679
18 changed files with 104 additions and 106 deletions

View File

@ -672,8 +672,7 @@ int bsputil_main(int argc, char **argv)
m.maxs *= scalar;
}
auto scaleTexInfo = [&](mtexinfo_t &t)
{
auto scaleTexInfo = [&](mtexinfo_t &t) {
// update texinfo
const qmat3x3d inversescaleM{// column-major...

View File

@ -352,7 +352,8 @@ public:
this->id = ID;
}
bool surf_is_lightmapped(const surfflags_t &flags, const char *texname, bool light_nodraw, bool lightgrid_enabled) const override
bool surf_is_lightmapped(
const surfflags_t &flags, const char *texname, bool light_nodraw, bool lightgrid_enabled) const override
{
/* don't save lightmaps for "trigger" texture */
if (!Q_strcasecmp(texname, "trigger"))
@ -980,12 +981,13 @@ struct gamedef_q2_t : public gamedef_t
max_entity_key = 256;
}
bool surf_is_lightmapped(const surfflags_t &flags, const char *texname, bool light_nodraw, bool lightgrid_enabled) const override
bool surf_is_lightmapped(
const surfflags_t &flags, const char *texname, bool light_nodraw, bool lightgrid_enabled) const override
{
/* don't save lightmaps for "trigger" texture even if light_nodraw is set */
if (std::string_view(texname).ends_with("/trigger"))
return false;
// Q2RTX should light nodraw faces
if (light_nodraw && (flags.native & Q2_SURF_NODRAW)) {
return true;
@ -1000,10 +1002,7 @@ struct gamedef_q2_t : public gamedef_t
return !(flags.native & (Q2_SURF_NODRAW | Q2_SURF_SKIP));
}
bool surf_is_emissive(const surfflags_t &flags, const char *texname) const override
{
return true;
}
bool surf_is_emissive(const surfflags_t &flags, const char *texname) const override { return true; }
bool surf_is_subdivided(const surfflags_t &flags) const override { return !(flags.native & Q2_SURF_SKY); }

View File

@ -468,7 +468,7 @@ full_atlas_t build_lightmap_atlas(const mbsp_t &bsp, const bspxentries_t &bspx,
for (auto &rect : rectangles) {
ExportLightmapUVs(&bsp, rect);
}
return result;
}

View File

@ -326,11 +326,10 @@ qvec3b calculate_average(const std::vector<qvec4b> &pixels)
return avg /= n;
}
std::tuple<std::optional<img::texture>, fs::resolve_result, fs::data> load_texture(
const std::string_view &name, bool meta_only, const gamedef_t *game, const settings::common_settings &options,
bool no_prefix)
std::tuple<std::optional<img::texture>, fs::resolve_result, fs::data> load_texture(const std::string_view &name,
bool meta_only, const gamedef_t *game, const settings::common_settings &options, bool no_prefix)
{
fs::path prefix {};
fs::path prefix{};
if (!no_prefix && game->id == GAME_QUAKE_II) {
prefix = "textures";

View File

@ -92,8 +92,7 @@ void print(flag logflag, const char *str)
return;
}
if (active_print_callback)
{
if (active_print_callback) {
active_print_callback(logflag, str);
return;
}

View File

@ -34,7 +34,7 @@
namespace settings
{
class common_settings;
class common_settings;
}
struct lump_t
@ -250,7 +250,8 @@ struct gamedef_t
gamedef_t(const char *default_base_dir);
// surface stores lightmap/luxel color data
virtual bool surf_is_lightmapped(const surfflags_t &flags, const char *texname, bool light_nodraw, bool lightgrid_enabled) const = 0;
virtual bool surf_is_lightmapped(
const surfflags_t &flags, const char *texname, bool light_nodraw, bool lightgrid_enabled) const = 0;
// surface can be emissive
virtual bool surf_is_emissive(const surfflags_t &flags, const char *texname) const = 0;
virtual bool surf_is_subdivided(const surfflags_t &flags) const = 0;

View File

@ -113,8 +113,8 @@ constexpr struct
{".wal", ext::WAL, load_wal}, {".mip", ext::MIP, load_mip}, {"", ext::MIP, load_mip}};
// Attempt to load a texture from the specified name.
std::tuple<std::optional<texture>, fs::resolve_result, fs::data> load_texture(
const std::string_view &name, bool meta_only, const gamedef_t *game, const settings::common_settings &options, bool no_prefix = false);
std::tuple<std::optional<texture>, fs::resolve_result, fs::data> load_texture(const std::string_view &name,
bool meta_only, const gamedef_t *game, const settings::common_settings &options, bool no_prefix = false);
enum class meta_ext
{

View File

@ -42,9 +42,9 @@ struct surfacelight_t
{
bool bounce = false; // whether this is a direct or indirect emission
/**
* disables use of the surfnormal. We set this to true on sky surface lights,
* to avoid black seams on geometry meeting the sky
*/
* disables use of the surfnormal. We set this to true on sky surface lights,
* to avoid black seams on geometry meeting the sky
*/
bool omnidirectional = false;
// rescale faces to account for perpendicular lights
bool rescale = false;

View File

@ -222,7 +222,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m
// Get face normal and midpoint...
qvec3d facenormal = faceplane.normal;
qvec3d facemidpoint = winding.center() + facenormal; // Lift 1 unit
vector<qvec3f> points;
if (light_options.emissivequality.value() == emissivequality_t::LOW ||
@ -241,8 +241,7 @@ static void MakeBounceLightsThread(const settings::worldspawn_keys &cfg, const m
}
for (auto &style : emitcolors) {
MakeBounceLight(
bsp, cfg, surf, style.second, style.first, points, winding, area, facenormal, facemidpoint);
MakeBounceLight(bsp, cfg, surf, style.second, style.first, points, winding, area, facenormal, facemidpoint);
}
}
@ -252,5 +251,5 @@ void MakeBounceLights(const settings::worldspawn_keys &cfg, const mbsp_t *bsp)
logging::parallel_for_each(bsp->dfaces, [&](const mface_t &face) { MakeBounceLightsThread(cfg, bsp, face); });
//logging::print("{} bounce lights created, with {} points\n", bouncelights.size(), bouncelightpoints);
// logging::print("{} bounce lights created, with {} points\n", bouncelights.size(), bouncelightpoints);
}

View File

@ -301,7 +301,9 @@ light_settings::light_settings()
this, "lightmap_scale", 0, &experimental_group, "force change lightmap scale; vanilla engines only allow 16"},
extra{
this, {"extra", "extra4"}, 1, &performance_group, "supersampling; 2x2 (extra) or 4x4 (extra4) respectively"},
emissivequality{this, "emissivequality", emissivequality_t::LOW, { { "LOW", emissivequality_t::LOW }, { "MEDIUM", emissivequality_t::MEDIUM }, { "HIGH", emissivequality_t::HIGH } }, &performance_group,
emissivequality{this, "emissivequality", emissivequality_t::LOW,
{{"LOW", emissivequality_t::LOW}, {"MEDIUM", emissivequality_t::MEDIUM}, {"HIGH", emissivequality_t::HIGH}},
&performance_group,
"low = one point in the center of the face, med = center + all verts, high = spread points out for antialiasing"},
visapprox{this, "visapprox", visapprox_t::AUTO,
{{"auto", visapprox_t::AUTO}, {"none", visapprox_t::NONE}, {"vis", visapprox_t::VIS},
@ -745,9 +747,7 @@ static void SaveLightmapSurfaces(mbsp_t *bsp)
void ClearLightmapSurfaces(mbsp_t *bsp)
{
logging::funcheader();
logging::parallel_for(static_cast<size_t>(0), bsp->dfaces.size(), [&bsp](size_t i) {
light_surfaces[i].reset();
});
logging::parallel_for(static_cast<size_t>(0), bsp->dfaces.size(), [&bsp](size_t i) { light_surfaces[i].reset(); });
}
static void FindModelInfo(const mbsp_t *bsp)

View File

@ -437,7 +437,8 @@ static void CalcPoints(
const vec_t us = starts + s * st_step;
const vec_t ut = startt + t * st_step;
sample.point = surf->extents.LMCoordToWorld(qvec2f(us, ut)) + surf->plane.normal; // one unit in front of face
sample.point =
surf->extents.LMCoordToWorld(qvec2f(us, ut)) + surf->plane.normal; // one unit in front of face
// do this before correcting the point, so we can wrap around the inside of pipes
const bool phongshaded = (surf->curved && cfg.phongallowed.value());
@ -1244,8 +1245,7 @@ static void LightFace_Entity(
GetLightContrib(cfg, entity, surfnorm, true, surfpoint, lightsurf->twosided, color, surfpointToLightDir,
normalcontrib, &surfpointToLightDist);
const float occlusion =
Dirt_GetScaleFactor(cfg, sample.occlusion, entity, surfpointToLightDist, lightsurf);
const float occlusion = Dirt_GetScaleFactor(cfg, sample.occlusion, entity, surfpointToLightDist, lightsurf);
color *= occlusion;
/* Quick distance check first */
@ -1412,7 +1412,7 @@ static void LightFace_Sky(const mbsp_t *bsp, const sun_t *sun, lightsurf_t *ligh
angle = (1.0 - sun->anglescale) + sun->anglescale * angle;
vec_t value = angle * sun->sunlight;
if (sun->dirt) {
value *= Dirt_GetScaleFactor(cfg, sample.occlusion, NULL, 0.0, lightsurf);
}
@ -1777,8 +1777,8 @@ static void LightFace_AutoMin(const mbsp_t *bsp, const mface_t *face, lightsurf_
*/
bool apply_to_all = false;
const bool any_occluded =
std::any_of(lightsurf->samples.begin(), lightsurf->samples.end(), [](const lightsurf_t::sample_data_t &v) { return v.occluded; });
const bool any_occluded = std::any_of(lightsurf->samples.begin(), lightsurf->samples.end(),
[](const lightsurf_t::sample_data_t &v) { return v.occluded; });
if (!modelinfo->autominlight.is_changed()) {
// default: apply autominlight to occluded luxels only
@ -1910,9 +1910,9 @@ constexpr qvec3f SurfaceLight_ColorAtDist(const settings::worldspawn_keys &cfg,
// dir: vpl -> sample point direction
// mxd. returns color in [0,255]
inline qvec3f GetSurfaceLighting(const settings::worldspawn_keys &cfg, const surfacelight_t &vpl, const surfacelight_t::per_style_t &vpl_settings, const qvec3f &dir,
const float dist, const qvec3f &normal, bool use_normal, const vec_t &standard_scale, const vec_t &sky_scale,
const float &hotspot_clamp)
inline qvec3f GetSurfaceLighting(const settings::worldspawn_keys &cfg, const surfacelight_t &vpl,
const surfacelight_t::per_style_t &vpl_settings, const qvec3f &dir, const float dist, const qvec3f &normal,
bool use_normal, const vec_t &standard_scale, const vec_t &sky_scale, const float &hotspot_clamp)
{
qvec3f result;
float dotProductFactor = 1.0f;
@ -1942,8 +1942,8 @@ inline qvec3f GetSurfaceLighting(const settings::worldspawn_keys &cfg, const sur
dotProductFactor = max(0.0f, dotProductFactor);
// Get light contribution
result = SurfaceLight_ColorAtDist(
cfg, vpl_settings.omnidirectional ? sky_scale : standard_scale, vpl_settings.intensity, vpl_settings.color, dist, hotspot_clamp);
result = SurfaceLight_ColorAtDist(cfg, vpl_settings.omnidirectional ? sky_scale : standard_scale,
vpl_settings.intensity, vpl_settings.color, dist, hotspot_clamp);
// Apply angle scale
const qvec3f resultscaled = result * dotProductFactor;
@ -1953,8 +1953,8 @@ inline qvec3f GetSurfaceLighting(const settings::worldspawn_keys &cfg, const sur
}
static bool // mxd
SurfaceLight_SphereCull(
const surfacelight_t *vpl, const lightsurf_t *lightsurf, const surfacelight_t::per_style_t &vpl_settings, const vec_t &bouncelight_gate, const float &hotspot_clamp)
SurfaceLight_SphereCull(const surfacelight_t *vpl, const lightsurf_t *lightsurf,
const surfacelight_t::per_style_t &vpl_settings, const vec_t &bouncelight_gate, const float &hotspot_clamp)
{
if (light_options.visapprox.value() == visapprox_t::RAYS &&
vpl->bounds.disjoint(lightsurf->extents.bounds, 0.001)) {
@ -1966,17 +1966,16 @@ SurfaceLight_SphereCull(
const float dist = qv::length(dir) + lightsurf->extents.radius;
// Get light contribution
const qvec3f color =
SurfaceLight_ColorAtDist(cfg, vpl_settings.omnidirectional ? cfg.surflightskyscale.value() : cfg.surflightscale.value(),
vpl_settings.totalintensity, vpl_settings.color, dist, hotspot_clamp);
const qvec3f color = SurfaceLight_ColorAtDist(cfg,
vpl_settings.omnidirectional ? cfg.surflightskyscale.value() : cfg.surflightscale.value(),
vpl_settings.totalintensity, vpl_settings.color, dist, hotspot_clamp);
return qv::gate(color, (float)bouncelight_gate);
}
static void // mxd
LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t *lightmaps,
bool bounce, const vec_t &standard_scale, const vec_t &sky_scale,
const float &hotspot_clamp)
LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t *lightmaps, bool bounce,
const vec_t &standard_scale, const vec_t &sky_scale, const float &hotspot_clamp)
{
const settings::worldspawn_keys &cfg = *lightsurf->cfg;
const float surflight_gate = 0.01f;
@ -1986,7 +1985,7 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
return;
}
for (const auto & surf_ptr : LightSurfaces()) {
for (const auto &surf_ptr : LightSurfaces()) {
if (!surf_ptr || !surf_ptr->vpl) {
// didn't emit anthing
@ -2033,8 +2032,8 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
dir /= dist;
}
const qvec3f indirect = GetSurfaceLighting(
cfg, vpl, vpl_setting, dir, dist, lightsurf_normal, use_normal, standard_scale, sky_scale, hotspot_clamp);
const qvec3f indirect = GetSurfaceLighting(cfg, vpl, vpl_setting, dir, dist, lightsurf_normal,
use_normal, standard_scale, sky_scale, hotspot_clamp);
if (!qv::gate(indirect, surflight_gate)) { // Each point contributes very little to the final result
rs.pushRay(i, pos, dir, dist, &indirect);
}
@ -2061,7 +2060,8 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
Q_assert(!std::isnan(indirect[0]));
// Use dirt scaling on the surface lighting.
const vec_t dirtscale = Dirt_GetScaleFactor(cfg, lightsurf->samples[i].occlusion, nullptr, 0.0, lightsurf);
const vec_t dirtscale =
Dirt_GetScaleFactor(cfg, lightsurf->samples[i].occlusion, nullptr, 0.0, lightsurf);
indirect *= dirtscale;
lightsample_t &sample = lightmap->samples[i];
@ -2080,9 +2080,9 @@ LightFace_SurfaceLight(const mbsp_t *bsp, lightsurf_t *lightsurf, lightmapdict_t
}
static void // mxd
LightPoint_SurfaceLight(const mbsp_t *bsp, const std::vector<uint8_t> *pvs, raystream_occlusion_t &rs,
bool bounce, const vec_t &standard_scale, const vec_t &sky_scale,
const float &hotspot_clamp, const qvec3d &surfpoint, lightgrid_samples_t &result)
LightPoint_SurfaceLight(const mbsp_t *bsp, const std::vector<uint8_t> *pvs, raystream_occlusion_t &rs, bool bounce,
const vec_t &standard_scale, const vec_t &sky_scale, const float &hotspot_clamp, const qvec3d &surfpoint,
lightgrid_samples_t &result)
{
const settings::worldspawn_keys &cfg = light_options;
const float surflight_gate = 0.01f;
@ -2125,8 +2125,8 @@ LightPoint_SurfaceLight(const mbsp_t *bsp, const std::vector<uint8_t> *pvs, rays
qvec3f cube_normal{};
cube_normal[axis] = sign;
cube_color = GetSurfaceLighting(
cfg, vpl, vpl_settings, dir, dist, cube_normal, true, standard_scale, sky_scale, hotspot_clamp);
cube_color = GetSurfaceLighting(cfg, vpl, vpl_settings, dir, dist, cube_normal, true,
standard_scale, sky_scale, hotspot_clamp);
#ifdef LIGHTPOINT_TAKE_MAX
if (qv::length2(cube_color) > qv::length2(indirect)) {
@ -2846,7 +2846,8 @@ bool Face_IsLightmapped(const mbsp_t *bsp, const mface_t *face)
const char *texname = Face_TextureName(bsp, face);
return bsp->loadversion->game->surf_is_lightmapped(texinfo->flags, texname,
light_options.q2rtx.value() && bsp->loadversion->game->id == GAME_QUAKE_II, // FIXME: move to own config option. -light_nodraw?
light_options.q2rtx.value() &&
bsp->loadversion->game->id == GAME_QUAKE_II, // FIXME: move to own config option. -light_nodraw?
light_options.lightgrid.value());
}
@ -3349,8 +3350,8 @@ void DirectLightFace(const mbsp_t *bsp, lightsurf_t &lightsurf, const settings::
// mxd. Add surface lights...
// FIXME: negative surface lights
LightFace_SurfaceLight(bsp, &lightsurf, lightmaps, false, cfg.surflightscale.value(),
cfg.surflightskyscale.value(), 16.0f);
LightFace_SurfaceLight(
bsp, &lightsurf, lightmaps, false, cfg.surflightscale.value(), cfg.surflightskyscale.value(), 16.0f);
}
LightFace_LocalMin(bsp, face, &lightsurf, lightmaps);
@ -3389,8 +3390,8 @@ void IndirectLightFace(const mbsp_t *bsp, lightsurf_t &lightsurf, const settings
/* add bounce lighting */
// note: scale here is just to keep it close-ish to the old code
LightFace_SurfaceLight(bsp, &lightsurf, lightmaps, true, cfg.bouncescale.value() * 0.5,
cfg.bouncescale.value(), 128.0f);
LightFace_SurfaceLight(
bsp, &lightsurf, lightmaps, true, cfg.bouncescale.value() * 0.5, cfg.bouncescale.value(), 128.0f);
}
}
}
@ -3438,7 +3439,8 @@ void PostProcessLightFace(const mbsp_t *bsp, lightsurf_t &lightsurf, const setti
if (surface_minlight_scale > 0) {
minlight = std::get<0>(value.value()) * surface_minlight_scale;
minlight_color = std::get<2>(value.value());
LightFace_Min(bsp, face, minlight_color, minlight, &lightsurf, lightmaps, std::get<1>(value.value()));
LightFace_Min(
bsp, face, minlight_color, minlight, &lightsurf, lightmaps, std::get<1>(value.value()));
}
}
}
@ -3598,8 +3600,8 @@ lightgrid_samples_t CalcLightgridAtPoint(const mbsp_t *bsp, const qvec3d &world_
// mxd. Add surface lights...
// FIXME: negative surface lights
LightPoint_SurfaceLight(bsp, pvs, rs, false, cfg.surflightscale.value(), cfg.surflightskyscale.value(),
16.0f, world_point, result);
LightPoint_SurfaceLight(
bsp, pvs, rs, false, cfg.surflightscale.value(), cfg.surflightskyscale.value(), 16.0f, world_point, result);
#if 0
// FIXME: port to lightgrid
@ -3630,8 +3632,8 @@ lightgrid_samples_t CalcLightgridAtPoint(const mbsp_t *bsp, const qvec3d &world_
/* add bounce lighting */
// note: scale here is just to keep it close-ish to the old code
LightPoint_SurfaceLight(bsp, pvs, rs, true, cfg.bouncescale.value() * 0.5, cfg.bouncescale.value(),
128.0f, world_point, result);
LightPoint_SurfaceLight(
bsp, pvs, rs, true, cfg.bouncescale.value() * 0.5, cfg.bouncescale.value(), 128.0f, world_point, result);
LightPoint_ScaleAndClamp(result);

View File

@ -125,7 +125,7 @@ static void MakeSurfaceLight(const mbsp_t *bsp, const settings::worldspawn_keys
if (light_options.emissivequality.value() == emissivequality_t::LOW ||
light_options.emissivequality.value() == emissivequality_t::MEDIUM) {
l->points = { l->pos };
l->points = {l->pos};
l->points_before_culling++;
total_surflight_points++;

View File

@ -604,7 +604,7 @@ void GLView::renderBSP(const QString &file, const mbsp_t &bsp, const bspxentries
img::load_textures(&bsp, settings);
std::optional<bspxfacenormals> facenormals;
if (use_bspx_normals)
facenormals = BSPX_FaceNormals(bsp, bspx);

View File

@ -147,8 +147,8 @@ public:
~GLView();
void renderBSP(const QString &file, const mbsp_t &bsp, const bspxentries_t &bspx,
const std::vector<entdict_t> &entities, const full_atlas_t &lightmap,
const settings::common_settings &settings, bool use_bspx_normals);
const std::vector<entdict_t> &entities, const full_atlas_t &lightmap, const settings::common_settings &settings,
bool use_bspx_normals);
void setCamera(const qvec3d &origin, const qvec3d &fwd);
void setLighmapOnly(bool lighmapOnly);
void setFullbright(bool fullbright);

View File

@ -100,8 +100,8 @@ static QStringList GetRecents()
}
// ETLogWidget
ETLogWidget::ETLogWidget(QWidget *parent) :
QTabWidget(parent)
ETLogWidget::ETLogWidget(QWidget *parent)
: QTabWidget(parent)
{
for (size_t i = 0; i < std::size(logTabNames); i++) {
m_textEdits[i] = new QTextEdit();
@ -246,21 +246,26 @@ void MainWindow::createPropertiesSidebar()
void MainWindow::logWidgetSetText(ETLogTab tab, const std::string &str)
{
m_outputLogWidget->setTabText((int32_t) tab, str.c_str());
m_outputLogWidget->setTabText((int32_t)tab, str.c_str());
}
void MainWindow::lightpreview_percent_callback(std::optional<uint32_t> percent, std::optional<duration> elapsed)
{
int32_t tabIndex = (int32_t) m_activeLogTab;
int32_t tabIndex = (int32_t)m_activeLogTab;
if (elapsed.has_value()) {
lightpreview_log_callback(logging::flag::PROGRESS, fmt::format("finished in: {:.3}\n", elapsed.value()).c_str());
QMetaObject::invokeMethod(this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab, ETLogWidget::logTabNames[tabIndex]));
lightpreview_log_callback(
logging::flag::PROGRESS, fmt::format("finished in: {:.3}\n", elapsed.value()).c_str());
QMetaObject::invokeMethod(
this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab, ETLogWidget::logTabNames[tabIndex]));
} else {
if (percent.has_value()) {
QMetaObject::invokeMethod(this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab, fmt::format("{} [{:>3}%]", ETLogWidget::logTabNames[tabIndex], percent.value())));
QMetaObject::invokeMethod(
this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab,
fmt::format("{} [{:>3}%]", ETLogWidget::logTabNames[tabIndex], percent.value())));
} else {
QMetaObject::invokeMethod(this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab, fmt::format("{} (...)", ETLogWidget::logTabNames[tabIndex])));
QMetaObject::invokeMethod(this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab,
fmt::format("{} (...)", ETLogWidget::logTabNames[tabIndex])));
}
}
}
@ -270,18 +275,16 @@ void MainWindow::lightpreview_log_callback(logging::flag flags, const char *str)
if (bitflags(flags) & logging::flag::PERCENT)
return;
if (QApplication::instance()->thread() != QThread::currentThread())
{
QMetaObject::invokeMethod(this, std::bind([this, flags](const std::string &s) -> void
{
lightpreview_log_callback(flags, s.c_str());
}, std::string(str)));
if (QApplication::instance()->thread() != QThread::currentThread()) {
QMetaObject::invokeMethod(this,
std::bind([this, flags](const std::string &s) -> void { lightpreview_log_callback(flags, s.c_str()); },
std::string(str)));
return;
}
auto *textEdit = m_outputLogWidget->textEdit(m_activeLogTab);
const bool atBottom = textEdit->verticalScrollBar()->value() == textEdit->verticalScrollBar()->maximum();
QTextDocument* doc = textEdit->document();
QTextDocument *doc = textEdit->document();
QTextCursor cursor(doc);
cursor.movePosition(QTextCursor::End);
cursor.beginEditBlock();
@ -289,11 +292,11 @@ void MainWindow::lightpreview_log_callback(logging::flag flags, const char *str)
cursor.insertHtml(QString::asprintf("%s\n", str));
cursor.endEditBlock();
//scroll scrollarea to bottom if it was at bottom when we started
// scroll scrollarea to bottom if it was at bottom when we started
//(we don't want to force scrolling to bottom if user is looking at a
//higher position)
// higher position)
if (atBottom) {
QScrollBar* bar = textEdit->verticalScrollBar();
QScrollBar *bar = textEdit->verticalScrollBar();
bar->setValue(bar->maximum());
}
}
@ -310,8 +313,10 @@ void MainWindow::createOutputLog()
addDockWidget(Qt::BottomDockWidgetArea, dock);
viewMenu->addAction(dock->toggleViewAction());
logging::set_print_callback(std::bind(&MainWindow::lightpreview_log_callback, this, std::placeholders::_1, std::placeholders::_2));
logging::set_percent_callback(std::bind(&MainWindow::lightpreview_percent_callback, this, std::placeholders::_1, std::placeholders::_2));
logging::set_print_callback(
std::bind(&MainWindow::lightpreview_log_callback, this, std::placeholders::_1, std::placeholders::_2));
logging::set_percent_callback(
std::bind(&MainWindow::lightpreview_percent_callback, this, std::placeholders::_1, std::placeholders::_2));
}
void MainWindow::createStatusBar()
@ -469,7 +474,8 @@ bspdata_t MainWindow::QbspVisLight_Common(const std::filesystem::path &name, std
std::vector<std::string> extra_vis_args, std::vector<std::string> extra_light_args, bool run_vis)
{
auto resetActiveTabText = [&]() {
QMetaObject::invokeMethod(this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab, ETLogWidget::logTabNames[(int32_t) m_activeLogTab]));
QMetaObject::invokeMethod(this, std::bind(&MainWindow::logWidgetSetText, this, m_activeLogTab,
ETLogWidget::logTabNames[(int32_t)m_activeLogTab]));
};
auto bsp_path = name;

View File

@ -47,18 +47,13 @@ class ETLogWidget : public QTabWidget
Q_OBJECT
public:
static constexpr const char *logTabNames[(size_t) ETLogTab::TAB_TOTAL] = {
"lightpreview",
"bsp",
"vis",
"light"
};
static constexpr const char *logTabNames[(size_t)ETLogTab::TAB_TOTAL] = {"lightpreview", "bsp", "vis", "light"};
explicit ETLogWidget(QWidget *parent = nullptr);
~ETLogWidget() { }
QTextEdit *textEdit(ETLogTab i) { return m_textEdits[(size_t) i]; }
const QTextEdit *textEdit(ETLogTab i) const { return m_textEdits[(size_t) i]; }
QTextEdit *textEdit(ETLogTab i) { return m_textEdits[(size_t)i]; }
const QTextEdit *textEdit(ETLogTab i) const { return m_textEdits[(size_t)i]; }
auto &textEdits() { return m_textEdits; }

View File

@ -410,7 +410,7 @@ static void CalcTreeBounds_r(node_t *node, logging::percent_clock &clock)
}
if (node->bounds.mins()[0] >= node->bounds.maxs()[0]) {
//logging::print("WARNING: {} without a volume\n", node->is_leaf ? "leaf" : "node");
// logging::print("WARNING: {} without a volume\n", node->is_leaf ? "leaf" : "node");
// fixme-brushbsp: added this to work around leafs with no portals showing up in "qbspfeatures.map" among other
// test maps. Not sure if correct or there's another underlying problem.
@ -615,8 +615,8 @@ static void FloodAreas_r(node_t *node)
// note the current area as bounding the portal
if (entity->portalareas[1]) {
logging::print("WARNING: {}: areaportal touches > 2 areas\n Entity Bounds: {} -> {}\n",
entity->location, entity->bounds.mins(), entity->bounds.maxs());
logging::print("WARNING: {}: areaportal touches > 2 areas\n Entity Bounds: {} -> {}\n", entity->location,
entity->bounds.mins(), entity->bounds.maxs());
return;
}

View File

@ -1398,7 +1398,6 @@ static void BSPX_CreateBrushList(void)
}
}
}
}
if (!brushes.empty()) {