2 ms·
> Am I missing something? Yeah. You're missing the part where I said ECS is not just looping. It's clearly also not just sorting, if you know how ECS is struct
by ratww 5y ago
> Am I missing something?
Yeah. You're missing the part where I said ECS is not just looping. It's clearly also not just sorting, if you know how ECS is structured. You need either indexing, like databases, or you need to watch for changes and cache them before usage, like in SQL materialised views. If you want to keep discussing the basics of ECS I strongly suggest searching at least how it is structured, its goals, and how it works.
- jayd16 5y agoPerhaps I should because it seems like you simply listed ways to sort. My understanding is any ECS implementation would always spend the time bookkeeping to prevent O(n^4) or other combinatoric explosion. Systems run every frame while entities are spawned much less often, if at all between load screens. Nested linear searches as you suggest would also blow out any locality improvements, which made the suggestion even more confusing to me. Unity's implementation is deeply focused on keeping component data tightly packed so systems can quickly loop over them with SIMD, or even batch them across other threads. They keep entities sorted in buckets by component list, eg entities with components A, B, and AB are grouped separately (but still as arrays of the underlying component data). They can trivially pass organized sets of arrays to any system that may need them. No linear searching is required as the arrays of separate component data are naturally matched. If a system needs to operate on A and B, the paired arrays are ready made. ...but what do they know?