views:

48

answers:

1

There has been one more question on what data-oriented design is, and there's one article which is often referred to (and I've read it like 5 or 6 times already). I understand the general concept of this, especially when dealing with, for example, 3d models, where you'd like to keep all vertexes together, and not pollute your faces with normals, etc.

However, I do have a hard time visualizing how data-oriented design might work for anything but the most trivial cases (3d models, particles, BSP-trees, and so on). Are there any good examples out there which really embraces data-oriented design and shows how this might work in practice? I can plow through large code-bases if needed.

What I'm especially interested in is the mantra "where there's one there are many", which I can't really seem to connect with the rest here. Yes, there are always more than one enemy, yet, you still need to update each enemy individually, cause they're not moving the same way now are they? Same goes for the 'balls'-example in the accepted answer to the question above (I actually asked this in a comment to that answer, but haven't gotten a reply yet). Is it simply that the rendering will only need the positions, and not the velocities, whereas the game simulation will need both, but not the materials? Or am I missing something? Perhaps I've already understood it and it's a far more straightforward concept than I thought.

Any pointers would be much appreciated!

+1  A: 

I read the question you linked to and the article.

I've read one book on the subject of data driven design.

I'm pretty much in the same boat as you.

The way I understand Noel's article is that you design your game in the typical object oriented way. You have classes and methods that work on the classes.

After you've done your design, you ask yourself the following question:

How can I arrange all of the data I've designed in one huge blob?

Think of it in terms of writing your entire design as one functional method, with lots of subordinate methods. It reminds me of the massive 500,000 line Cobol programs of my youth.

Now, you probably won't write the entire game as one huge functional method. Really, in the article, Noel is talking about the rendering portion of a game. Think of it as a game engine (the one huge functional method) and the code to drive the game engine (the OOP code).

What I'm especially interested in is the mantra "where there's one there are many", which I can't really seem to connect with the rest here. Yes, there are always more than one enemy, yet, you still need to update each enemy individually, cause they're not moving the same way now are they?

You're thinking in terms of objects. Try thinking in terms of functionality.

Each enemy update is an iteration of a loop.

What's important is that the enemy data is structured to be in one memory location, rather than spread across enemy object instantiations.

Gilbert Le Blanc
It's funny how asking a question on the subject kind of makes it clearer, eh? Thank you for your answer. With regards to the "You're thinking in term of objects", I see we've reached the same conclusion here (see further down in my question, just rephrase it to use enemy position, and so on), where the important point is that the function should only be concerned with the data it needs, like enemy position, orientation, and other information relevant to the game update, whereas it won't need (for example) rendering specifics such as object model, materials, animation sequence, bones, etc. +1
roe
@roe: You can either put just the rendering data in the rendering engine, or you can put all of the data in the rendering engine. The function can reference the data in the rendering engine. It depends on how much data your game needs.
Gilbert Le Blanc