qbsp: rename brush_t -> bspbrush_t for consistency with qbsp3
This commit is contained in:
parent
12a5c6555c
commit
038651fca6
|
|
@ -28,13 +28,12 @@
|
|||
|
||||
class mapentity_t;
|
||||
|
||||
struct brush_t
|
||||
{
|
||||
struct bspbrush_t {
|
||||
/**
|
||||
* The brushes in the mapentity_t::brushes vector are considered originals. Brush fragments created during
|
||||
* the BrushBSP will have this pointing back to the original brush in mapentity_t::brushes.
|
||||
*/
|
||||
brush_t *original;
|
||||
bspbrush_t *original;
|
||||
uint32_t file_order;
|
||||
aabb3d bounds;
|
||||
std::vector<face_t> faces;
|
||||
|
|
@ -57,7 +56,7 @@ enum class rotation_t
|
|||
origin_brush
|
||||
};
|
||||
|
||||
std::optional<brush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, const contentflags_t &contents,
|
||||
std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, const contentflags_t &contents,
|
||||
const qvec3d &rotate_offset, const rotation_t rottype, const int hullnum);
|
||||
void FreeBrushes(mapentity_t *ent);
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
struct brush_t;
|
||||
struct bspbrush_t;
|
||||
struct face_t;
|
||||
|
||||
face_t *NewFaceFromFace(const face_t *in);
|
||||
|
|
@ -35,5 +35,5 @@ face_t *CopyFace(const face_t *in);
|
|||
face_t *MirrorFace(const face_t *face);
|
||||
std::tuple<face_t *, face_t *> SplitFace(face_t *in, const qplane3d &split);
|
||||
void UpdateFaceSphere(face_t *in);
|
||||
bool BrushGE(const brush_t &a, const brush_t &b);
|
||||
std::vector<std::unique_ptr<brush_t>> ChopBrushes(const std::vector<std::unique_ptr<brush_t>> &input);
|
||||
bool BrushGE(const bspbrush_t &a, const bspbrush_t &b);
|
||||
std::vector<std::unique_ptr<bspbrush_t>> ChopBrushes(const std::vector<std::unique_ptr<bspbrush_t>> &input);
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include <unordered_map>
|
||||
#include <list>
|
||||
|
||||
struct brush_t;
|
||||
struct bspbrush_t;
|
||||
|
||||
struct qbsp_plane_t : qplane3d
|
||||
{
|
||||
|
|
@ -102,7 +102,7 @@ public:
|
|||
entdict_t epairs;
|
||||
|
||||
aabb3d bounds;
|
||||
std::vector<std::unique_ptr<brush_t>> brushes;
|
||||
std::vector<std::unique_ptr<bspbrush_t>> brushes;
|
||||
|
||||
int firstoutputfacenumber = -1;
|
||||
std::optional<size_t> outputmodelnumber = std::nullopt;
|
||||
|
|
@ -218,7 +218,7 @@ constexpr int HULL_COLLISION = -1;
|
|||
/* Create BSP brushes from map brushes */
|
||||
void Brush_LoadEntity(mapentity_t *entity, const int hullnum);
|
||||
|
||||
std::list<face_t *> CSGFace(face_t *srcface, const mapentity_t* srcentity, const brush_t *srcbrush, const node_t *srcnode);
|
||||
std::list<face_t *> CSGFace(face_t *srcface, const mapentity_t* srcentity, const bspbrush_t *srcbrush, const node_t *srcnode);
|
||||
void TJunc(const mapentity_t *entity, node_t *headnode);
|
||||
int MakeFaceEdges(mapentity_t *entity, node_t *headnode);
|
||||
void ExportClipNodes(mapentity_t *entity, node_t *headnode, const int hullnum);
|
||||
|
|
@ -232,10 +232,10 @@ void BSPX_Brushes_Finalize(struct bspxbrushes_s *ctx);
|
|||
void BSPX_Brushes_Init(struct bspxbrushes_s *ctx);
|
||||
|
||||
void ExportObj_Faces(const std::string &filesuffix, const std::vector<const face_t *> &faces);
|
||||
void ExportObj_Brushes(const std::string &filesuffix, const std::vector<const brush_t *> &brushes);
|
||||
void ExportObj_Brushes(const std::string &filesuffix, const std::vector<const bspbrush_t *> &brushes);
|
||||
void ExportObj_Nodes(const std::string &filesuffix, const node_t *nodes);
|
||||
void ExportObj_Marksurfaces(const std::string &filesuffix, const node_t *nodes);
|
||||
|
||||
void WriteBspBrushMap(const fs::path &name, const std::vector<std::unique_ptr<brush_t>> &list);
|
||||
void WriteBspBrushMap(const fs::path &name, const std::vector<std::unique_ptr<bspbrush_t>> &list);
|
||||
|
||||
bool IsValidTextureProjection(const qvec3f &faceNormal, const qvec3f &s_vec, const qvec3f &t_vec);
|
||||
|
|
|
|||
|
|
@ -353,7 +353,7 @@ struct face_t : face_fragment_t
|
|||
|
||||
// there is a node_t structure for every node and leaf in the bsp tree
|
||||
|
||||
struct brush_t;
|
||||
struct bspbrush_t;
|
||||
|
||||
struct node_t
|
||||
{
|
||||
|
|
@ -369,7 +369,7 @@ struct node_t
|
|||
|
||||
// information for leafs
|
||||
contentflags_t contents; // leaf nodes (0 for decision nodes)
|
||||
std::vector<brush_t *> original_brushes;
|
||||
std::vector<bspbrush_t *> original_brushes;
|
||||
std::vector<face_t *> markfaces; // leaf nodes only, point to node faces
|
||||
portal_t *portals;
|
||||
int visleafnum; // -1 = solid
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
extern std::atomic<int> splitnodes;
|
||||
|
||||
struct brush_t;
|
||||
struct bspbrush_t;
|
||||
struct node_t;
|
||||
struct face_t;
|
||||
class mapentity_t;
|
||||
|
|
@ -40,5 +40,5 @@ struct tree_t;
|
|||
void DetailToSolid(node_t *node);
|
||||
void PruneNodes(node_t *node);
|
||||
bool WindingIsTiny(const winding_t &w, double size = 0.2);
|
||||
twosided<std::unique_ptr<brush_t>> SplitBrush(std::unique_ptr<brush_t> brush, const qplane3d &split);
|
||||
twosided<std::unique_ptr<bspbrush_t>> SplitBrush(std::unique_ptr<bspbrush_t> brush, const qplane3d &split);
|
||||
tree_t *BrushBSP(mapentity_t *entity, bool midsplit);
|
||||
|
|
|
|||
|
|
@ -755,7 +755,7 @@ LoadBrush
|
|||
Converts a mapbrush to a bsp brush
|
||||
===============
|
||||
*/
|
||||
std::optional<brush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, const contentflags_t &contents,
|
||||
std::optional<bspbrush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *mapbrush, const contentflags_t &contents,
|
||||
const qvec3d &rotate_offset, const rotation_t rottype, const int hullnum)
|
||||
{
|
||||
hullbrush_t hullbrush;
|
||||
|
|
@ -796,7 +796,7 @@ std::optional<brush_t> LoadBrush(const mapentity_t *src, const mapbrush_t *mapbr
|
|||
}
|
||||
|
||||
// create the brush
|
||||
brush_t brush{};
|
||||
bspbrush_t brush{};
|
||||
brush.contents = contents;
|
||||
brush.faces = std::move(facelist);
|
||||
brush.bounds = hullbrush.bounds;
|
||||
|
|
@ -826,7 +826,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
|
|||
continue;
|
||||
}
|
||||
|
||||
std::optional<brush_t> brush = LoadBrush(src, mapbrush, contents, {}, rotation_t::none, 0);
|
||||
std::optional<bspbrush_t> brush = LoadBrush(src, mapbrush, contents, {}, rotation_t::none, 0);
|
||||
|
||||
if (brush) {
|
||||
rotate_offset = brush->bounds.centroid();
|
||||
|
|
@ -946,7 +946,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
|
|||
*/
|
||||
if (hullnum != HULL_COLLISION && contents.is_clip(options.target_game)) {
|
||||
if (hullnum == 0) {
|
||||
std::optional<brush_t> brush = LoadBrush(src, mapbrush, contents, rotate_offset, rottype, hullnum);
|
||||
std::optional<bspbrush_t> brush = LoadBrush(src, mapbrush, contents, rotate_offset, rottype, hullnum);
|
||||
|
||||
if (brush) {
|
||||
dst->bounds += brush->bounds;
|
||||
|
|
@ -996,7 +996,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
|
|||
contents.set_clips_same_type(clipsametype);
|
||||
contents.illusionary_visblocker = func_illusionary_visblocker;
|
||||
|
||||
std::optional<brush_t> brush = LoadBrush(src, mapbrush, contents, rotate_offset, rottype, hullnum);
|
||||
std::optional<bspbrush_t> brush = LoadBrush(src, mapbrush, contents, rotate_offset, rottype, hullnum);
|
||||
if (!brush)
|
||||
continue;
|
||||
|
||||
|
|
@ -1010,7 +1010,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
|
|||
}
|
||||
|
||||
options.target_game->count_contents_in_stats(brush->contents, stats);
|
||||
dst->brushes.push_back(std::make_unique<brush_t>(brush.value()));
|
||||
dst->brushes.push_back(std::make_unique<bspbrush_t>(brush.value()));
|
||||
dst->bounds += brush->bounds;
|
||||
}
|
||||
|
||||
|
|
@ -1057,7 +1057,7 @@ void Brush_LoadEntity(mapentity_t *entity, const int hullnum)
|
|||
options.target_game->print_content_stats(stats, "brushes");
|
||||
}
|
||||
|
||||
void brush_t::update_bounds()
|
||||
void bspbrush_t::update_bounds()
|
||||
{
|
||||
this->bounds = {};
|
||||
for (const face_t &face : faces) {
|
||||
|
|
|
|||
|
|
@ -122,11 +122,11 @@ void ExportObj_Faces(const std::string &filesuffix, const std::vector<const face
|
|||
}
|
||||
}
|
||||
|
||||
void ExportObj_Brushes(const std::string &filesuffix, const std::vector<const brush_t *> &brushes)
|
||||
void ExportObj_Brushes(const std::string &filesuffix, const std::vector<const bspbrush_t *> &brushes)
|
||||
{
|
||||
std::vector<const face_t *> faces;
|
||||
|
||||
for (const brush_t *brush : brushes)
|
||||
for (const bspbrush_t *brush : brushes)
|
||||
for (auto &face : brush->faces)
|
||||
faces.push_back(&face);
|
||||
|
||||
|
|
|
|||
|
|
@ -2284,7 +2284,7 @@ WriteBspBrushMap
|
|||
from q3map
|
||||
==================
|
||||
*/
|
||||
void WriteBspBrushMap(const fs::path &name, const std::vector<std::unique_ptr<brush_t>> &list)
|
||||
void WriteBspBrushMap(const fs::path &name, const std::vector<std::unique_ptr<bspbrush_t>> &list)
|
||||
{
|
||||
logging::print("writing {}\n", name);
|
||||
std::ofstream f(name);
|
||||
|
|
@ -2330,16 +2330,16 @@ from q3map
|
|||
*/
|
||||
static void TestExpandBrushes(const mapentity_t *src)
|
||||
{
|
||||
std::vector<std::unique_ptr<brush_t>> hull1brushes;
|
||||
std::vector<std::unique_ptr<bspbrush_t>> hull1brushes;
|
||||
|
||||
for (int i = 0; i < src->nummapbrushes; i++) {
|
||||
const mapbrush_t *mapbrush = &src->mapbrush(i);
|
||||
std::optional<brush_t> hull1brush = LoadBrush(
|
||||
std::optional<bspbrush_t> hull1brush = LoadBrush(
|
||||
src, mapbrush, {CONTENTS_SOLID}, {}, rotation_t::none, options.target_game->id == GAME_QUAKE_II ? HULL_COLLISION : 1);
|
||||
|
||||
if (hull1brush) {
|
||||
hull1brushes.emplace_back(
|
||||
std::make_unique<brush_t>(std::move(*hull1brush)));
|
||||
std::make_unique<bspbrush_t>(std::move(*hull1brush)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ Adds any additional planes necessary to allow the brush to be expanded
|
|||
against axial bounding boxes
|
||||
=================
|
||||
*/
|
||||
static std::vector<std::tuple<size_t, const face_t *>> AddBrushBevels(const brush_t &b)
|
||||
static std::vector<std::tuple<size_t, const face_t *>> AddBrushBevels(const bspbrush_t &b)
|
||||
{
|
||||
// add already-present planes
|
||||
std::vector<std::tuple<size_t, const face_t *>> planes;
|
||||
|
|
@ -1019,7 +1019,7 @@ hull sizes
|
|||
*/
|
||||
|
||||
static void BSPX_Brushes_AddModel(
|
||||
struct bspxbrushes_s *ctx, int modelnum, std::vector<std::unique_ptr<brush_t>> &brushes)
|
||||
struct bspxbrushes_s *ctx, int modelnum, std::vector<std::unique_ptr<bspbrush_t>> &brushes)
|
||||
{
|
||||
bspxbrushes_permodel permodel{1, modelnum};
|
||||
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ ChooseMidPlaneFromList
|
|||
The clipping hull BSP doesn't worry about avoiding splits
|
||||
==================
|
||||
*/
|
||||
static const face_t *ChooseMidPlaneFromList(const std::vector<std::unique_ptr<brush_t>> &brushes, const aabb3d &bounds)
|
||||
static const face_t *ChooseMidPlaneFromList(const std::vector<std::unique_ptr<bspbrush_t>> &brushes, const aabb3d &bounds)
|
||||
{
|
||||
/* pick the plane that splits the least */
|
||||
vec_t bestaxialmetric = VECT_MAX;
|
||||
|
|
@ -375,7 +375,7 @@ The real BSP heuristic
|
|||
fixme-brushbsp: prefer splits that include a lot of brush sides?
|
||||
==================
|
||||
*/
|
||||
static const face_t *ChoosePlaneFromList(const std::vector<std::unique_ptr<brush_t>> &brushes, const aabb3d &bounds)
|
||||
static const face_t *ChoosePlaneFromList(const std::vector<std::unique_ptr<bspbrush_t>> &brushes, const aabb3d &bounds)
|
||||
{
|
||||
/* pick the plane that splits the least */
|
||||
int minsplits = INT_MAX - 1;
|
||||
|
|
@ -477,7 +477,7 @@ returns NULL if the surface list can not be divided any more (a leaf)
|
|||
Called in parallel.
|
||||
==================
|
||||
*/
|
||||
static const face_t *SelectPartition(const std::vector<std::unique_ptr<brush_t>> &brushes)
|
||||
static const face_t *SelectPartition(const std::vector<std::unique_ptr<bspbrush_t>> &brushes)
|
||||
{
|
||||
// calculate a bounding box of the entire surfaceset
|
||||
aabb3d bounds;
|
||||
|
|
@ -569,7 +569,7 @@ BrushMostlyOnSide
|
|||
|
||||
==================
|
||||
*/
|
||||
side_t BrushMostlyOnSide(const brush_t &brush, const qplane3d &plane)
|
||||
side_t BrushMostlyOnSide(const bspbrush_t &brush, const qplane3d &plane)
|
||||
{
|
||||
vec_t max = 0;
|
||||
side_t side = SIDE_FRONT;
|
||||
|
|
@ -595,7 +595,7 @@ BrushVolume
|
|||
|
||||
==================
|
||||
*/
|
||||
vec_t BrushVolume(const brush_t &brush)
|
||||
vec_t BrushVolume(const bspbrush_t &brush)
|
||||
{
|
||||
// grab the first valid point as the corner
|
||||
|
||||
|
|
@ -635,9 +635,9 @@ input.
|
|||
https://github.com/id-Software/Quake-2-Tools/blob/master/bsp/qbsp3/brushbsp.c#L935
|
||||
================
|
||||
*/
|
||||
twosided<std::unique_ptr<brush_t>> SplitBrush(std::unique_ptr<brush_t> brush, const qplane3d &split)
|
||||
twosided<std::unique_ptr<bspbrush_t>> SplitBrush(std::unique_ptr<bspbrush_t> brush, const qplane3d &split)
|
||||
{
|
||||
twosided<std::unique_ptr<brush_t>> result;
|
||||
twosided<std::unique_ptr<bspbrush_t>> result;
|
||||
|
||||
// check all points
|
||||
vec_t d_front = 0;
|
||||
|
|
@ -692,9 +692,9 @@ twosided<std::unique_ptr<brush_t>> SplitBrush(std::unique_ptr<brush_t> brush, co
|
|||
// start with 2 empty brushes
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
result[i] = std::make_unique<brush_t>();
|
||||
result[i] = std::make_unique<bspbrush_t>();
|
||||
result[i]->original = brush->original;
|
||||
// fixme-brushbsp: add a brush_t copy constructor to make sure we get all fields
|
||||
// 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;
|
||||
|
|
@ -806,7 +806,7 @@ inline void DivideNodeBounds(node_t *node, const qbsp_plane_t &split)
|
|||
DivideBounds(node->bounds, split, node->children[0]->bounds, node->children[1]->bounds);
|
||||
}
|
||||
|
||||
static bool AllDetail(const std::vector<std::unique_ptr<brush_t>> &brushes)
|
||||
static bool AllDetail(const std::vector<std::unique_ptr<bspbrush_t>> &brushes)
|
||||
{
|
||||
for (auto &brush : brushes) {
|
||||
if (!brush->contents.is_any_detail(options.target_game)) {
|
||||
|
|
@ -826,7 +826,7 @@ original faces that have some fragment inside this leaf.
|
|||
Called in parallel.
|
||||
==================
|
||||
*/
|
||||
static void CreateLeaf(std::vector<std::unique_ptr<brush_t>> brushes, node_t *leafnode)
|
||||
static void CreateLeaf(std::vector<std::unique_ptr<bspbrush_t>> brushes, node_t *leafnode)
|
||||
{
|
||||
leafnode->facelist.clear();
|
||||
leafnode->planenum = PLANENUM_LEAF;
|
||||
|
|
@ -850,7 +850,7 @@ PartitionBrushes
|
|||
Called in parallel.
|
||||
==================
|
||||
*/
|
||||
static void PartitionBrushes(std::vector<std::unique_ptr<brush_t>> brushes, node_t *node)
|
||||
static void PartitionBrushes(std::vector<std::unique_ptr<bspbrush_t>> brushes, node_t *node)
|
||||
{
|
||||
face_t *split = const_cast<face_t *>(SelectPartition(brushes));
|
||||
|
||||
|
|
@ -876,7 +876,7 @@ static void PartitionBrushes(std::vector<std::unique_ptr<brush_t>> brushes, node
|
|||
DivideNodeBounds(node, splitplane);
|
||||
|
||||
// multiple surfaces, so split all the polysurfaces into front and back lists
|
||||
std::vector<std::unique_ptr<brush_t>> frontlist, backlist;
|
||||
std::vector<std::unique_ptr<bspbrush_t>> frontlist, backlist;
|
||||
|
||||
for (auto &brush : brushes) {
|
||||
// NOTE: we're destroying `brushes` here with the std::move()
|
||||
|
|
@ -977,9 +977,9 @@ tree_t *BrushBSP(mapentity_t *entity, bool midsplit)
|
|||
mapbrushes = entity->brushes.size();
|
||||
|
||||
// set the original pointers
|
||||
std::vector<std::unique_ptr<brush_t>> brushcopies;
|
||||
std::vector<std::unique_ptr<bspbrush_t>> brushcopies;
|
||||
for (const auto &original : entity->brushes) {
|
||||
auto copy = std::make_unique<brush_t>(*original);
|
||||
auto copy = std::make_unique<bspbrush_t>(*original);
|
||||
copy->original = original.get();
|
||||
brushcopies.push_back(std::move(copy));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ TEST_CASE("duplicatePlanes", "[qbsp]")
|
|||
CHECK(0 == worldspawn.brushes.size());
|
||||
CHECK(6 == worldspawn.mapbrush(0).numfaces);
|
||||
|
||||
std::optional<brush_t> brush =
|
||||
std::optional<bspbrush_t> brush =
|
||||
LoadBrush(&worldspawn, &worldspawn.mapbrush(0), {CONTENTS_SOLID}, {}, rotation_t::none, 0);
|
||||
REQUIRE(std::nullopt != brush);
|
||||
CHECK(6 == brush->faces.size());
|
||||
|
|
|
|||
Loading…
Reference in New Issue