protected override void OnUpdate() { var joinPoints = GetComponentDataFromEntity <LineJoinPoint>(true); var lines = GetComponentDataFromEntity <Line>(true); var knotBuffers = GetBufferFromEntity <LineKnotData>(true); var linesToCheck = mergeCheckQuery.ToEntityArray(Allocator.TempJob); Dependency.Complete(); LineEndSimBufferSystem.Instance .CreateCommandBuffer() .RemoveComponent <MergeCheck>(mergeCheckQuery); Dependency = new LineMergeJob { Lines = lines, LineEntities = linesToCheck, LineJoinPoints = joinPoints, LineProfiles = GetComponentDataFromEntity <LineProfile>(), LineKnotData = knotBuffers, Ecb = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(), DefaultProfile = LineProfile.Default() }.Schedule(linesToCheck.Length, 4, Dependency); // TODO only trigger this when lines are merged Dependency = new LineTriggerMeshRebuildJob { Ecb = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(), Lines = GetComponentDataFromEntity <Line>(true), LineProfiles = GetComponentDataFromEntity <LineProfile>(true), LineEntities = linesToCheck, DefaultPrefab = LineDefaultMeshBuilderSystem.Prefab }.Schedule(linesToCheck.Length, 4, Dependency); Dependency = new LineSetDirtyJob { Ecb = LineEndSimBufferSystem.Instance.CreateCommandBuffer().ToConcurrent(), LineEntities = linesToCheck }.Schedule(linesToCheck.Length, 4, Dependency); Dependency = new DeallocateJob <Entity> { NativeArray1 = linesToCheck }.Schedule(Dependency); LineEndSimBufferSystem.Instance.AddJobHandleForProducer(Dependency); }
/// <inheritdoc /> protected override JobHandle SetComponentData(EntityManager entityManager, NativeArray <Entity> entities) { var componentType = entityManager.GetArchetypeChunkComponentType <T>(false); var chunks = this.query.CreateArchetypeChunkArray(Allocator.TempJob); int startIndex = 0; var handles = new NativeArray <JobHandle>(this.queues.Count, Allocator.TempJob); // Create a job for each queue. This is designed so that these jobs can run simultaneously. for (var index = 0; index < this.queues.Count; index++) { var queue = this.queues[index]; var job = new SetComponentDataJob { Chunks = chunks, Queue = queue, StartIndex = startIndex, ComponentType = componentType, }; startIndex += queue.Count; handles[index] = job.Schedule(); } var handle = JobHandle.CombineDependencies(handles); handles.Dispose(); // Deallocate the chunk array handle = new DeallocateJob <NativeArray <ArchetypeChunk> >(chunks).Schedule(handle); return(handle); }