I have a 2D engine that uses XNA 4.0. I have an issue with handling many objects.
In my engine, I only draw visible sprites, and ignore sprites outside of the current viewport. It works, so far. I also use a
RenderTarget to minimize the amount of sprite batch being called, to draw the base.
I also need to draw buildable objects, and the worst case is that there is a list with 10,000 - 20,000 objects. I need to iterate through them, to find the visible buildable objects, as well. This really affects my frame rate, especially when the viewport changes.
I could decrease the zoom level, to minimize the amount of base tiles, but the list of objects keeps the same. Using smaller texture sizes could help, but then I´m also losing detail.
How could I improve the performance?