Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

AngryLlama

Little Quake3 BSP problem

This topic is 5954 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I''ve had a BSP render written in VC++ using OpenGL for some time. Until recently I''ve been just pushing all the faces to the screen, but now I want to use BSP tree and PVS data to cut down on my drawn faces. I have all the structures loaded from the BSP file, and my first function pertaining to leafs and stuff is my FindLeaf() function for determining which leaf the player is in. The problem is, this function doesn''t work, any help would be appreciated. int CBSP::FindLeaf() { node_t *node; plane_t *plane; int idx; float dot; idx = 0; while(idx>=0) { node = &nodes[idx]; plane = &planes[node->plane]; dot = plane->normal[0]*CameraPoint[0] +plane->normal[1]*CameraPoint[1] +plane->normal[2]*CameraPoint[2] -plane->dist; if (dot>=0) idx = node->children[0]; else idx = node->children[1]; } return(-(idx+1)); } The program freezes in this function, and I don''t know why, any help would be much appreciated. ~Paul

Share this post


Link to post
Share on other sites
Advertisement
ok, nevermind, I got that working (without any changes to that code) it appears i was accidently loading the node info incorrectly.

However, I have run into another problem. Now, it seems that I get a LOWER FPS then I did when i just drew all the polygons to the screen. (By lower I mean 90-130fps vs. 20-50fps)

I logged the polys drawn each frame and it varies from 850-3700 and seems to stay around 2400 on a 3728 polygon map!! However, when I look at it on wireframe mode it appears to removing surfaces just fine. So this means there is something in my checking code that is not optimized, and is there any chance of overdraw? I mean, can several leafs reference the same faces??

Thanks! here is my render code in case it helps:

for(x=0; x < n_leafs;x++)
{
if(BSP_TESTVIS(leafs[CameraLeaf].cluster, leafs[x].cluster))
{
n_currleaffaces = leafs[x].n_leaffaces;
for (j=0; j < n_currleaffaces; j++)
{
CurrFace = leaffaces[leafs[x].leafface+j].face;
if (faces[CurrFace].type == 1 && faces[CurrFace].lm_index > -1)
{
Render->PushFace(&faces[CurrFace]);
fdrawn++;
}
}
}
}


Thanks again!
~Llama

Edited by - AngryLlama on February 2, 2002 12:00:41 AM

Share this post


Link to post
Share on other sites
quote:

I mean, can several leafs reference the same faces??


Yes, don't ask me why. Does anyone know why?

It's helpful to render nodes by traversing the BSP. Here's my source for rendering nodes:
    
void Q3AMap::RenderNodes(int i,int accept)
{
Q3ANodes *node = &nodes[i];
{
if(!accept)
{
int clipcode = ClipAgainstCameraVolume(node->bb);
//completely outside veiwing volume

if(!clipcode)
return;
//completely inside viewing volume

if(clipcode == 2)
accept=1;
}

Q3APlanes *qplane = &planes[node->plane];

if(node->children[0] > 0)
RenderNodes(node->children[0],accept);
else
RenderLeafs(-(node->children[0]+1),accept);

if(node->children[1] > 0)
RenderNodes(node->children[1],accept);
else
RenderLeafs(-(node->children[1]+1),accept);
}
}



Mike

"The state is that great fiction by which everyone tries to live at the expense of everyone else." - Frederick Bastiat, The Law

Edited by - Vetinari on February 2, 2002 12:20:03 AM

Share this post


Link to post
Share on other sites
RenderNodes(int i,int accept)... what should my initial i and accept be?

~Llama.

By the way, I got my code working by marking a face as rendered or not, so it doesn't redraw at all. And no, I'm not on crack.

Edited by - AngryLlama on February 3, 2002 1:43:50 AM

Share this post


Link to post
Share on other sites
Sorry, accept is a code that notifies if that whole node (and therefore all the nodes underneath) is completely within the viewing volume or not.

accept == 0 - partially inside view volume
accpet == 1 - completely inside view volume

When a node is completely inside a view volume, you no longer have to test for culling against the view volume for any nodes underneath it.

RenderNodes starts at the top node...


Mike

"The state is that great fiction by which everyone tries to live at the expense of everyone else." - Frederick Bastiat, The Law

Share this post


Link to post
Share on other sites
Of course do several leafs "reference" the same faces.

Take a piece of paper, draw some lines (10..15) of
different length and angles onto it.
Imagine those lines were actually wall-polygons, viewed from
above.

Start to build a 2D bsp-tree from that polygons, on paper.
(cool, a human bsp-tree compiler

The leafs of your bsp-tree are nothing else than the
bounded subspaces without any further polygons within them,
which have been created by your subdividing.

Of course several leafs can have the same polygon's planes
as their bounds.

Well, if it's not easy to imagine for you,
just do what I suggested, and draw it in 2D on paper.
Then you'll surely see what I'm talking about.


the unshaven bastard




Edited by - UnshavenBastard on February 4, 2002 7:01:00 PM

Share this post


Link to post
Share on other sites
quote:
Original post by AngryLlama
so you dont even check which leaf the camera is in??


Yeah, but that''s only used for rendering leafs. I was just suggesting an alternative to your for loop. I''m going to open my engine one of these days, but until then you can check out aftershocks rendering loop.


Mike

"The state is that great fiction by which everyone tries to live at the expense of everyone else." - Frederick Bastiat, The Law

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!