# Efficient dynamic world

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

## 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 on other sites
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 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.

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633768
• Total Posts
3013741
×