11

There is no such thing as a "game with DOD". Firstable, that buzz-word is a bit fuzzy, because each system is designed data-oriented. Each program works on a set of data and makes certain transformations to it. Impossible to do that without orienting the design towards the data. So it's not mutually exclusive with "normal" design, but adds constraints in ...


10

What's an object? What we call an object or an entity depending on the model is, fundamentally, made of two parts: data, and behaviour. Game objects have properties and do things. Let's take a simple, free-falling ball as an example. A ball's data is: Its current position Its current speed Our ball can do a single thing: fall. When a ball falls, it does ...


9

Most entity systems don't use Data Oriented Design. Note that entity system doesn't necessarily imply DOD, it just means splitting gameplay functionality into different component classes giving entities certain features and behavior. You can (very easily) create a bloated and horribly slow Object-Oriented version of an entity system. So entity systems are ...


5

I was considering voting to close this question as opinion-based, but I think there are a couple of misunderstandings about Entity-Component Systems and Data-Oriented Design here that are worth addressing. ECS is just a tool Like any programming pattern or principle, it exists to help you write good software. It is not an unbreakable law of physics or a ...


5

Do the simplest thing that works, especially early on. If you've ever seen videos of triple-A titles in alpha, you'll know how slow / buggy they are. This is normal; in fact, it's desirable. And it's often because they used the naive solution to problems. Agile development philosophy states Refactor Mercilessly; I couldn't agree more, from experience. ...


4

It's typical than an Entity System will duplicate some data. Some solutions I've seen is that the Position component contains a transform representing the world position & orientation of the entity. The renderable component has a reference to the position component, as does the physics component. In other designs, the renderable system and physics ...


4

Processing data in arrays is not component based or data driven design. Component based design is about aggregation and dynamic composition. Much of the hype about component performance in the indie community is extremely ill-advised. I've seen great complex 3D games written from scratch in C++ with a fairly naive memory allocator and component ...


3

feels like I'm violating the ECS rule There is no ECS police that will come and put you in ECS Jail. This is your architecture, you set it up how it fits your needs. having any functionality in components. I don't see any functionality in what you suggest. I only see data. At their core, all of those are effectively shapes and will have to be treated ...


3

What you should optimize for is probably best shown in and around slide 40 of this presentation: http://www.slideshare.net/cellperformance/gdc15-code-clinic The idea is to prevent the code from doing wasteful things with the CPU. Loading memory and then throwing it away is rather wasteful. So, naturally, you can reorder data to make better use of it. If you ...


2

It's not that object oriented paradigms are bad for game development, they do the job just fine. Though, there are downsides to doing everything with a typical OOP mindset. 1) Inflexible, you can't reassemble behaviors and properties of your game objects on runtime as they are tied to fixed class hierarchies. 2) Slower unless you mix OOP with data ...


2

ArcaneEngineer's advice is good, particularly for early development (to an extent - once you configure your engine to work a particular way, it can be significantly hard to rework it later). For best performance, look into slot maps (also known as slot arrays, packed arrays) and colony. A slot map has the advantage of already having the map (id) ...


2

TL;DR Use metrics to find what's a performance problem, don't just guess what it is. TL As you're accessing it via a web interface, the datastore at the back end is irrelevant. The performance considerations for you concern the transport of the data to your client and then the parsing of the data into workable data structures (i.e. C# classes). If you ...


1

When you have pure tile-based yes-or-no walkability, then there are a lot of optimizations you can do because: Tiles never move Tiles always have the same size Tiles are always found at coordinates which are multiples of the tile size Your collision system doesn't need to check every tile for collisions with entities, because tiles won't move and won't ...


1

Should I use pointer to Tile or (x,y) coordinates for Unit class? When looking up the tile of a coordinate-pair is cheap (which it usually is if your map is an array of tiles with array indexes mapping to coordinates), then it does not make much of a difference if you get the tile from the coordinates or the coordinates from the tile. So the unit knowing ...


1

The way I approached this was to use a constexpr string-hash which I apply to my components at compile-time to assign each of them a unique id. I essentially do this with the use of a macro where I provide a generated UUID string that gets hashed and a name to my macro. Under the hood, this macro adds some static methods allowing me to fetch the the ...


1

It's great that you have taken the time to think about a couple of ways to accomplish this. Unfortunately, there is no way to tell what's the best approach before you try it with actual data in an actual game. Guessing where the bottlenecks are and trying to optimize that in advance may lead to work done in vain. I spent two weeks rehashing the ...


1

It's difficult to say which way is best, since we don't know how prone your setup is to cache misses without this. I think I remember Jonathan Blow describing doing this type of sort-before-update on one of his developer streams, as a way to improve performance late in a project, so there certainly could be cases where it's beneficial. Without profiling ...


1

Ordering the data is going to depend on existing data access patterns for your application. Profile first, and see what areas of execution are taking the longest as a result of cache misses. Once you've done that, interleaved data (array of structs) will almost certainly be better than splitting into massive arrays of a single element type. How you ...


1

I would not necessarily mimic in the component system the necessary data structures your logic systems require to function. There is an advantage to keeping the component system straight forward and simple and using a layer of indirection here. As an example, when the level is loaded, an entity is created that contains a Transform and a Mesh component. ...


1

It's my ComponentContainer code: #pragma once #include <cassert> #include <vector> #include <unordered_map> #include "tool/config.h" #include "component.h" struct ComponentContainerData { ComponentType type; size_t sizeOfComponent; size_t capacity; size_t freeIndex; }; template<typename ComponentClass> struct ...


1

entity.addComponent<Position>(32, 4, 5); Is definitely possible using C++11 variadic templates, with no performance difference from the original versions. struct Entity { std::vector<std::unique_ptr<Component>> components; template<typename T, typename... TArgs> T& createComponent(TArgs&&... mArgs) { ...


Only top voted, non community-wiki answers of a minimum length are eligible