move func_areaportal and lmshift from bspbrush_t to mapbrush_t
This commit is contained in:
parent
c0cec4e1ba
commit
70f015a36c
|
|
@ -67,8 +67,6 @@ struct bspbrush_t
|
|||
int side, testside; // side of node during construction
|
||||
std::vector<side_t> sides;
|
||||
contentflags_t contents; /* BSP contents */
|
||||
short lmshift; /* lightmap scaling (qu/lightmap pixel), passed to the light util */
|
||||
mapentity_t *func_areaportal;
|
||||
|
||||
qvec3d sphere_origin;
|
||||
double sphere_radius;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ enum class brushformat_t
|
|||
BRUSH_PRIMITIVES
|
||||
};
|
||||
|
||||
class mapentity_t;
|
||||
|
||||
class mapbrush_t
|
||||
{
|
||||
public:
|
||||
|
|
@ -82,6 +84,8 @@ public:
|
|||
std::optional<uint32_t> outputnumber; /* only set for original brushes */
|
||||
parser_source_location line;
|
||||
contentflags_t contents {};
|
||||
short lmshift = 0; /* lightmap scaling (qu/lightmap pixel), passed to the light util */
|
||||
mapentity_t *func_areaportal = nullptr;
|
||||
};
|
||||
|
||||
struct lumpdata
|
||||
|
|
|
|||
|
|
@ -355,8 +355,6 @@ static void Brush_LoadEntity(mapentity_t *dst, mapentity_t *src, const int hulln
|
|||
return;
|
||||
}
|
||||
|
||||
int i;
|
||||
int lmshift;
|
||||
bool all_detail, all_detail_fence, all_detail_illusionary;
|
||||
|
||||
const std::string &classname = src->epairs.get("classname");
|
||||
|
|
@ -379,16 +377,6 @@ static void Brush_LoadEntity(mapentity_t *dst, mapentity_t *src, const int hulln
|
|||
}
|
||||
}
|
||||
|
||||
/* entities with custom lmscales are important for the qbsp to know about */
|
||||
i = 16 * src->epairs.get_float("_lmscale");
|
||||
if (!i)
|
||||
i = 16; // if 0, pick a suitable default
|
||||
lmshift = 0;
|
||||
while (i > 1) {
|
||||
lmshift++; // only allow power-of-two scales
|
||||
i /= 2;
|
||||
}
|
||||
|
||||
/* _mirrorinside key (for func_water etc.) */
|
||||
std::optional<bool> mirrorinside;
|
||||
|
||||
|
|
@ -406,7 +394,7 @@ static void Brush_LoadEntity(mapentity_t *dst, mapentity_t *src, const int hulln
|
|||
const bool func_illusionary_visblocker = (0 == Q_strcasecmp(classname, "func_illusionary_visblocker"));
|
||||
|
||||
auto it = src->mapbrushes.begin();
|
||||
for (i = 0; i < src->mapbrushes.size(); i++, it++) {
|
||||
for (size_t i = 0; i < src->mapbrushes.size(); i++, it++) {
|
||||
logging::percent(i, src->mapbrushes.size());
|
||||
auto &mapbrush = *it;
|
||||
contentflags_t contents = mapbrush.contents;
|
||||
|
|
@ -510,14 +498,8 @@ static void Brush_LoadEntity(mapentity_t *dst, mapentity_t *src, const int hulln
|
|||
continue;
|
||||
}
|
||||
|
||||
brush->lmshift = lmshift;
|
||||
|
||||
for (auto &face : brush->sides) {
|
||||
face.lmshift = lmshift;
|
||||
}
|
||||
|
||||
if (classname == std::string_view("func_areaportal")) {
|
||||
brush->func_areaportal = const_cast<mapentity_t *>(src); // FIXME: get rid of consts on src in the callers?
|
||||
face.lmshift = mapbrush.lmshift;
|
||||
}
|
||||
|
||||
qbsp_options.target_game->count_contents_in_stats(brush->contents, stats);
|
||||
|
|
|
|||
|
|
@ -494,8 +494,6 @@ static twosided<std::unique_ptr<bspbrush_t>> SplitBrush(std::unique_ptr<bspbrush
|
|||
result[i]->original = brush->original;
|
||||
// fixme-brushbsp: add a bspbrush_t copy constructor to make sure we get all fields
|
||||
result[i]->contents = brush->contents;
|
||||
result[i]->lmshift = brush->lmshift;
|
||||
result[i]->func_areaportal = brush->func_areaportal;
|
||||
result[i]->sides.reserve(brush->sides.size() + 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
22
qbsp/map.cc
22
qbsp/map.cc
|
|
@ -2268,9 +2268,31 @@ void ProcessMapBrushes()
|
|||
/* Origin brush support */
|
||||
entity.rotation = rotation_t::none;
|
||||
|
||||
|
||||
/* entities with custom lmscales are important for the qbsp to know about */
|
||||
int i = 16 * entity.epairs.get_float("_lmscale");
|
||||
if (!i) {
|
||||
i = 16; // if 0, pick a suitable default
|
||||
}
|
||||
int lmshift = 0;
|
||||
while (i > 1) {
|
||||
lmshift++; // only allow power-of-two scales
|
||||
i /= 2;
|
||||
}
|
||||
|
||||
mapentity_t *areaportal = nullptr;
|
||||
|
||||
if (entity.epairs.get("classname") == "func_areaportal") {
|
||||
areaportal = &entity;
|
||||
}
|
||||
|
||||
for (auto it = entity.mapbrushes.begin(); it != entity.mapbrushes.end(); ) {
|
||||
auto &brush = *it;
|
||||
|
||||
// set properties calculated above
|
||||
brush.lmshift = lmshift;
|
||||
brush.func_areaportal = areaportal;
|
||||
|
||||
// calculate brush bounds
|
||||
CalculateBrushBounds(brush);
|
||||
|
||||
|
|
|
|||
|
|
@ -573,8 +573,8 @@ static mapentity_t *AreanodeEntityForLeaf(node_t *node)
|
|||
}
|
||||
|
||||
for (auto &brush : node->original_brushes) {
|
||||
if (brush->func_areaportal) {
|
||||
return brush->func_areaportal;
|
||||
if (brush->mapbrush->func_areaportal) {
|
||||
return brush->mapbrush->func_areaportal;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
|||
Loading…
Reference in New Issue