add the ability to specify a chop order; this is to help with "nested" func_groups and layers, since TB makes them an implicit object at random spots in the BSP. Now you can be sure your objects will chop in the right order.
This commit is contained in:
parent
be8ae00fa6
commit
93da0c9905
|
|
@ -108,6 +108,7 @@ public:
|
||||||
mapentity_t *func_areaportal = nullptr;
|
mapentity_t *func_areaportal = nullptr;
|
||||||
bool is_hint = false; // whether we are a hint brush or not (at least one side is "hint" or SURF_HINT)
|
bool is_hint = false; // whether we are a hint brush or not (at least one side is "hint" or SURF_HINT)
|
||||||
bool no_chop = false; // don't chop this
|
bool no_chop = false; // don't chop this
|
||||||
|
int32_t chop_index = 0; // chopping order; higher numbers chop lower numbers
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lumpdata
|
struct lumpdata
|
||||||
|
|
|
||||||
|
|
@ -3161,10 +3161,19 @@ void ProcessMapBrushes()
|
||||||
brush.func_areaportal = areaportal;
|
brush.func_areaportal = areaportal;
|
||||||
brush.is_hint = MapBrush_IsHint(brush);
|
brush.is_hint = MapBrush_IsHint(brush);
|
||||||
|
|
||||||
|
// _chop signals that a brush does not partake in the BSP chopping phase.
|
||||||
|
// this allows brushes embedded in others to be retained.
|
||||||
if (entity.epairs.has("_chop") && !entity.epairs.get_int("_chop")) {
|
if (entity.epairs.has("_chop") && !entity.epairs.get_int("_chop")) {
|
||||||
brush.no_chop = true;
|
brush.no_chop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// brushes are sorted by their _chop_order; higher numbered brushes
|
||||||
|
// will "eat" lower numbered brushes. This effectively overrides the
|
||||||
|
// brush order of the map.
|
||||||
|
if (entity.epairs.has("_chop_order")) {
|
||||||
|
brush.chop_index = entity.epairs.get_int("_chop_order");
|
||||||
|
}
|
||||||
|
|
||||||
// calculate brush bounds
|
// calculate brush bounds
|
||||||
CalculateBrushBounds(brush);
|
CalculateBrushBounds(brush);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1036,6 +1036,14 @@ static void ProcessEntity(mapentity_t &entity, hull_index_t hullnum)
|
||||||
|
|
||||||
// always chop the other hulls to reduce brush tests
|
// always chop the other hulls to reduce brush tests
|
||||||
if (qbsp_options.chop.value() || hullnum.value_or(0)) {
|
if (qbsp_options.chop.value() || hullnum.value_or(0)) {
|
||||||
|
std::sort(brushes.begin(), brushes.end(), [](const bspbrush_t::ptr &a, const bspbrush_t::ptr &b) -> bool {
|
||||||
|
if (a->mapbrush->chop_index == b->mapbrush->chop_index) {
|
||||||
|
return a->mapbrush->line.line_number < b->mapbrush->line.line_number;
|
||||||
|
}
|
||||||
|
|
||||||
|
return a->mapbrush->chop_index < b->mapbrush->chop_index;
|
||||||
|
});
|
||||||
|
|
||||||
ChopBrushes(brushes, qbsp_options.chopfragment.value());
|
ChopBrushes(brushes, qbsp_options.chopfragment.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue