/// <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 } } });
/// <summary> /// Do work on the completion of a job /// </summary> /// <param name="job"></param> public virtual void onJobComplete(IAdjustmentJob job) { #if DEBUG lens.decrementRunningJobCount(job.adjustment.resolution); #endif /// dirty jobs don't effect the chain if (job.adjustment.type == FocusAdjustmentType.Dirty) { return; } /// try to pass along the adjustment to the next aperture in line, up the line if it's in focus, down the line if it's out Chunk.Resolution nextResolutionInLine = resolution + (job.adjustment.type == FocusAdjustmentType.InFocus ? 1 : -1); if (lens.tryToGetAperture(nextResolutionInLine, out IChunkResolutionAperture nextApetureInLine)) { #if DEBUG lens.level.getChunk(job.adjustment.chunkID).recordEvent($"Handing adjustment to next apeture in line: {(nextResolutionInLine, job.adjustment.type)}"); #endif if (nextApetureInLine.tryToGetAdjustmentJobHandle( new Adjustment( job.adjustment.chunkID, job.adjustment.type, nextResolutionInLine, job.adjustment.focusID ), out ApetureJobHandle jobHandle )) { jobHandle.schedule(); #if DEBUG lens.incrementRunningJobCount(nextResolutionInLine); #endif } } }