- fixed: The node builder did not check if all segs could be split properly.

Also removed some fudging that tried to work around this case but produced
  a broken BSP tree on other maps.



SVN r2071 (trunk)
This commit is contained in:
Christoph Oelckers 2010-01-01 11:00:58 +00:00
commit bf7ed6258b
4 changed files with 94 additions and 7 deletions

View file

@ -114,6 +114,17 @@ int FNodeBuilder::CreateNode (DWORD set, fixed_t bbox[4])
DWORD set1, set2;
SplitSegs (set, node, splitseg, set1, set2);
// Check if the set could be split. It may happen that all segs end up on the same side
// in which case we need to create a subsector from such a set.
if (set1 == DWORD_MAX)
{
return 0x80000000 | CreateSubsector (set2, bbox);
}
else if (set2 == DWORD_MAX)
{
return 0x80000000 | CreateSubsector (set1, bbox);
}
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));
@ -490,7 +501,9 @@ int FNodeBuilder::SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int
int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit)
{
int score = 0;
int score = 1000000; // a high base so that segs that come too close to a splitter
// still can be weighed extremely negatively but preventing
// them from creating a negative score.
int segsInSet = 0;
int counts[2] = { 0, 0 };
int realSegs[2] = { 0, 0 };
@ -767,6 +780,27 @@ void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &ou
newvert.y += fixed_t(frac * double(Vertices[seg->v2].y - newvert.y));
vertnum = VertexMap->SelectVertexClose (newvert);
if (vertnum == seg->v1 || vertnum == seg->v2)
{
// Check if the resulting split vertex matches one of the line's ends.
// In this case this seg must not be split
if ((vertnum == seg->v1 && sidev2 == -1) || (vertnum == seg->v2 && sidev1 == -1))
{
side = 0;
sidev1 = 0;
seg->next = outset0;
outset0 = set;
}
else
{
side = 1;
sidev2 = 0;
seg->next = outset1;
outset1 = set;
}
break;
}
seg2 = SplitSeg (set, vertnum, sidev1);
Segs[seg2].next = outset0;
@ -841,7 +875,7 @@ void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &ou
set = next;
}
FixSplitSharers (node);
if (GLNodes)
if (GLNodes && outset0 != DWORD_MAX && outset1 != DWORD_MAX)
{
AddMinisegs (node, splitseg, outset0, outset1);
}