move immediately instead of splicing after construction (probably compiles to the same code but whatever)
don't add all of the `result_portals_onnode` one at a time; just directly copy-elision the result.
This commit is contained in:
parent
de7c8b42b4
commit
781a772d8a
|
|
@ -91,6 +91,7 @@ public:
|
|||
contentflags_t contents {};
|
||||
int16_t lmshift = 0; /* lightmap scaling (qu/lightmap pixel), passed to the light util */
|
||||
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)
|
||||
};
|
||||
|
||||
struct lumpdata
|
||||
|
|
|
|||
|
|
@ -231,26 +231,6 @@ qvec3d FixRotateOrigin(mapentity_t *entity)
|
|||
return offset;
|
||||
}
|
||||
|
||||
static bool MapBrush_IsHint(const mapbrush_t &brush)
|
||||
{
|
||||
for (auto &f : brush.faces) {
|
||||
if (f.flags.is_hint)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (hullnum <= 0 && Brush_IsHint(*hullbrush)) {
|
||||
/* Don't generate hintskip faces */
|
||||
const maptexinfo_t &texinfo = map.mtexinfos.at(mapface.texinfo);
|
||||
|
||||
if (qbsp_options.target_game->texinfo_is_hintskip(texinfo.flags, map.miptexTextureName(texinfo.miptex)))
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
//============================================================================
|
||||
|
||||
/*
|
||||
|
|
@ -315,6 +295,16 @@ std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, mapbrush_t *mapbrush
|
|||
for (size_t i = 0; i < mapbrush->faces.size(); i++) {
|
||||
auto &src = mapbrush->faces[i];
|
||||
|
||||
if (hullnum <= 0 && mapbrush->is_hint) {
|
||||
/* Don't generate hintskip faces */
|
||||
const maptexinfo_t &texinfo = map.mtexinfos.at(src.texinfo);
|
||||
|
||||
// any face that isn't a hint is assumed to be hintskip
|
||||
if (!texinfo.flags.is_hint) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// don't add bevels for the point hull
|
||||
if (hullnum <= 0 && src.bevel) {
|
||||
continue;
|
||||
|
|
@ -511,7 +501,7 @@ static void Brush_LoadEntity(mapentity_t *dst, mapentity_t *src, const int hulln
|
|||
}
|
||||
|
||||
/* "hint" brushes don't affect the collision hulls */
|
||||
if (MapBrush_IsHint(mapbrush)) {
|
||||
if (mapbrush.is_hint) {
|
||||
if (hullnum > 0)
|
||||
continue;
|
||||
contents = qbsp_options.target_game->create_empty_contents();
|
||||
|
|
|
|||
11
qbsp/map.cc
11
qbsp/map.cc
|
|
@ -2251,6 +2251,16 @@ inline void CalculateBrushBounds(mapbrush_t &ob)
|
|||
}
|
||||
}
|
||||
|
||||
inline bool MapBrush_IsHint(const mapbrush_t &brush)
|
||||
{
|
||||
for (auto &f : brush.faces) {
|
||||
if (f.flags.is_hint)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProcessMapBrushes()
|
||||
{
|
||||
logging::funcheader();
|
||||
|
|
@ -2295,6 +2305,7 @@ void ProcessMapBrushes()
|
|||
// set properties calculated above
|
||||
brush.lmshift = lmshift;
|
||||
brush.func_areaportal = areaportal;
|
||||
brush.is_hint = MapBrush_IsHint(brush);
|
||||
|
||||
// calculate brush bounds
|
||||
CalculateBrushBounds(brush);
|
||||
|
|
|
|||
|
|
@ -448,8 +448,7 @@ static std::list<buildportal_t> ClipNodePortalsToTree_r(node_t *node, portaltype
|
|||
auto front_fragments = ClipNodePortalsToTree_r(node->children[0], type, std::move(boundary_portals_split.front), stats);
|
||||
auto back_fragments = ClipNodePortalsToTree_r(node->children[1], type, std::move(boundary_portals_split.back), stats);
|
||||
|
||||
std::list<buildportal_t> merged_result;
|
||||
merged_result.splice(merged_result.end(), front_fragments);
|
||||
std::list<buildportal_t> merged_result = std::move(front_fragments);
|
||||
merged_result.splice(merged_result.end(), back_fragments);
|
||||
return merged_result;
|
||||
}
|
||||
|
|
@ -496,14 +495,11 @@ std::list<buildportal_t> MakeTreePortals_r(tree_t *tree, node_t *node, portaltyp
|
|||
std::list<buildportal_t> half_clipped =
|
||||
ClipNodePortalsToTree_r(node->children[0], type, make_list(std::move(*nodeportal)), stats);
|
||||
|
||||
for (auto &clipped_p : ClipNodePortalsToTree_r(node->children[1], type, std::move(half_clipped), stats)) {
|
||||
result_portals_onnode.push_back(std::move(clipped_p));
|
||||
}
|
||||
result_portals_onnode = ClipNodePortalsToTree_r(node->children[1], type, std::move(half_clipped), stats);
|
||||
}
|
||||
|
||||
// all done, merge together the lists and return
|
||||
std::list<buildportal_t> merged_result;
|
||||
merged_result.splice(merged_result.end(), result_portals_front);
|
||||
std::list<buildportal_t> merged_result = std::move(result_portals_front);
|
||||
merged_result.splice(merged_result.end(), result_portals_back);
|
||||
merged_result.splice(merged_result.end(), result_portals_onnode);
|
||||
return merged_result;
|
||||
|
|
|
|||
Loading…
Reference in New Issue