Jump to content
  • Advertisement
Sign in to follow this  
haphazardlynamed

2d RingQueue data structure, help with index wrapping?

This topic is 5130 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm building a special vertex data cache for a terrain heightfield basically its a 2d ringqueue so, as the player moves north off the terrain, I 'scroll' the ringqueue north, and load new terrain data into the space cleared by the old stuff that got scrolled out does this similarly for all 4 compass directions once issue im getting, is how to safely access the data in this 2d queue ive been using a procedural terrain generating method that requires relatively random access to verticies and it would be very hard to redesign this method to explicitly avoid stepping over cache boundries so I'm considering, that perhaps I should simply do a safety check for every access i make something like safety(y,x){ return cache[(y+size)&(size-1)][(x+size)&(size-1)]; } that basically uses a bitlogic trick to modulus the indecies so they wrap back to the other size of the cache (assming size is a power of 2) so, what do you think? how do other people build 2d ringqueues? can someone suggest a better, cheaper way to make it wrap even with random accesses?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!