mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
Use 64-bit fixed point for node builder's vertex map
https://forum.zdoom.org/viewtopic.php?t=59368
This commit is contained in:
parent
e70250425a
commit
56df88c792
3 changed files with 12 additions and 10 deletions
|
@ -814,8 +814,8 @@ void FNodeBuilder::SplitSegs (uint32_t set, node_t &node, uint32_t splitseg, uin
|
||||||
frac = InterceptVector (node, *seg);
|
frac = InterceptVector (node, *seg);
|
||||||
newvert.x = Vertices[seg->v1].x;
|
newvert.x = Vertices[seg->v1].x;
|
||||||
newvert.y = Vertices[seg->v1].y;
|
newvert.y = Vertices[seg->v1].y;
|
||||||
newvert.x += fixed_t(frac * double(Vertices[seg->v2].x - newvert.x));
|
newvert.x += fixed_t(frac * (double(Vertices[seg->v2].x) - newvert.x));
|
||||||
newvert.y += fixed_t(frac * double(Vertices[seg->v2].y - newvert.y));
|
newvert.y += fixed_t(frac * (double(Vertices[seg->v2].y) - newvert.y));
|
||||||
vertnum = VertexMap->SelectVertexClose (newvert);
|
vertnum = VertexMap->SelectVertexClose (newvert);
|
||||||
|
|
||||||
if (vertnum != (unsigned int)seg->v1 && vertnum != (unsigned int)seg->v2)
|
if (vertnum != (unsigned int)seg->v1 && vertnum != (unsigned int)seg->v2)
|
||||||
|
|
|
@ -91,6 +91,8 @@ struct FSimpleVert
|
||||||
fixed_t x, y;
|
fixed_t x, y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef int64_t fixed64_t;
|
||||||
|
|
||||||
class FNodeBuilder
|
class FNodeBuilder
|
||||||
{
|
{
|
||||||
struct FPrivSeg
|
struct FPrivSeg
|
||||||
|
@ -167,14 +169,14 @@ class FNodeBuilder
|
||||||
FNodeBuilder &MyBuilder;
|
FNodeBuilder &MyBuilder;
|
||||||
TArray<int> *VertexGrid;
|
TArray<int> *VertexGrid;
|
||||||
|
|
||||||
fixed_t MinX, MinY, MaxX, MaxY;
|
fixed64_t MinX, MinY, MaxX, MaxY;
|
||||||
int BlocksWide, BlocksTall;
|
int BlocksWide, BlocksTall;
|
||||||
|
|
||||||
enum { BLOCK_SHIFT = 8 + FRACBITS };
|
enum { BLOCK_SHIFT = 8 + FRACBITS };
|
||||||
enum { BLOCK_SIZE = 1 << BLOCK_SHIFT };
|
enum { BLOCK_SIZE = 1 << BLOCK_SHIFT };
|
||||||
|
|
||||||
int InsertVertex (FPrivVert &vert);
|
int InsertVertex (FPrivVert &vert);
|
||||||
inline int GetBlock (fixed_t x, fixed_t y)
|
inline int GetBlock (fixed64_t x, fixed64_t y)
|
||||||
{
|
{
|
||||||
assert (x >= MinX);
|
assert (x >= MinX);
|
||||||
assert (y >= MinY);
|
assert (y >= MinY);
|
||||||
|
|
|
@ -641,8 +641,8 @@ FNodeBuilder::FVertexMap::FVertexMap (FNodeBuilder &builder,
|
||||||
MinY = miny;
|
MinY = miny;
|
||||||
BlocksWide = int(((double(maxx) - minx + 1) + (BLOCK_SIZE - 1)) / BLOCK_SIZE);
|
BlocksWide = int(((double(maxx) - minx + 1) + (BLOCK_SIZE - 1)) / BLOCK_SIZE);
|
||||||
BlocksTall = int(((double(maxy) - miny + 1) + (BLOCK_SIZE - 1)) / BLOCK_SIZE);
|
BlocksTall = int(((double(maxy) - miny + 1) + (BLOCK_SIZE - 1)) / BLOCK_SIZE);
|
||||||
MaxX = MinX + BlocksWide * BLOCK_SIZE - 1;
|
MaxX = MinX + fixed64_t(BlocksWide) * BLOCK_SIZE - 1;
|
||||||
MaxY = MinY + BlocksTall * BLOCK_SIZE - 1;
|
MaxY = MinY + fixed64_t(BlocksTall) * BLOCK_SIZE - 1;
|
||||||
VertexGrid = new TArray<int>[BlocksWide * BlocksTall];
|
VertexGrid = new TArray<int>[BlocksWide * BlocksTall];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,10 +703,10 @@ int FNodeBuilder::FVertexMap::InsertVertex (FNodeBuilder::FPrivVert &vert)
|
||||||
// If a vertex is near a block boundary, then it will be inserted on
|
// If a vertex is near a block boundary, then it will be inserted on
|
||||||
// both sides of the boundary so that SelectVertexClose can find
|
// both sides of the boundary so that SelectVertexClose can find
|
||||||
// it by checking in only one block.
|
// it by checking in only one block.
|
||||||
fixed_t minx = MAX (MinX, vert.x - VERTEX_EPSILON);
|
fixed64_t minx = MAX (MinX, fixed64_t(vert.x) - VERTEX_EPSILON);
|
||||||
fixed_t maxx = MIN (MaxX, vert.x + VERTEX_EPSILON);
|
fixed64_t maxx = MIN (MaxX, fixed64_t(vert.x) + VERTEX_EPSILON);
|
||||||
fixed_t miny = MAX (MinY, vert.y - VERTEX_EPSILON);
|
fixed64_t miny = MAX (MinY, fixed64_t(vert.y) - VERTEX_EPSILON);
|
||||||
fixed_t maxy = MIN (MaxY, vert.y + VERTEX_EPSILON);
|
fixed64_t maxy = MIN (MaxY, fixed64_t(vert.y) + VERTEX_EPSILON);
|
||||||
|
|
||||||
int blk[4] =
|
int blk[4] =
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue