• 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
JoshuaWaring

Questions about moving objects and quadtrees

6 posts in this topic

I have a few quesions on quadtree's. I'm implementing it into an asteroids game I'm creating for educational purposes. I know that there is absolutely NO point in doing do, but it's educational ;3 and will help me when I go to produce something more complex :) it just helps me learn, now enough about why.

 

With a quadTree would you need to restructure the quadtree when objects move in and out of the quads for every update? or is there another method which I'm not seeing, because in that case the optimisations would only be highely benifital in situations where the collision detection is a complex calculations. How would some of you guys/girls manage a Quadtree with moving objects?

 

Thank you for any answers :)

0

Share this post


Link to post
Share on other sites

In my implementation, I found that rebuilding the quadtree every cycle worked just fine. That is, rebuilding the entire tree is relatively fast compared to the subsequent collission search logic (it tracks about a thousand or so items). I'm sure I could optimize the quadtree by incremental updates, as the objects move relatively slowly. But the algorithm would get far more complex, so I'm not doing it until I really have to.

2

Share this post


Link to post
Share on other sites

Yeah I guess because it's faster quite a bit, since 10 objects would be 10^2 checks 50 would be 2500 checks D: rebuilding doesn't seem too intensive when you put it in that perspective.

0

Share this post


Link to post
Share on other sites

Yes, rebuilding takes N log N which is far faster than N^2. But what I meant was comparing it with the collission search. Iterating each item and looking for others within a certain radius also takes N log N. So the conclusion is that the incremental version is of the same order compared to the non-incremental one. Making the optimization *can* be worthwhile, but as always, you should measure first.

 

[edit]

 

PS. Making the optimization would actually be an excellent educational excersize. If you do, make sure to measure performance before and after.

Edited by Felix Ungman
0

Share this post


Link to post
Share on other sites

"Loose" octrees as described by Thatcher Ulrich might be something that's interesting for you if you're doing this for educational purposes (note: octree is the same as quadtree, just with one more dimension).

 

But for something that "just works" for reasonable numbers, I agree with Felix Ungman, nothing wrong with just rebuilding the tree, and it's nice and easy.

0

Share this post


Link to post
Share on other sites

Also not ussing a quadtree at all is probably even faster :p. I don't get why everyone instantly jumps to quad trees for broad phase collision detection. Just grids/cell lists are often easier to implement AND perform better. Especially in the asteroids case where the domain is limited.

0

Share this post


Link to post
Share on other sites

Why do you need to rebuild the quadtree ? I mean, it sounds that you are clearing and inserting all the objects when updating?

 

It is perfectly fine to just update the nodes which are affected by the moving objects. 

 

I'm using a loose octree for a 3d world and I have no performance problems with 200-300 moving objects. Of course there are some possibilities for optimizing such as "if object is inside the same octree node as it was before moving, no update is necessary". 

 

Probably for a limited play area game a grid based solution will be easier to implement and it'll perform better. 

 

Cheers!

0

Share this post


Link to post
Share on other sites

In a space partitioning structure, for either collision checking or graphic optimization (or both), you have two kinds of objects, mobile and static.
The proportions of the population will change depending on the game itself, some will have just a few mobile and tons of statics and some may have truckloads of mobiles and just a few statics.

How you update your space partitioning structurte will likely be driven by these characteristics, in games with mostly static content the best approach is to keep the structure stored for the statics and have the mobiles update their position in the structure, if your object knows which node of the structure it is stored in, you could trigger the reevaluation of the object from that node, make a check for containment, if its contained check child nodes, if its intersected by the node boundaries or has no overlapping at al move it up the hierarchy and re check.

If you have more mobile entities than static, a full recalculation may be the best approach, though in these cases, like bullet hell games, entirely different techniques than space partitioning are usually more effective.

If its an entirely learning experience, try to abstract yourself of the quadtree, the octree, the bsp or any specific structure and try to think of a system that would allow you to use any of these and even combine them, what is a space partitioning structure? what do they all have in common? its a node structure with space containing boundaries and a hierarchy where all nodes are fully contained by their parent.
Think of special cases that would still qualify, for instance, this one is assumed invalid by many people not familiar with these structures, the only rule is that the child node is fully contained by the parent, it doesn't say nor there is any reason why it wouldn't be valid, that the child nodes must not overlap each other, which could solve the horribly annoying defect that if an object is on the exact center of a quadtree, it can only be stored on the root node regardless of how small the object may be.

You could for instance, have a quadtree that stores an exterior, open world, in which there is somewhere a large building, the building will have its own space partitioning structure for the objects inside it, this structure can be a sub node of the quadtree node in which the building is located. The inside of the building may best be represented by a graph of rooms and the conent of those rooms may best be repesented by a BSP, which would be a sub node of the graph node for that room.
If you design your classes and system well, this should be entirely possible and efficient.

Edited by NEXUSKill
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