qbsp: import BaseWindingForNode from qbsp3
This commit is contained in:
parent
3e2045479b
commit
af2dd987d8
|
|
@ -355,6 +355,7 @@ struct portal_t;
|
|||
struct node_t
|
||||
{
|
||||
aabb3d bounds; // bounding volume, not just points inside
|
||||
node_t *parent;
|
||||
|
||||
// information for decision nodes
|
||||
int planenum; // -1 = leaf node
|
||||
|
|
|
|||
|
|
@ -225,6 +225,39 @@ static void CheckLeafPortalConsistancy(node_t *node)
|
|||
|
||||
//============================================================================
|
||||
|
||||
/*
|
||||
================
|
||||
BaseWindingForNode
|
||||
|
||||
Creates a winding from the given node plane, clipped by all parent nodes.
|
||||
================
|
||||
*/
|
||||
#define BASE_WINDING_EPSILON 0.001
|
||||
#define SPLIT_WINDING_EPSILON 0.001
|
||||
|
||||
std::optional<winding_t> BaseWindingForNode(node_t *node)
|
||||
{
|
||||
auto plane = map.planes.at(node->planenum);
|
||||
|
||||
std::optional<winding_t> w = BaseWindingForPlane(plane);
|
||||
|
||||
// clip by all the parents
|
||||
for (node_t *np = node->parent; np && w; )
|
||||
{
|
||||
plane = map.planes.at(np->planenum);
|
||||
|
||||
const side_t keep = (np->children[0] == node) ?
|
||||
SIDE_FRONT : SIDE_BACK;
|
||||
|
||||
w = w->clip(plane, BASE_WINDING_EPSILON, false)[keep];
|
||||
|
||||
node = np;
|
||||
np = np->parent;
|
||||
}
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CutNodePortals_r
|
||||
|
|
|
|||
|
|
@ -865,7 +865,9 @@ static void PartitionBrushes(std::vector<std::unique_ptr<brush_t>> brushes, node
|
|||
splitnodes++;
|
||||
|
||||
node->children[0] = new node_t{};
|
||||
node->children[0]->parent = node;
|
||||
node->children[1] = new node_t{};
|
||||
node->children[1]->parent = node;
|
||||
node->planenum = FindPositivePlane(split->planenum);
|
||||
|
||||
node->detail_separator = AllDetail(brushes);
|
||||
|
|
@ -933,9 +935,11 @@ tree_t *BrushBSP(mapentity_t *entity, bool midsplit)
|
|||
headnode->children[0] = new node_t{};
|
||||
headnode->children[0]->planenum = PLANENUM_LEAF;
|
||||
headnode->children[0]->contents = options.target_game->create_empty_contents();
|
||||
headnode->children[0]->parent = headnode;
|
||||
headnode->children[1] = new node_t{};
|
||||
headnode->children[1]->planenum = PLANENUM_LEAF;
|
||||
headnode->children[1]->contents = options.target_game->create_empty_contents();
|
||||
headnode->children[1]->parent = headnode;
|
||||
|
||||
tree->headnode = headnode;
|
||||
tree->bounds = headnode->bounds;
|
||||
|
|
|
|||
Loading…
Reference in New Issue