Merge branch 'type-cleanup' into brushbsp

This commit is contained in:
Eric Wasylishen 2022-02-17 00:43:08 -07:00
commit 2a257693c6
10 changed files with 45 additions and 24 deletions

View File

@ -208,7 +208,7 @@ struct compiled_brush_t
for (auto &side : sides) {
planepoints p;
if (side.winding) {
if (side.winding && side.winding->size()) {
p = WindingToThreePoints(*side.winding);
} else {
p = NormalDistanceToThreePoints(side.plane);
@ -1120,7 +1120,6 @@ static void DecompileEntity(
DecompileNode(stack, bsp, headnode, tasks);
// decompile the leafs in parallel
std::vector<compiled_brush_t> compiledBrushes;
compiledBrushes.resize(tasks.size());
tbb::parallel_for(static_cast<size_t>(0), tasks.size(), [&](const size_t &i) {
if (options.geometryOnly) {

View File

@ -462,8 +462,8 @@ struct gamedef_q2_t : public gamedef_t
int32_t get_content_type(const contentflags_t &contents) const
{
return (contents.native & ((Q2_LAST_VISIBLE_CONTENTS << 1) - 1)) |
(Q2_CONTENTS_PLAYERCLIP | Q2_CONTENTS_MONSTERCLIP | Q2_CONTENTS_ORIGIN | Q2_CONTENTS_DETAIL | Q2_CONTENTS_TRANSLUCENT | Q2_CONTENTS_AREAPORTAL);
return contents.native & (((Q2_LAST_VISIBLE_CONTENTS << 1) - 1) |
(Q2_CONTENTS_PLAYERCLIP | Q2_CONTENTS_MONSTERCLIP | Q2_CONTENTS_ORIGIN | Q2_CONTENTS_TRANSLUCENT | Q2_CONTENTS_AREAPORTAL));
}
int32_t contents_priority(const contentflags_t &contents) const

View File

@ -110,6 +110,8 @@ struct texdata_t
std::string name;
surfflags_t flags;
int32_t value;
std::string animation;
int32_t animation_miptex = -1;
};
struct mapdata_t
@ -178,6 +180,7 @@ struct extended_texinfo_t
contentflags_t contents = { 0 };
surfflags_t flags = { 0 };
int value = 0;
std::string animation;
};
struct quark_tx_info_t

View File

@ -191,9 +191,10 @@ struct mtexinfo_t
int32_t miptex = 0;
surfflags_t flags = {};
int32_t value = 0; // Q2-specific
int32_t next = -1; // Q2-specific
std::optional<size_t> outputnum = std::nullopt; // nullopt until added to bsp
constexpr auto as_tuple() const { return std::tie(vecs, miptex, flags, value); }
constexpr auto as_tuple() const { return std::tie(vecs, miptex, flags, value, next); }
constexpr bool operator<(const mtexinfo_t &other) const { return as_tuple() < other.as_tuple(); }

View File

@ -237,9 +237,9 @@ static void *MakeBounceLightsThread(void *arg)
styleColor.second /= 255.0f;
}
// lerp between gray and the texture color according to `bouncecolorscale`
// lerp between gray and the texture color according to `bouncecolorscale` (0 = use gray, 1 = use texture color)
qvec3f texturecolor = qvec3f(Face_LookupTextureColor(bsp, face)) / 255.0f;
qvec3f blendedcolor = mix(texturecolor, { 127.f / 255.f }, cfg.bouncecolorscale.floatValue());
qvec3f blendedcolor = mix(qvec3f{127.f / 255.f}, texturecolor, cfg.bouncecolorscale.floatValue());
// final colors to emit
map<int, qvec3f> emitcolors;

View File

@ -653,6 +653,7 @@ static contentflags_t Brush_GetContents(const mapbrush_t *mapbrush)
for (int i = 0; i < mapbrush->numfaces; i++) {
const mapface_t &mapface = mapbrush->face(i);
const mtexinfo_t &texinfo = map.mtexinfos.at(mapface.texinfo);
contentflags_t contents = options.target_game->face_get_contents(mapface.texname.data(), texinfo.flags, mapface.contents);
if (contents.is_empty(options.target_game)) {

View File

@ -188,14 +188,10 @@ int FindMiptex(const char *name, std::optional<extended_texinfo_t> &extended_inf
}
} else {
// load .wal first
std::optional<img::texture_meta> wal;
std::optional<img::texture_meta> wal = LoadWal(name);
if (!internal && !extended_info.has_value()) {
wal = LoadWal(name);
if (wal) {
extended_info = extended_texinfo_t{wal->contents, wal->flags, wal->value};
}
if (wal && !internal && !extended_info.has_value()) {
extended_info = extended_texinfo_t{wal->contents, wal->flags, wal->value, wal->animation};
}
if (!extended_info.has_value()) {
@ -205,19 +201,21 @@ int FindMiptex(const char *name, std::optional<extended_texinfo_t> &extended_inf
for (i = 0; i < map.nummiptex(); i++) {
const texdata_t &tex = map.miptex.at(i);
if (!Q_strcasecmp(name, tex.name.c_str()) && tex.flags.native == extended_info->flags.native &&
tex.value == extended_info->value) {
if (!Q_strcasecmp(name, tex.name.c_str()) &&
tex.flags.native == extended_info->flags.native &&
tex.value == extended_info->value &&
tex.animation == extended_info->animation) {
return i;
}
}
i = map.miptex.size();
map.miptex.push_back({name, extended_info->flags, extended_info->value});
map.miptex.push_back({name, extended_info->flags, extended_info->value, extended_info->animation});
/* Handle animating textures carefully */
if (wal && !wal->animation.empty()) {
FindMiptex(wal->animation.data());
if (!extended_info->animation.empty()) {
map.miptex[i].animation_miptex = FindMiptex(extended_info->animation.data(), internal);
}
}
@ -295,12 +293,21 @@ int FindTexinfo(const mtexinfo_t &texinfo)
/* Allocate a new texinfo at the end of the array */
const int num_texinfo = static_cast<int>(map.mtexinfos.size());
map.mtexinfos.push_back(texinfo);
map.mtexinfos.emplace_back(texinfo);
map.mtexinfo_lookup[texinfo] = num_texinfo;
// catch broken < implementations in mtexinfo_t
assert(map.mtexinfo_lookup.find(texinfo) != map.mtexinfo_lookup.end());
// create a copy of the miptex for animation chains
if (map.miptex[texinfo.miptex].animation_miptex != -1) {
mtexinfo_t anim_next = texinfo;
anim_next.miptex = map.miptex[texinfo.miptex].animation_miptex;
map.mtexinfos[num_texinfo].next = FindTexinfo(anim_next);
}
return num_texinfo;
}
@ -1306,8 +1313,6 @@ static void ParseTextureDef(parser_t &parser, mapface_t &mapface, const mapbrush
qvec2d shift, scale;
texcoord_style_t tx_type;
memset(tx, 0, sizeof(*tx));
quark_tx_info_t extinfo;
if (brush->format == brushformat_t::BRUSH_PRIMITIVES) {
@ -1362,6 +1367,12 @@ static void ParseTextureDef(parser_t &parser, mapface_t &mapface, const mapbrush
// info so it can at least compile.
if (options.target_game->id != GAME_QUAKE_II) {
extinfo.info = std::nullopt;
} else {
// assign animation to extinfo, so that we load the animated
// first one first
if (auto wal = LoadWal(mapface.texname.c_str())) {
extinfo.info->animation = wal->animation;
}
}
tx->miptex = FindMiptex(mapface.texname.c_str(), extinfo.info);

View File

@ -652,7 +652,6 @@ static void ProcessEntity(mapentity_t *entity, const int hullnum)
}
FreeBrushes(entity);
// fixme-brushbsp: why is this crashig?
//FreeNodes(nodes);
}

View File

@ -104,6 +104,10 @@ size_t ExportMapTexinfo(size_t texinfonum)
src.outputnum = i;
if (src.next != -1) {
map.bsp.texinfo[i].nexttexinfo = ExportMapTexinfo(src.next);
}
return i;
}

View File

@ -14,7 +14,10 @@
set -x
UPDATE_HASHES=0
CONTINUE_ON_FAILURE=0
# FIXME: reset back to 0
CONTINUE_ON_FAILURE=1
if [[ "$1" == "--update-hashes" ]]; then
UPDATE_HASHES=1
elif [[ "$1" == "--continue-on-failure" ]]; then