mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-15 08:41:59 +00:00
Use floating point node bounding boxes
This commit is contained in:
parent
265783e1f6
commit
7d03ed4dc7
7 changed files with 46 additions and 28 deletions
|
@ -156,12 +156,12 @@ int FNodeBuilder::CreateNode (DWORD set, unsigned int count, fixed_t bbox[4])
|
|||
D(PrintSet (1, set1));
|
||||
D(Printf (PRINT_LOG, "(%d,%d) delta (%d,%d) from seg %d\n", node.x>>16, node.y>>16, node.dx>>16, node.dy>>16, splitseg));
|
||||
D(PrintSet (2, set2));
|
||||
node.intchildren[0] = CreateNode (set1, count1, node.bbox[0]);
|
||||
node.intchildren[1] = CreateNode (set2, count2, node.bbox[1]);
|
||||
bbox[BOXTOP] = MAX (node.bbox[0][BOXTOP], node.bbox[1][BOXTOP]);
|
||||
bbox[BOXBOTTOM] = MIN (node.bbox[0][BOXBOTTOM], node.bbox[1][BOXBOTTOM]);
|
||||
bbox[BOXLEFT] = MIN (node.bbox[0][BOXLEFT], node.bbox[1][BOXLEFT]);
|
||||
bbox[BOXRIGHT] = MAX (node.bbox[0][BOXRIGHT], node.bbox[1][BOXRIGHT]);
|
||||
node.intchildren[0] = CreateNode (set1, count1, node.nb_bbox[0]);
|
||||
node.intchildren[1] = CreateNode (set2, count2, node.nb_bbox[1]);
|
||||
bbox[BOXTOP] = MAX (node.nb_bbox[0][BOXTOP], node.nb_bbox[1][BOXTOP]);
|
||||
bbox[BOXBOTTOM] = MIN (node.nb_bbox[0][BOXBOTTOM], node.nb_bbox[1][BOXBOTTOM]);
|
||||
bbox[BOXLEFT] = MIN (node.nb_bbox[0][BOXLEFT], node.nb_bbox[1][BOXLEFT]);
|
||||
bbox[BOXRIGHT] = MAX (node.nb_bbox[0][BOXRIGHT], node.nb_bbox[1][BOXRIGHT]);
|
||||
return (int)Nodes.Push (node);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -94,6 +94,13 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
|||
outNodes[i].children[j] = outNodes + outNodes[i].intchildren[j];
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 2; ++j)
|
||||
{
|
||||
for (int k = 0; k < 4; ++k)
|
||||
{
|
||||
outNodes[i].bbox[j][k] = FIXED2FLOAT(outNodes[i].nb_bbox[j][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GLNodes)
|
||||
|
@ -194,6 +201,13 @@ void FNodeBuilder::ExtractMini (FMiniBSP *bsp)
|
|||
bsp->Nodes[i].children[j] = &bsp->Nodes[bsp->Nodes[i].intchildren[j]];
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 2; ++j)
|
||||
{
|
||||
for (int k = 0; k < 4; ++k)
|
||||
{
|
||||
bsp->Nodes[i].bbox[j][k] = FIXED2FLOAT(bsp->Nodes[i].nb_bbox[j][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (GLNodes)
|
||||
|
|
|
@ -589,7 +589,7 @@ static bool LoadNodes (FileReader * lump)
|
|||
}
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
no->bbox[j][k] = LittleShort(mn->bbox[j][k])<<FRACBITS;
|
||||
no->bbox[j][k] = (float)LittleShort(mn->bbox[j][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ static bool LoadNodes (FileReader * lump)
|
|||
}
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
no->bbox[j][k] = LittleShort(mn->bbox[j][k])<<FRACBITS;
|
||||
no->bbox[j][k] = (float)LittleShort(mn->bbox[j][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1135,7 +1135,7 @@ static void CreateCachedNodes(MapData *map)
|
|||
{
|
||||
for (int k = 0; k < 4; ++k)
|
||||
{
|
||||
WriteWord(ZNodes, nodes[i].bbox[j][k] >> FRACBITS);
|
||||
WriteWord(ZNodes, (short)nodes[i].bbox[j][k]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1096,7 +1096,7 @@ void LoadZNodes(FileReaderBase &data, int glnodes)
|
|||
{
|
||||
SWORD coord;
|
||||
data >> coord;
|
||||
nodes[i].bbox[j][k] = coord << FRACBITS;
|
||||
nodes[i].bbox[j][k] = coord;
|
||||
}
|
||||
}
|
||||
for (int m = 0; m < 2; ++m)
|
||||
|
@ -1640,7 +1640,7 @@ void P_LoadNodes (MapData * map)
|
|||
}
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
no->bbox[j][k] = LittleShort(mn->bbox[j][k])<<FRACBITS;
|
||||
no->bbox[j][k] = (float)LittleShort(mn->bbox[j][k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1919,7 +1919,7 @@ static double PartitionDistance(FPolyVertex *vt, node_t *node)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void AddToBBox(fixed_t child[4], fixed_t parent[4])
|
||||
static void AddToBBox(float child[4], float parent[4])
|
||||
{
|
||||
if (child[BOXTOP] > parent[BOXTOP])
|
||||
{
|
||||
|
@ -1945,10 +1945,10 @@ static void AddToBBox(fixed_t child[4], fixed_t parent[4])
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void AddToBBox(FPolyVertex *v, fixed_t bbox[4])
|
||||
static void AddToBBox(FPolyVertex *v, float bbox[4])
|
||||
{
|
||||
fixed_t x = FLOAT2FIXED(v->pos.X);
|
||||
fixed_t y = FLOAT2FIXED(v->pos.Y);
|
||||
float x = float(v->pos.X);
|
||||
float y = float(v->pos.Y);
|
||||
if (x < bbox[BOXLEFT])
|
||||
{
|
||||
bbox[BOXLEFT] = x;
|
||||
|
@ -1973,7 +1973,7 @@ static void AddToBBox(FPolyVertex *v, fixed_t bbox[4])
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void SplitPoly(FPolyNode *pnode, void *node, fixed_t bbox[4])
|
||||
static void SplitPoly(FPolyNode *pnode, void *node, float bbox[4])
|
||||
{
|
||||
static TArray<FPolySeg> lists[2];
|
||||
static const double POLY_EPSILON = 0.3125;
|
||||
|
@ -2110,7 +2110,7 @@ static void SplitPoly(FPolyNode *pnode, void *node, fixed_t bbox[4])
|
|||
|
||||
// calculate bounding box for this polynode
|
||||
assert(pnode->segs.Size() != 0);
|
||||
fixed_t subbbox[4] = { FIXED_MIN, FIXED_MAX, FIXED_MAX, FIXED_MIN };
|
||||
float subbbox[4] = { FLT_MIN, FLT_MAX, FLT_MAX, FLT_MIN };
|
||||
|
||||
for (unsigned i = 0; i < pnode->segs.Size(); ++i)
|
||||
{
|
||||
|
@ -2134,7 +2134,7 @@ void FPolyObj::CreateSubsectorLinks()
|
|||
// Even though we don't care about it, we need to initialize this
|
||||
// bounding box to something so that Valgrind won't complain about it
|
||||
// when SplitPoly modifies it.
|
||||
fixed_t dummybbox[4] = { 0 };
|
||||
float dummybbox[4] = { 0 };
|
||||
|
||||
node->poly = this;
|
||||
node->segs.Resize(Sidedefs.Size());
|
||||
|
|
|
@ -877,7 +877,7 @@ extern "C" const int checkcoord[12][4] =
|
|||
};
|
||||
|
||||
|
||||
static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
|
||||
static bool R_CheckBBox (float *bspcoord) // killough 1/28/98: static
|
||||
{
|
||||
int boxx;
|
||||
int boxy;
|
||||
|
@ -891,16 +891,16 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
|
|||
|
||||
// Find the corners of the box
|
||||
// that define the edges from current viewpoint.
|
||||
if (ViewPos.X <= FIXED2DBL(bspcoord[BOXLEFT]))
|
||||
if (ViewPos.X <= bspcoord[BOXLEFT])
|
||||
boxx = 0;
|
||||
else if (ViewPos.X < FIXED2DBL(bspcoord[BOXRIGHT]))
|
||||
else if (ViewPos.X < bspcoord[BOXRIGHT])
|
||||
boxx = 1;
|
||||
else
|
||||
boxx = 2;
|
||||
|
||||
if (ViewPos.Y >= FIXED2DBL(bspcoord[BOXTOP]))
|
||||
if (ViewPos.Y >= bspcoord[BOXTOP])
|
||||
boxy = 0;
|
||||
else if (ViewPos.Y > FIXED2DBL(bspcoord[BOXBOTTOM]))
|
||||
else if (ViewPos.Y > bspcoord[BOXBOTTOM])
|
||||
boxy = 1;
|
||||
else
|
||||
boxy = 2;
|
||||
|
@ -909,10 +909,10 @@ static bool R_CheckBBox (fixed_t *bspcoord) // killough 1/28/98: static
|
|||
if (boxpos == 5)
|
||||
return true;
|
||||
|
||||
x1 = FIXED2DBL(bspcoord[checkcoord[boxpos][0]]) - ViewPos.X;
|
||||
y1 = FIXED2DBL(bspcoord[checkcoord[boxpos][1]]) - ViewPos.Y;
|
||||
x2 = FIXED2DBL(bspcoord[checkcoord[boxpos][2]]) - ViewPos.X;
|
||||
y2 = FIXED2DBL(bspcoord[checkcoord[boxpos][3]]) - ViewPos.Y;
|
||||
x1 = bspcoord[checkcoord[boxpos][0]] - ViewPos.X;
|
||||
y1 = bspcoord[checkcoord[boxpos][1]] - ViewPos.Y;
|
||||
x2 = bspcoord[checkcoord[boxpos][2]] - ViewPos.X;
|
||||
y2 = bspcoord[checkcoord[boxpos][3]] - ViewPos.Y;
|
||||
|
||||
// check clip list for an open space
|
||||
|
||||
|
|
|
@ -1364,7 +1364,11 @@ struct node_t
|
|||
fixed_t y;
|
||||
fixed_t dx;
|
||||
fixed_t dy;
|
||||
fixed_t bbox[2][4]; // Bounding box for each child.
|
||||
union
|
||||
{
|
||||
float bbox[2][4]; // Bounding box for each child.
|
||||
fixed_t nb_bbox[2][4]; // Used by nodebuilder.
|
||||
};
|
||||
float len;
|
||||
union
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue