EntityIndexInQuery is generally way more expensive than ChunkIndexInQuery and EntityIndexInChunk

As it says in document, what if I use ChunkIndexInQuery and EntityIndexInChunk combined and calculate “EntityIndexInQuery” inside job, is it cheaper than using EntityIndexInQuery directly?

You need chunkBaseEntityIndices in order to calculate the correct EntityIndexInQuery. There’s no other cheaper way that I know of. Generally, it’s fine. Always profile before you judge something as slow or expensive. You will find that it’s already good enough in most cases.

1 Like

You’ll have unused indices this way, because chunks can have a variable number of entities, and worse some of those entities might be filtered out by IEnableableComponent in your query.

1 Like