- ClassifyLine now chooses either SSE2 or regular x87 math depending on whether
or not SSE2 is available at runtime. Since most of the time is spent in ClassifyLine, using SSE2 in just this one function helps the most. - Nodebuilding is a little faster if we inline PointOnSide. - Changed FEventTree into a regular binary tree, since there just aren't enough nodes inserted into it to make a red-black tree worthwhile. - Added more checks at the start of ClassifyLine so that it has a better chance of avoiding the more complicated checking, and it seems to have paid off with a reasonably modest performance boost. - Added a "vertex map" for ZDBSP's vertex selection. (Think BLOCKMAP for vertices instead of lines.) On large maps, this can result in a very significant speed up. (In one particular map, ZDBSP had previously spent 40% of its time just scanning through all the vertices in the map. Now the time it spends finding vertices is immeasurable.) On small maps, this won't make much of a difference, because the number of vertices to search was so small to begin with. SVN r173 (trunk)
This commit is contained in:
parent
6975103dd9
commit
7a601515df
13 changed files with 604 additions and 369 deletions
|
|
@ -45,7 +45,6 @@ FEventTree::FEventTree ()
|
|||
: Root (&Nil), Spare (NULL)
|
||||
{
|
||||
memset (&Nil, 0, sizeof(Nil));
|
||||
Nil.Color = FEvent::BLACK;
|
||||
}
|
||||
|
||||
FEventTree::~FEventTree ()
|
||||
|
|
@ -79,56 +78,6 @@ void FEventTree::DeletionTraverser (FEvent *node)
|
|||
}
|
||||
}
|
||||
|
||||
void FEventTree::LeftRotate (FEvent *x)
|
||||
{
|
||||
FEvent *y = x->Right;
|
||||
x->Right = y->Left;
|
||||
if (y->Left != &Nil)
|
||||
{
|
||||
y->Left->Parent = x;
|
||||
}
|
||||
y->Parent = x->Parent;
|
||||
if (x->Parent == &Nil)
|
||||
{
|
||||
Root = y;
|
||||
}
|
||||
else if (x == x->Parent->Left)
|
||||
{
|
||||
x->Parent->Left = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x->Parent->Right = y;
|
||||
}
|
||||
y->Left = x;
|
||||
x->Parent = y;
|
||||
}
|
||||
|
||||
void FEventTree::RightRotate (FEvent *x)
|
||||
{
|
||||
FEvent *y = x->Left;
|
||||
x->Left = y->Right;
|
||||
if (y->Right != &Nil)
|
||||
{
|
||||
y->Right->Parent = x;
|
||||
}
|
||||
y->Parent = x->Parent;
|
||||
if (x->Parent == &Nil)
|
||||
{
|
||||
Root = y;
|
||||
}
|
||||
else if (x == x->Parent->Left)
|
||||
{
|
||||
x->Parent->Left = y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x->Parent->Right = y;
|
||||
}
|
||||
y->Right = x;
|
||||
x->Parent = y;
|
||||
}
|
||||
|
||||
FEvent *FEventTree::GetNewNode ()
|
||||
{
|
||||
FEvent *node;
|
||||
|
|
@ -177,174 +126,6 @@ void FEventTree::Insert (FEvent *z)
|
|||
}
|
||||
z->Left = &Nil;
|
||||
z->Right = &Nil;
|
||||
|
||||
z->Color = FEvent::RED;
|
||||
while (z != Root && z->Parent->Color == FEvent::RED)
|
||||
{
|
||||
if (z->Parent == z->Parent->Parent->Left)
|
||||
{
|
||||
y = z->Parent->Parent->Right;
|
||||
if (y->Color == FEvent::RED)
|
||||
{
|
||||
z->Parent->Color = FEvent::BLACK;
|
||||
y->Color = FEvent::BLACK;
|
||||
z->Parent->Parent->Color = FEvent::RED;
|
||||
z = z->Parent->Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (z == z->Parent->Right)
|
||||
{
|
||||
z = z->Parent;
|
||||
LeftRotate (z);
|
||||
}
|
||||
z->Parent->Color = FEvent::BLACK;
|
||||
z->Parent->Parent->Color = FEvent::RED;
|
||||
RightRotate (z->Parent->Parent);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
y = z->Parent->Parent->Left;
|
||||
if (y->Color == FEvent::RED)
|
||||
{
|
||||
z->Parent->Color = FEvent::BLACK;
|
||||
y->Color = FEvent::BLACK;
|
||||
z->Parent->Parent->Color = FEvent::RED;
|
||||
z = z->Parent->Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (z == z->Parent->Left)
|
||||
{
|
||||
z = z->Parent;
|
||||
RightRotate (z);
|
||||
}
|
||||
z->Parent->Color = FEvent::BLACK;
|
||||
z->Parent->Parent->Color = FEvent::RED;
|
||||
LeftRotate (z->Parent->Parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
Root->Color = FEvent::BLACK;
|
||||
}
|
||||
|
||||
void FEventTree::Delete (FEvent *z)
|
||||
{
|
||||
FEvent *x, *y;
|
||||
|
||||
if (z->Left == &Nil || z->Right == &Nil)
|
||||
{
|
||||
y = z;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = Successor (z);
|
||||
}
|
||||
if (y->Left != &Nil)
|
||||
{
|
||||
x = y->Left;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = y->Right;
|
||||
}
|
||||
x->Parent = y->Parent;
|
||||
if (y->Parent == &Nil)
|
||||
{
|
||||
Root = x;
|
||||
}
|
||||
else if (y == y->Parent->Left)
|
||||
{
|
||||
y->Parent->Left = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
y->Parent->Right = x;
|
||||
}
|
||||
if (y != z)
|
||||
{
|
||||
z->Distance = y->Distance;
|
||||
z->Info = y->Info;
|
||||
}
|
||||
if (y->Color == FEvent::BLACK)
|
||||
{
|
||||
DeleteFixUp (x);
|
||||
}
|
||||
|
||||
y->Left = Spare;
|
||||
Spare = y;
|
||||
}
|
||||
|
||||
void FEventTree::DeleteFixUp (FEvent *x)
|
||||
{
|
||||
FEvent *w;
|
||||
|
||||
while (x != Root && x->Color == FEvent::BLACK)
|
||||
{
|
||||
if (x == x->Parent->Left)
|
||||
{
|
||||
w = x->Parent->Right;
|
||||
if (w->Color == FEvent::RED)
|
||||
{
|
||||
w->Color = FEvent::BLACK;
|
||||
x->Parent->Color = FEvent::RED;
|
||||
LeftRotate (x->Parent);
|
||||
w = x->Parent->Right;
|
||||
}
|
||||
if (w->Left->Color == FEvent::BLACK && w->Right->Color == FEvent::BLACK)
|
||||
{
|
||||
w->Color = FEvent::RED;
|
||||
x = x->Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w->Right->Color == FEvent::BLACK)
|
||||
{
|
||||
w->Left->Color = FEvent::BLACK;
|
||||
w->Color = FEvent::RED;
|
||||
RightRotate (w);
|
||||
w = x->Parent->Right;
|
||||
}
|
||||
w->Color = x->Parent->Color;
|
||||
x->Parent->Color = FEvent::BLACK;
|
||||
w->Right->Color = FEvent::BLACK;
|
||||
LeftRotate (x->Parent);
|
||||
x = Root;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
w = x->Parent->Left;
|
||||
if (w->Color == FEvent::RED)
|
||||
{
|
||||
w->Color = FEvent::BLACK;
|
||||
x->Parent->Color = FEvent::RED;
|
||||
RightRotate (x->Parent);
|
||||
w = x->Parent->Left;
|
||||
}
|
||||
if (w->Right->Color == FEvent::BLACK && w->Left->Color == FEvent::BLACK)
|
||||
{
|
||||
w->Color = FEvent::RED;
|
||||
x = x->Parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (w->Left->Color == FEvent::BLACK)
|
||||
{
|
||||
w->Right->Color = FEvent::BLACK;
|
||||
w->Color = FEvent::RED;
|
||||
LeftRotate (w);
|
||||
w = x->Parent->Left;
|
||||
}
|
||||
w->Color = x->Parent->Color;
|
||||
x->Parent->Color = FEvent::BLACK;
|
||||
w->Left->Color = FEvent::BLACK;
|
||||
RightRotate (x->Parent);
|
||||
x = Root;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FEvent *FEventTree::Successor (FEvent *event) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue