qbsp: fix misc_external_map + -wrbrushes
- fix world extents not including external maps - thanks @DaZombieKiller for pointing this out Fixes #372
This commit is contained in:
parent
f8d432c861
commit
c77f4ba2dd
|
|
@ -49,7 +49,7 @@ static std::string hex_string(const uint8_t *bytes, const size_t count)
|
|||
/**
|
||||
* returns a JSON array of models
|
||||
*/
|
||||
static json serialize_bspxbrushlist(const std::vector<uint8_t> &lump)
|
||||
json serialize_bspxbrushlist(const std::vector<uint8_t> &lump)
|
||||
{
|
||||
json j = json::array();
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#include "common/imglib.hh"
|
||||
#include "common/qvec.hh"
|
||||
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
|
|
@ -44,3 +46,5 @@ struct full_atlas_t
|
|||
full_atlas_t build_lightmap_atlas(const mbsp_t &bsp, const bspxentries_t &bspx, const std::vector<uint8_t> &litdata, bool use_bspx, bool use_decoupled);
|
||||
|
||||
void serialize_bsp(const bspdata_t &bspdata, const mbsp_t &bsp, const fs::path &name);
|
||||
|
||||
nlohmann::json serialize_bspxbrushlist(const std::vector<uint8_t> &lump);
|
||||
|
|
|
|||
|
|
@ -888,9 +888,6 @@ void Brush_LoadEntity(mapentity_t &entity, hull_index_t hullnum, bspbrush_t::con
|
|||
for (int i = 1; i < map.entities.size(); i++) {
|
||||
mapentity_t &source = map.entities.at(i);
|
||||
|
||||
/* Load external .map and change the classname, if needed */
|
||||
ProcessExternalMapEntity(source);
|
||||
|
||||
ProcessAreaPortal(source);
|
||||
|
||||
if (IsWorldBrushEntity(source) || IsNonRemoveWorldBrushEntity(source)) {
|
||||
|
|
|
|||
|
|
@ -3104,6 +3104,11 @@ void ProcessMapBrushes()
|
|||
{
|
||||
logging::funcheader();
|
||||
|
||||
// load external maps (needs to be before world extents are calculated)
|
||||
for (auto &source : map.entities) {
|
||||
ProcessExternalMapEntity(source);
|
||||
}
|
||||
|
||||
// calculate extents, if required
|
||||
if (!qbsp_options.worldextent.value()) {
|
||||
CalculateWorldExtent();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
// Game: Quake
|
||||
// Format: Valve
|
||||
// entity 0
|
||||
{
|
||||
"mapversion" "220"
|
||||
"classname" "worldspawn"
|
||||
}
|
||||
// entity 1
|
||||
{
|
||||
"classname" "misc_external_map"
|
||||
"origin" "0 0 0"
|
||||
"_external_map" "q1_external_map_included.map"
|
||||
"_external_map_classname" "func_group"
|
||||
"_external_map_angle" "180"
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// Game: Quake
|
||||
// Format: Valve
|
||||
// entity 0
|
||||
{
|
||||
"mapversion" "220"
|
||||
"classname" "worldspawn"
|
||||
"wad" "deprecated/free_wad.wad"
|
||||
// brush 0
|
||||
{
|
||||
( -64 -64 -16 ) ( -64 -63 -16 ) ( -64 -64 -15 ) sand [ 0 -1 0 0 ] [ 0 0 -1 0 ] 0 1 1
|
||||
( -64 -64 -16 ) ( -64 -64 -15 ) ( -63 -64 -16 ) sand [ 1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
|
||||
( -64 -64 -16 ) ( -63 -64 -16 ) ( -64 -63 -16 ) sand [ -1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
|
||||
( 64 64 16 ) ( 64 65 16 ) ( 65 64 16 ) sand [ 1 0 0 0 ] [ 0 -1 0 0 ] 0 1 1
|
||||
( 64 64 16 ) ( 65 64 16 ) ( 64 64 17 ) sand [ -1 0 0 0 ] [ 0 0 -1 0 ] 0 1 1
|
||||
( 64 64 16 ) ( 64 64 17 ) ( 64 65 16 ) sand [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
|
||||
}
|
||||
}
|
||||
|
|
@ -67,6 +67,7 @@ mapentity_t &LoadMapPath(const std::filesystem::path &name)
|
|||
}
|
||||
|
||||
#include <common/bspinfo.hh>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
std::tuple<mbsp_t, bspxentries_t, std::optional<prtfile_t>> LoadTestmap(
|
||||
const std::filesystem::path &name, std::vector<std::string> extra_args)
|
||||
|
|
@ -1992,3 +1993,26 @@ TEST_CASE("hl_basic")
|
|||
CHECK(64 == bsp.dtex.textures[1].width);
|
||||
CHECK(64 == bsp.dtex.textures[1].height);
|
||||
}
|
||||
|
||||
TEST_CASE("wrbrushes + misc_external_map")
|
||||
{
|
||||
const auto [bsp, bspx, prt] = LoadTestmap("q1_external_map_base.map", {"-wrbrushes"});
|
||||
|
||||
auto models_json = serialize_bspxbrushlist(bspx.at("BRUSHLIST"));
|
||||
logging::print("{}\n", to_string(models_json));
|
||||
|
||||
REQUIRE(models_json.size() == 1);
|
||||
|
||||
auto &model_json = models_json.at(0);
|
||||
REQUIRE(model_json.at("brushes").size() == 1);
|
||||
|
||||
auto &brush_json = model_json.at("brushes").at(0);
|
||||
REQUIRE(brush_json.at("maxs") == nlohmann::json::array({nlohmann::json::number_float_t(64),
|
||||
nlohmann::json::number_float_t(64),
|
||||
nlohmann::json::number_float_t(16)
|
||||
}));
|
||||
REQUIRE(brush_json.at("mins") == nlohmann::json::array({nlohmann::json::number_float_t(-64),
|
||||
nlohmann::json::number_float_t(-64),
|
||||
nlohmann::json::number_float_t(-16)
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue