diff --git a/bsputil/bsputil.cc b/bsputil/bsputil.cc index 046dd71c..aa8a433f 100644 --- a/bsputil/bsputil.cc +++ b/bsputil/bsputil.cc @@ -627,6 +627,17 @@ int bsputil_main(int argc, char **argv) ent.get_vector("origin", origin); origin *= scalar; ent.set("origin", fmt::format("{} {} {}", origin[0], origin[1], origin[2])); + } else if (ent.has("lip")) { + float lip = ent.get_float("lip"); + lip -= 2.0f; + lip *= scalar; + lip += 2.0f; + ent.set("lip", fmt::format("{}", lip)); + } else if (ent.has("height")) { + // FIXME: check this + float height = ent.get_float("height"); + height *= scalar; + ent.set("height", fmt::format("{}", height)); } } diff --git a/lightpreview/glview.cpp b/lightpreview/glview.cpp index 27f541e3..0efdf064 100644 --- a/lightpreview/glview.cpp +++ b/lightpreview/glview.cpp @@ -596,11 +596,15 @@ void GLView::takeScreenshot(QString destPath, int w, int h) } void GLView::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) + const std::vector &entities, const full_atlas_t &lightmap, const settings::common_settings &settings, + bool use_bspx_normals) { img::load_textures(&bsp, settings); - auto facenormals = BSPX_FaceNormals(bsp, bspx); + std::optional facenormals; + + if (use_bspx_normals) + facenormals = BSPX_FaceNormals(bsp, bspx); // NOTE: according to https://doc.qt.io/qt-6/qopenglwidget.html#resource-initialization-and-cleanup // we can only do this after `initializeGL()` has run once. diff --git a/lightpreview/glview.h b/lightpreview/glview.h index e3aff7f3..bbdaf5db 100644 --- a/lightpreview/glview.h +++ b/lightpreview/glview.h @@ -148,7 +148,7 @@ public: 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); + 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 57092caa..70f44390 100644 --- a/lightpreview/mainwindow.cpp +++ b/lightpreview/mainwindow.cpp @@ -153,6 +153,12 @@ void MainWindow::createPropertiesSidebar() nearest = new QCheckBox(tr("Nearest Filter")); + bspx_decoupled_lm = new QCheckBox(tr("BSPX: Decoupled Lightmap")); + bspx_decoupled_lm->setChecked(true); + + bspx_normals = new QCheckBox(tr("BSPX: Face Normals")); + bspx_normals->setChecked(true); + formLayout->addRow(tr("qbsp"), qbsp_options); formLayout->addRow(vis_checkbox, vis_options); formLayout->addRow(tr("light"), light_options); @@ -161,6 +167,8 @@ void MainWindow::createPropertiesSidebar() formLayout->addRow(showtris); formLayout->addRow(keepposition); formLayout->addRow(nearest); + formLayout->addRow(bspx_decoupled_lm); + formLayout->addRow(bspx_normals); lightstyles = new QVBoxLayout(); @@ -580,9 +588,9 @@ void MainWindow::loadFileInternal(const QString &file, bool is_reload) auto ents = EntData_Parse(bsp); // build lightmap atlas - auto atlas = build_lightmap_atlas(bsp, m_bspdata.bspx.entries, false, true); + auto atlas = build_lightmap_atlas(bsp, m_bspdata.bspx.entries, false, bspx_decoupled_lm->isChecked()); - glView->renderBSP(file, bsp, m_bspdata.bspx.entries, ents, atlas, render_settings); + glView->renderBSP(file, bsp, m_bspdata.bspx.entries, ents, atlas, render_settings, bspx_normals->isChecked()); if (!is_reload && !glView->getKeepOrigin()) { for (auto &ent : ents) { diff --git a/lightpreview/mainwindow.h b/lightpreview/mainwindow.h index e704c193..afd43d7d 100644 --- a/lightpreview/mainwindow.h +++ b/lightpreview/mainwindow.h @@ -72,6 +72,8 @@ private: QCheckBox *vis_checkbox = nullptr; QCheckBox *nearest = nullptr; + QCheckBox *bspx_decoupled_lm = nullptr; + QCheckBox *bspx_normals = nullptr; QLineEdit *qbsp_options = nullptr; QLineEdit *vis_options = nullptr;