public static void UnsafeReleaseGatheredEntities(ref EntityQuery query, ref EntityQuery.GatherEntitiesResult result) => query.ReleaseGatheredEntities(ref result);
public static void GatherEntitiesToArray(EntityQueryData *queryData, ref EntityQueryFilter filter, out EntityQuery.GatherEntitiesResult result) { if (s_EntityQueryResultBuffer == null) { s_EntityQueryResultBuffer = (Entity *)UnsafeUtility.Malloc(k_EntityQueryResultBufferSize * sizeof(Entity), 64, Allocator.Persistent); } var buffer = s_EntityQueryResultBuffer; var curOffset = currentOffsetInResultBuffer; // Main method that copies the entities of each chunk of a matching archetype to the buffer bool AddArchetype(MatchingArchetype *matchingArchetype, ref EntityQueryFilter queryFilter) { var archetype = matchingArchetype->Archetype; var entityCountInArchetype = archetype->EntityCount; if (entityCountInArchetype == 0) { return(true); } var chunkCount = archetype->Chunks.Count; var chunks = archetype->Chunks.p; var counts = archetype->Chunks.GetChunkEntityCountArray(); for (int i = 0; i < chunkCount; ++i) { // Ignore the chunk if the query uses filter and the chunk doesn't comply if (queryFilter.RequiresMatchesFilter && (chunks[i]->MatchesFilter(matchingArchetype, ref queryFilter) == false)) { continue; } var entityCountInChunk = counts[i]; if ((curOffset + entityCountInChunk) > k_EntityQueryResultBufferSize) { return(false); } UnsafeUtility.MemCpy(buffer + curOffset, chunks[i]->Buffer, entityCountInChunk * sizeof(Entity)); curOffset += entityCountInChunk; } return(true); } // Parse all the matching archetypes and add the entities that fits the query and its filter bool success = true; ref var matchingArchetypes = ref queryData->MatchingArchetypes;
public static void UnsafeCreateGatherEntitiesResult(ref EntityQuery query, out EntityQuery.GatherEntitiesResult result) => query.GatherEntitiesToArray(out result);