From fbea58d6794e823f1b164e01c3e2a8623e32caba Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 25 Jun 2023 18:29:48 -0600 Subject: [PATCH] code formatting pass --- bsputil/bsputil.cc | 3 +- common/bspfile.cc | 13 +++---- common/bspinfo.cc | 2 +- common/imglib.cc | 7 ++-- common/log.cc | 3 +- include/common/bspfile.hh | 5 ++- include/common/imglib.hh | 4 +- include/light/surflight.hh | 6 +-- light/bounce.cc | 7 ++-- light/light.cc | 8 ++-- light/ltface.cc | 78 +++++++++++++++++++------------------ light/surflight.cc | 2 +- lightpreview/glview.cpp | 2 +- lightpreview/glview.h | 4 +- lightpreview/mainwindow.cpp | 48 +++++++++++++---------- lightpreview/mainwindow.h | 11 ++---- qbsp/portals.cc | 6 +-- qbsp/qbsp.cc | 1 - 18 files changed, 104 insertions(+), 106 deletions(-) diff --git a/bsputil/bsputil.cc b/bsputil/bsputil.cc index 2eac8c44..2ac93bd9 100644 --- a/bsputil/bsputil.cc +++ b/bsputil/bsputil.cc @@ -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... diff --git a/common/bspfile.cc b/common/bspfile.cc index 9cb66c2d..580a61a9 100644 --- a/common/bspfile.cc +++ b/common/bspfile.cc @@ -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); } diff --git a/common/bspinfo.cc b/common/bspinfo.cc index 00ddde48..24827aae 100644 --- a/common/bspinfo.cc +++ b/common/bspinfo.cc @@ -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; } diff --git a/common/imglib.cc b/common/imglib.cc index aaaffa86..4fc955eb 100644 --- a/common/imglib.cc +++ b/common/imglib.cc @@ -326,11 +326,10 @@ qvec3b calculate_average(const std::vector &pixels) return avg /= n; } -std::tuple, 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, 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"; diff --git a/common/log.cc b/common/log.cc index e1dfa8c2..670d2ffd 100644 --- a/common/log.cc +++ b/common/log.cc @@ -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; } diff --git a/include/common/bspfile.hh b/include/common/bspfile.hh index 99934e68..41589640 100644 --- a/include/common/bspfile.hh +++ b/include/common/bspfile.hh @@ -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; diff --git a/include/common/imglib.hh b/include/common/imglib.hh index dbb5dcd5..b902897c 100644 --- a/include/common/imglib.hh +++ b/include/common/imglib.hh @@ -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, 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, 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 { diff --git a/include/light/surflight.hh b/include/light/surflight.hh index 02fa5620..6599c400 100644 --- a/include/light/surflight.hh +++ b/include/light/surflight.hh @@ -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; diff --git a/light/bounce.cc b/light/bounce.cc index b80c6de6..cea587c7 100644 --- a/light/bounce.cc +++ b/light/bounce.cc @@ -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 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); } diff --git a/light/light.cc b/light/light.cc index 32c578cc..7f506864 100644 --- a/light/light.cc +++ b/light/light.cc @@ -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(0), bsp->dfaces.size(), [&bsp](size_t i) { - light_surfaces[i].reset(); - }); + logging::parallel_for(static_cast(0), bsp->dfaces.size(), [&bsp](size_t i) { light_surfaces[i].reset(); }); } static void FindModelInfo(const mbsp_t *bsp) diff --git a/light/ltface.cc b/light/ltface.cc index 9c115c94..36b94aa8 100644 --- a/light/ltface.cc +++ b/light/ltface.cc @@ -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 *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 *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 *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); diff --git a/light/surflight.cc b/light/surflight.cc index 7fffa954..44d06ce2 100644 --- a/light/surflight.cc +++ b/light/surflight.cc @@ -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++; diff --git a/lightpreview/glview.cpp b/lightpreview/glview.cpp index 27b00892..7a011e43 100644 --- a/lightpreview/glview.cpp +++ b/lightpreview/glview.cpp @@ -604,7 +604,7 @@ void GLView::renderBSP(const QString &file, const mbsp_t &bsp, const bspxentries img::load_textures(&bsp, settings); std::optional facenormals; - + if (use_bspx_normals) facenormals = BSPX_FaceNormals(bsp, bspx); diff --git a/lightpreview/glview.h b/lightpreview/glview.h index bbdaf5db..271690bc 100644 --- a/lightpreview/glview.h +++ b/lightpreview/glview.h @@ -147,8 +147,8 @@ public: ~GLView(); void renderBSP(const QString &file, const mbsp_t &bsp, const bspxentries_t &bspx, - const std::vector &entities, const full_atlas_t &lightmap, - const settings::common_settings &settings, bool use_bspx_normals); + const std::vector &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); diff --git a/lightpreview/mainwindow.cpp b/lightpreview/mainwindow.cpp index b3401b7c..e84a985e 100644 --- a/lightpreview/mainwindow.cpp +++ b/lightpreview/mainwindow.cpp @@ -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 percent, std::optional 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 extra_vis_args, std::vector 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; diff --git a/lightpreview/mainwindow.h b/lightpreview/mainwindow.h index d6355b1d..b484c525 100644 --- a/lightpreview/mainwindow.h +++ b/lightpreview/mainwindow.h @@ -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; } diff --git a/qbsp/portals.cc b/qbsp/portals.cc index 3ddb1d7e..16a6143e 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -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; } diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index cdeb666d..8d3122d6 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -1398,7 +1398,6 @@ static void BSPX_CreateBrushList(void) } } } - } if (!brushes.empty()) {