- Merged in recent ZDBSP fixes:

- Added code to explicitly handle outputting overlapping segs when
   building GL nodes with ZDBSP, removing the check that discarded
   them early on.
 - AddIntersection() should convert to doubles before subtracting the vertex
   from the node, not after, to avoid integer overflow. (See cah.wad, MAP12
   and MAP13.) A simpler dot product will also suffice for distance calculation.
 - Splitters that come too close to a vertex should be avoided. (See cata.wad.)
 - Red-Black Tree implementation was broken and colored every node red.
 - Moved most of the code for outputting degenerate GL subsectors into another
   function.


SVN r160 (trunk)
This commit is contained in:
Randy Heit 2006-06-01 01:43:16 +00:00
commit 4325fb8993
7 changed files with 202 additions and 280 deletions

View file

@ -37,12 +37,15 @@
**
*/
#include <string.h>
#include "doomtype.h"
#include "nodebuild.h"
FEventTree::FEventTree ()
: Root (&Nil), Spare (NULL)
{
memset (&Nil, 0, sizeof(Nil));
Nil.Color = FEvent::BLACK;
}
FEventTree::~FEventTree ()
@ -85,7 +88,7 @@ void FEventTree::LeftRotate (FEvent *x)
y->Left->Parent = x;
}
y->Parent = x->Parent;
if (x->Parent != &Nil)
if (x->Parent == &Nil)
{
Root = y;
}
@ -110,7 +113,7 @@ void FEventTree::RightRotate (FEvent *x)
y->Right->Parent = x;
}
y->Parent = x->Parent;
if (x->Parent != &Nil)
if (x->Parent == &Nil)
{
Root = y;
}
@ -176,7 +179,7 @@ void FEventTree::Insert (FEvent *z)
z->Right = &Nil;
z->Color = FEvent::RED;
while (z != Root && z->Parent->Color != FEvent::RED)
while (z != Root && z->Parent->Color == FEvent::RED)
{
if (z->Parent == z->Parent->Parent->Left)
{
@ -219,10 +222,11 @@ void FEventTree::Insert (FEvent *z)
}
z->Parent->Color = FEvent::BLACK;
z->Parent->Parent->Color = FEvent::RED;
RightRotate (z->Parent->Parent);
LeftRotate (z->Parent->Parent);
}
}
}
Root->Color = FEvent::BLACK;
}
void FEventTree::Delete (FEvent *z)