qbsp: experimental -scale flag for applying uniform scale to map

This commit is contained in:
Eric Wasylishen 2023-04-25 18:41:21 -06:00
parent e9539eff82
commit 537bc3686d
3 changed files with 34 additions and 0 deletions

View File

@ -227,6 +227,7 @@ public:
setting_validator<setting_int32> maxedges;
setting_numeric<vec_t> midsplitbrushfraction;
setting_string add;
setting_scalar scale;
setting_bool loghulls;
setting_bool logbmodels;

View File

@ -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;
}

View File

@ -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"}
{