Hacker News new | past | comments | ask | show | jobs | submit login

> I can understand the fast lookup, but if I understand correctly, every object in the game is an entity, and every entity is represented in every vector? So if you have a hundred game properties, an object that only utilizes three properties still has to be allocated a hundred times over?

For any properties that are stored in a linear list, yes. Typically, values that are found in almost every object, and values that are small are placed in simple vectors. Values that are more rare and/or large enough to care about can be placed in a different, denser data structure.

> Also I'm not sure how a system is meant to recognize which entities to do its work on, without iterating over the entire associated vector, every frame?

For a lot of things you do in a game, iterating over the entire vector is substantially faster than deciding on what items you need work on. Linear access is really fast, cache misses are slow, and if the work done per entity is low enough, it can legitimately be faster to do it for everything and then just use a conditional move to only store the valid values, instead of eating branch prediction failures when choosing what to work on. Especially as SoA layout makes vectorizing code really easy.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: