Adding/Removing lots of Nodes at run-time

Nov 9, 2010 at 3:15 AM

I have a game loop where I detect what keys are pressed, and if I detect movement key I move the camera in the corresponding direction. All is working well. My world is quite large, too large to load into a scene at one time. So as the player moves around the world I swap out nodes (geometries) behind them that go ‘out of view’ with nodes coming into view in front. To help deal with large triangles close to the camera I also swap out the ground right near the camera with a higher resolution mesh. In this case that means more faces. The ground far from the camera can use fewer faces. (This is due to clipping of large meshes near the camera)

What I’m seeing is a slight pause when I swap out one lower resolution mesh for the higher. It's very short, but enough to provide a lag every few seconds as I walk around in the world.

While looking at the balder code I noticed that add node and remove node lock on the underlying node list. I assume this happens because Balder uses multiple threads to render and does not want a one thread to be iterating over the list while another adds something to the list.

1) Would it be a good idea to add two more methods AddNodes and RemoveNodes so the lock can happen only once per group of nodes.
2) Is there a more optimal time to be swapping out meshes? Is Update a better place to be doing that or does it not really matter when I add or remove nodes?

 Thanks for any advice.

Nov 10, 2010 at 4:25 PM

Ahh..  That Lock can in fact be removed. Balder is not doing anything multithreaded at the moment, and when I get to it I will change this behavior and use Arrays internally instead. 


Sorry I haven't had time to fix the problem with the clipping yet. The last couple of weeks has been completely crazy with work.