Background
Let’s say I have millions of interconnected Node instances which together form a graph. Each Node has a 2D position. A user has to be able to pan through a procedural render of this graph. Each Node has a draw method, but if I draw all Nodes every frame, it’s very slow.
As the user does not usually want to see the whole graph but instead is zoomed in, the optimisation is in not drawing the Nodes that are off screen.
My approach
Divide the 2D world space into rectangular Segments. Assign each Node to whatever Segment they’re in. When drawing, find out first which set of Segments the user’s view intersects with and draw only the Nodes in those Segments.
Now for my actual question:
How do I determine the optimal size of a Segment? (Make it too big and it’s the same thing as drawing everything. Make it too small and there are again too many to iterate through.)
I think Quad trees may be more helpful here than the division into fixed-size rectangles.