diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index 6184b9f1..f5512e18 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -227,6 +227,7 @@ public: setting_validator maxedges; setting_numeric midsplitbrushfraction; setting_string add; + setting_scalar scale; setting_bool loghulls; setting_bool logbmodels; diff --git a/qbsp/map.cc b/qbsp/map.cc index 43d2cf45..16d57582 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2582,6 +2582,12 @@ static void ScaleMapFace(mapface_t &face, const qvec3d &scale) } face.set_texvecs(newtexvecs); + + // update winding + + for (qvec3d &p : face.winding) { + p = scaleM * p; + } } static void RotateMapFace(mapface_t &face, const qvec3d &angles) @@ -3070,6 +3076,27 @@ void ProcessMapBrushes() } } + // apply global scale + if (qbsp_options.scale.value() != 1.0) { + // scale brushes + for (auto &brush : entity.mapbrushes) { + for (auto &f : brush.faces) { + ScaleMapFace(f, qvec3d(qbsp_options.scale.value())); + } + CalculateBrushBounds(brush); + } + + // scale point entity origin + if (entity.epairs.find("origin") != entity.epairs.end()) { + qvec3d origin; + if (3 == entity.epairs.get_vector("origin", origin)) { + origin *= qbsp_options.scale.value(); + + entity.epairs.set("origin", qv::to_string(origin)); + } + } + } + // remove windings, we no longer need them for (auto &brush : entity.mapbrushes) { for (auto &f : brush.faces) { @@ -3474,6 +3501,10 @@ inline vec_t GetBrushExtents(const mapbrush_t &hullbrush) } } + if (qbsp_options.scale.value() != 1) { + extents *= qbsp_options.scale.value(); + } + return extents; } diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index a5b0b651..520eab14 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -569,6 +569,8 @@ qbsp_settings::qbsp_settings() midsplitbrushfraction{this, "midsplitbrushfraction", 0.0, &common_format_group, "switch to cheaper partitioning if a node contains this % of brushes in the map"}, add{this, "add", "", "", &common_format_group, "the given map file will be appended to the base map"}, + scale{this, "scale", 1.0, &map_development_group, + "scales the map brushes and point entity origins by a give factor"}, loghulls{this, {"loghulls"}, false, &logging_group, "print log output for collision hulls"}, logbmodels{this, {"logbmodels"}, false, &logging_group, "print log output for bmodels"} {