bsp tree optimization
Hi guys
I have my bsp tree up and running.
At the moment i have this rendering routine, that renders my bsp tree correctly.
She has 402 nodes, but my problem is that this is extremely slow!
I''m going trouhg all of the nodes, to check if a point is inside the plane of the node.
I read somewhere that if a polygon of the node, is not accepted in this condition, then i can discard the rest of the nodes. Now, how can i do that?
For example, in the first iteraction, if a polygon is on the front plane (CP_FRONT=TRUE), the tree should never go check the back plane, right? How can i do that?
thanks
Bruno
void Render_BSP(NODE *Node,float pos[3])
{
if (Node->IsLeaf==true) return;
result=ClassifyPoint(position,Node->Splitter);
if (result==CP_FRONT)
{
if (Node->Back!=NULL) WalkBspTree(Node->Back,pos);
draw_poly();
if (Node->Front!=NULL) WalkBspTree(Node->Front,pos);
return ;
}
else
{
if (Node->Front!=NULL) WalkBspTree(Node->Front,pos);
if (Node->Back!=NULL) WalkBspTree(Node->Back,pos);
return;
}
return;
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement