Octree space partitioning bug

Started by
8 comments, last by extralongpants 18 years, 11 months ago
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!
Advertisement
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?
--Riley
not an OpenGL problem, shoved over to Game Programming
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...
-Scoot
Only a part of the node in which the missing polys are, is visible
What do you mean by loose octrees?


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).
-Scoot
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[A]*(center.x-w)+cPlanes*(center.y+w)+cPlanes[C]*(center.z-w)+cPlanes[D]>0)continue;	//LEFT BACK TOP  corner	if(cPlanes[A]*(center.x-w)+cPlanes*(center.y+w)+cPlanes[C]*(center.z+w)+cPlanes[D]>0)continue;	//RIGHT BACK TOP corner	if(cPlanes[A]*(center.x+w)+cPlanes*(center.y+w)+cPlanes[C]*(center.z+w)+cPlanes[D]>0)continue;	//RIGHT FRONT TOP corner	if(cPlanes[A]*(center.x+w)+cPlanes*(center.y+w)+cPlanes[C]*(center.z-w)+cPlanes[D]>0)continue;    			//LEFT FRONT BOTTOM corner    if(cPlanes[A]*(center.x-w)+cPlanes*(center.y-w)+cPlanes[C]*(center.z-w)+cPlanes[D]>0)continue;    //LEFT BACK BOTTOM corner	if(cPlanes[A]*(center.x-w)+cPlanes*(center.y-w)+cPlanes[C]*(center.z+w)+cPlanes[D]>0)continue;	//RIGHT BACK BOTTOM corner	if(cPlanes[A]*(center.x+w)+cPlanes*(center.y-w)+cPlanes[C]*(center.z+w)+cPlanes[D]>0)continue;    //RIGHT FRONT BOTTOM corner	if(cPlanes[A]*(center.x+w)+cPlanes*(center.y-w)+cPlanes[C]*(center.z-w)+cPlanes[D]>0)continue;    return false;}return true;
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?
-Scoot
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.
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]

This topic is closed to new replies.

Advertisement