Exemplo n.º 1
0
        /// <summary>
        /// When finished, alert the neighbors too
        /// </summary>
        /// <param name="job"></param>
        public override void onJobComplete(IAdjustmentJob job)
        {
            /// since neighbors may need this chunk to load, check if this one loading makes them ready to mesh:
            /// TODO: check if ForEachDirtiedNeighbor is the right set of neighbors, we may be able to use less
            if (job.adjustment.type == FocusAdjustmentType.InFocus &&
                lens.tryToGetAperture(resolution + 1, out IChunkResolutionAperture nextApetureInLine)
                )
            {
                MarchingTetsMeshGenerator.ForEachDirtiedNeighbor(job.adjustment.chunkID, lens.level, chunk => {
                    if (chunk.currentResolution == Chunk.Resolution.Loaded)
                    {
#if DEBUG
                        lens.level.getChunk(chunk.id).recordEvent($"Attempting to get apeture job for {(Chunk.Resolution.Meshed, job.adjustment.type)} from neighbor");
#endif
                        if (nextApetureInLine.tryToGetAdjustmentJobHandle(
                                new Adjustment(
                                    chunk.id,
                                    job.adjustment.type,
                                    job.adjustment.resolution + 1,
                                    job.adjustment.focusID
                                    ),
                                out ApetureJobHandle jobHandle
                                ))
                        {
                            jobHandle.schedule();
#if DEBUG
                            lens.incrementRunningJobCount(job.adjustment.resolution + 1);
#endif
                        }
                    }
                });
Exemplo n.º 2
0
 /// <summary>
 /// Capture notifications about dirtied chunks
 /// </summary>
 /// <param name="event"></param>
 public void notifyOf(IEvent @event)
 {
     if (@event is Level.ChunkDirtiedEvent cde)
     {
         foreach (ChunkResolutionAperture aperture in apeturesByPriority)
         {
             if (aperture.resolution == Chunk.Resolution.Meshed && aperture.isWithinManagedBounds(cde.chunkID))
             {
                 // throw in jobs to updat the neighbors
                 // TODO: are these the right neighbors?
                 MarchingTetsMeshGenerator.ForEachDirtiedNeighbor(
                     cde.chunkID,
                     level,
                     neighboringChunk => aperture.updateDirtyChunk(neighboringChunk.id, focus)
                     );
                 // then throw in the current chunk, so it's at position 0
                 aperture.updateDirtyChunk(cde.chunkID, focus);
             }
         }
     }
 }