# How are these called, and do they work like this?

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

## Recommended Posts

Hey, This is mostly about collision detection, and I'm sure it already exists: the world is divided into cubes, which are subdivided into more cubes, and so fort. Every cube has a boolean that indicates whether something or someone is in that cube. So, when an object is checked for collision, the game first checks the biggest cube he is in. When that is true, the same for the smaller ones, and so forth. Only when the smallest one where the player is in contains an object, real collision detection is done. When an object enters a smallest cube, that cube sets his flag to true, and tells his parent to do the same, and that parent his parent, and so forth. Now, I have two questions: - How is this called? Are these 'octrees'? (Which is the first name I thought of.. sounds logical too, as every part has 8 corners.) - For leaving the 'cube'. Should the 'cubes' keep a lists of contents, or should the system loop trough all objects to see if that cube is free again? Thanks While I described it in 3D, using the idea in 2D, or even 1D or 4D would be possible too, I guess

yes and yes

##### Share on other sites
Quote:
 Original post by krezyes and yes

To the first question, thanks, but to the second one.. which of them? Keep a list per cube (more memory) or loop trough objects (more cpu)?

##### Share on other sites
Well you have to keep track of which objects are in the same cube so you can do collision detection between them, but that information will change each frame as the positions of the objects are updated. So in a sense, you do both, however the list of objects per cube is only valid for that single frame.

##### Share on other sites
Each cube/node keeps it's own contents list. You then compare yourself to any other objects inside of your node(s). You would *not* compare yourself to all other objects in the world. As mentioned, this all requires some overhead of updating everyone's positions and the contents list of each node. But for large numbers of evenly-distributed objects, it can be very timesaving.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633344
• Total Posts
3011438
• ### Who's Online (See full list)

There are no registered users currently online

×