• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Telanor

Handling large entities on a grid

6 posts in this topic

My world is made up of 'regions' laid out in a grid and I have some entities that could be overlapping several regions at once. I need some way of querying what entity (if any) is at a given world position.

I had thought I could do it with octrees but I can't really see them working. The first issue is that I can't just have 1 octree for the whole world, because I have to deal with multiplayer and having multiple players that could potentially be very very far away from each other. If I instead do 1 octree per region, that leads to more problems: if an entity is in region 1 and 2, and I query a position inside region 2 which the entity overlaps, region 2 won't have an entry for it.

I could possibly duplicate the entries so that both octrees have the same entry and it wouldn't matter which you queried, but then I run into another problem: I can't add entries to a region which isn't loaded yet.

Another solution might be to query all the neighbor regions' octrees if nothing is found within the octree of the original region. That means even more time taken to find an entity and either require that entities be no larger than a single region or I'd have to keep expanding the search outwards. Overall not a terrible solution, but not one I'm particularly happy with.

Anyone else have some better solutions? Whatever structure is used needs to be buildable in realtime, these entities are dynamically placed. Edited by Telanor
0

Share this post


Link to post
Share on other sites
Sure. By grid cells do you mean within a region? or grid cells of regions? In the first case, its 32x32x256, in the second case, unlimited (its an infinite world). Entity numbers are variable. Like I said, the user is placing them down. I'd probably guess there'd typically be less than 100 in a single region, though if they build a massive vertical structure, there could be a lot more. As for how many cells an entity can overlap, I'm not sure, we haven't made all of them yet. It wouldn't likely much of an issue to limit the max size to that of a region (32x32x256), as that's quite large. I'd say on average, probably won't be more than a few dozen for most entities. Edited by Telanor
0

Share this post


Link to post
Share on other sites


I could possibly duplicate the entries so that both octrees have the same entry and it wouldn't matter which you queried, but then I run into another problem: I can't add entries to a region which isn't loaded yet.
I don't think you want to query the octrees of regions that you haven't loaded.

When you load a region, not earlier, you can collect overlapping entities in nearby regions.and add references in the new region.

0

Share this post


Link to post
Share on other sites
You seem to be thinking of the problem inside-out.


Don't build a spatial partitioning structure and then assume that every object will only belong neatly to one subspace. Instead, build a spatial partitioning structure and give each subspace an identifier (or just hold a pointer to it, more efficient). Then, each entity you have maintains a list of which partition subspaces it overlaps. If the entity moves, rebuild the membership list. If the world is mutated sufficiently, rebuild the spatial partitioning structure.

Octrees should be sufficient for this although you might have better results in non-uniform worlds with a kd-tree instead.
0

Share this post


Link to post
Share on other sites
So it's looking like I need to set it up like this:

* When a region loads, load in any saved entities and add them to the octree.
* Query the 8 neighbor regions. For any that are loaded:
- Find any entities in the current region that overlap the neighbor region (loop all entities and do a check?) and add them to the neighbor's octree
- Find any entities in the neighbor region that overlap the current region and add them to current region's octree

That's going to be a lot of looping over all entities. Should I be concerned about this? Is there a better way? I know the answer is probably going to be "test and find out" but I figured I'd ask before I waste time implementing it.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0