Nice, but if you're serious about this I suggest looking up oct_trees or a similar proven method.(I'm assuming you havn't.)
Just to show how simple this makes the actual rendering, here's a recurvise oct_tree function, that can cull whole chunks of geo with simple frustum collision checking.
Just to show how simple this makes the actual rendering, here's a recurvise oct_tree function, that can cull whole chunks of geo with simple frustum collision checking.
Function oct_renderNode(node.octNode,checkBounds=True) box.bound=node\box seen=False size#=box\w/2 checkbounds=False If checkBounds Select CubeFrustumState(box\x+box\w/2,box\y+box\h/2,box\z+box\d/2,box\size/2) Case 0 Return Case 2 For j=0 To nodes-1 oct_renderNode(node\child[j],0) Next Case 1 For j=0 To nodes-1 oct_renderNode(node\child[j],True) Next End Select If node\nodes=0 For j=0 To node\srfc-1 setUpScene(node\srf[j]\ent,node\srf[j]\srf) setupSurfacesWithTris(node\srf[j]\srf,node\srf[j]\ent,node\srf[j]\ctris[0],node\srf[j]\triBuf[0]) glDrawElements2(GL_TRIANGLES,(BankSize(node\srf[j]\ctris[0])/12)*3,GL_UNSIGNED_INT,0) rends=rends+BankSize(node\srf[j]\ctris[0])/12 Next EndIf Else If node\nodes=0 If CubeFrustumState(box\x+box\w/2,box\y+box\h/2,box\z+box\d/2,box\size/2) For j=0 To node\srfc-1 setUpScene(node\srf[j]\ent,node\srf[j]\srf) setupSurfacesWithTris(node\srf[j]\srf,node\srf[j]\ent,node\srf[j]\ctris[0],node\srf[j]\triBuf[0]) glDrawElements2(GL_TRIANGLES,(BankSize(node\srf[j]\ctris[0])/12)*3,GL_UNSIGNED_INT,0) rends=rends+BankSize(node\srf[j]\ctris[0])/12 Next EndIf Else For j=0 To nodes-1 oct_renderNode(node\child[j],False) Next EndIf EndIf End Function