Sign in to follow this  

Octree space partitioning bug

This topic is 4597 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

Hi ,i just finished putting togather my octree space partitioning library . picture here The problem is that i have a bug and i don't know how to eliminate it .Whenever i move the camera i see some missing polys in the corner of my camera and so i see the polys as they are built. The surface is build from bezier patches as an example for my lib. What could be the problem ? THX!

Share this post


Link to post
Share on other sites
The problem is that your polygons aren't being drawn until after they are in view of the camera, so the problem is going to lie in how you determine if they are in view or not.

Are you sure that you're calculating your viewing frustum properly (your camera is properly synched with your math, your surface are getting drawn where you think they are)? Maybe you check to see if the center of a node is in view instead of if any tiny little part is in view?

Share this post


Link to post
Share on other sites
This sounds like a standard culling issue to me...

Are you using loose octrees? How are you assigning surfaces to tree-nodes? Are the undrawn parts inside a node which is currently visible? Do some testing...

Share this post


Link to post
Share on other sites
Well remember you're not culling against your surfaces, but against the nodes that contain your surfaces, and the parents of those nodes, etc.

If your surface exceeds the bounds of the node containing it (or any parents), then if the node-bound lies outside the frustrum, the surface will be culled (even if it appears to be inside the frustrum) - giving you either the results you are getting (or remarkably similar ones).

Share this post


Link to post
Share on other sites


bool CFrustum::isCubeInView(C3dPoint center, float w)
{




w/=2;//!!!!!!!this shows empty polys w=width of the cube
//!!!!!!!!if i take 'w' instead of w/2 everything seems OK
//


for(int i=0;i<6;i++)
{
//LEFT FRONT TOP corner
if(cPlanes[i][A]*(center.x-w)+cPlanes[i][B]*(center.y+w)+cPlanes[i][C]*(center.z-w)+cPlanes[i][D]>0)continue;
//LEFT BACK TOP corner
if(cPlanes[i][A]*(center.x-w)+cPlanes[i][B]*(center.y+w)+cPlanes[i][C]*(center.z+w)+cPlanes[i][D]>0)continue;
//RIGHT BACK TOP corner
if(cPlanes[i][A]*(center.x+w)+cPlanes[i][B]*(center.y+w)+cPlanes[i][C]*(center.z+w)+cPlanes[i][D]>0)continue;
//RIGHT FRONT TOP corner
if(cPlanes[i][A]*(center.x+w)+cPlanes[i][B]*(center.y+w)+cPlanes[i][C]*(center.z-w)+cPlanes[i][D]>0)continue;



//LEFT FRONT BOTTOM corner
if(cPlanes[i][A]*(center.x-w)+cPlanes[i][B]*(center.y-w)+cPlanes[i][C]*(center.z-w)+cPlanes[i][D]>0)continue;
//LEFT BACK BOTTOM corner
if(cPlanes[i][A]*(center.x-w)+cPlanes[i][B]*(center.y-w)+cPlanes[i][C]*(center.z+w)+cPlanes[i][D]>0)continue;
//RIGHT BACK BOTTOM corner
if(cPlanes[i][A]*(center.x+w)+cPlanes[i][B]*(center.y-w)+cPlanes[i][C]*(center.z+w)+cPlanes[i][D]>0)continue;
//RIGHT FRONT BOTTOM corner
if(cPlanes[i][A]*(center.x+w)+cPlanes[i][B]*(center.y-w)+cPlanes[i][C]*(center.z-w)+cPlanes[i][D]>0)continue;



return false;

}


return true;


Share this post


Link to post
Share on other sites
Well the problem is probably not in your cube/frustrum culling algorithm, but in the method you use to assign surfaces to nodes - are you cutting surfaces along node-edges, or resizing node-bounds to accomodate the new contents correctly?

Share this post


Link to post
Share on other sites
Well it doesn't split the polys ,it assigns the cutted poly to all nodes that have some part of the poly inside. This is because I still don't know how to handle the texture coordinates in case of a cutted poly.

Share this post


Link to post
Share on other sites
Essentially you are assigning triangles to nodes, regardless of whether or not the triangles lie completely inside of them. In your picture, the non-visible triangles belong to a node outside of your viewing frustum. In order to solve this problem, you need to make sure that triangles lie completely within the bounds of your octree nodes, before assigning them.
You don't necessarily have to split the polygons to achieve this (You can impliment a loose octree, for instance [google "loose octree" for more info]).

[Edited by - odiousangel on May 16, 2005 3:23:02 PM]

Share this post


Link to post
Share on other sites

This topic is 4597 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this