Jump to content
  • Advertisement
Sign in to follow this  
Acef

Efficient dynamic world

This topic is 3252 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

Hi, I'm trying to think of a way to create dynamic world in my game, efficiently. My idea is basically to divide the world into 'sectors' which each contain their own properties. Inside these sectors, would be a simple x, y grid and certain positions inside the grid contains objects (like houses, trees, people, doors). Now what I've come up with to accomplish this is this ugly thing (pieces of the world) Vector of sectors of (a vector of rows (x, y)) ___column vectors(y) of row vectors(x) of (contains objects in that x,y) _______object vectors I'm writing this again just in case its hard to understand: Vector of sectors of column vectors(y) of row vectors(x) of object vectors Now as you can see this seems pretty redundant. Which raises questions such as: How fast would npc create a path to a location in this world? ect It would be very comforting to find another (more simple) method, or perhaps my method is just fine (some reassurance would be nice).

Share this post


Link to post
Share on other sites
Advertisement
It depends on what you want to do "efficiently." Your approach emphasizes data access based on positions in the world. For drawing the world, your setup will certainly help with culling "unseen" sectors. It's also not a bad approach if you want to "pick" things with the mouse pointer, as the mouse position can be converted to world coordinates and objects "under" the mouse located relatively quickly.

Given that "sectors" allow you to cull larger sections of your world quickly, you can also consider eliminating sectors and setting up your world directly as columns and rows of objects. Depends on how big your world is and how much of it needs to be accessed and updated frequently.

If you push pointers rather than structs in your object vectors, you can also use boost smart pointers and not worry about deleting objects, etc.

Your approach may prove just fine.

Share this post


Link to post
Share on other sites
Thank you very much for shedding some light on this. I think (for now) I'm going to use the method above with pointers. However, if anyone knows a link or two to some articles about large scale world management (open ended games). It would be very helpful.

Share this post


Link to post
Share on other sites
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!