Skip to content

Commit 3a7ebbc

Browse files
committed
refactor(voxel-annotations): rework chunk reloading pipeline -> wait for the entire downsample cascade before reloading chunks, this fixes the disappearing preview at low res.
1 parent 3b7650e commit 3a7ebbc

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/sliceview/volume/frontend.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ export class InMemoryVolumeChunkSource extends VolumeChunkSource {
342342
}
343343
};
344344
// adding a small delay to avoid flickering since the base source will take some time to download the new data
345-
// TODO: it would be better to reload the preview once the base source is good, with big brushes this delay is not sufficient
346345
setTimeout(update, 100);
347346
}
348347

src/voxel_annotation/TODOs.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77

88
### later
99

10-
- should we allow drawing even when there are no writable volume, and in that case inform the user about it and only draw edits in the preview layer? I am not sure about the real use cases tho.
1110
- add preview for the undo/redo
12-
- optimize flood fill tool (it is too slow on area containing uncached chunks, due to the getEnsuredValueAt() calls)
1311
- the flood fill sometimes leaves artifacts in sharp areas (maybe increase fillBorderRegion() radius)
14-
- write a testsuite for the downsampler and ensure its proper working on exotic lod levels
1512

1613
### questionable
1714

15+
- write a testsuite for the downsampler and ensure its proper working on exotic lod levels
1816
- design a dataset creation feature
1917
- adapt the brush size to the zoom level linearly

src/voxel_annotation/edit_backend.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ export class VoxelEditController extends SharedObject {
195195
if (firstErrorMessage === undefined) firstErrorMessage = msg;
196196
}
197197
}
198-
this.callChunkReload(editsByVoxKey.keys().toArray());
199198

200199
if (newAction.changes.size > 0) {
201200
this.undoStack.push(newAction);
@@ -273,7 +272,13 @@ export class VoxelEditController extends SharedObject {
273272
while (this.downsampleQueue.length > 0) {
274273
const key = this.downsampleQueue.shift() as string;
275274
this.downsampleQueueSet.delete(key);
276-
await this.performDownsampleCascadeForKey(key);
275+
const allModifiedKeys = new Array<string>();
276+
let currentKey: string | null = key;
277+
while (currentKey !== null) {
278+
allModifiedKeys.push(currentKey);
279+
currentKey = await this.downsampleStep(currentKey);
280+
}
281+
this.callChunkReload(allModifiedKeys);
277282
}
278283
} finally {
279284
this.isProcessingDownsampleQueue = false;
@@ -287,15 +292,6 @@ export class VoxelEditController extends SharedObject {
287292
}
288293
}
289294

290-
private async performDownsampleCascadeForKey(
291-
sourceKey: string,
292-
): Promise<void> {
293-
let currentKey: string | null = sourceKey;
294-
while (currentKey !== null) {
295-
currentKey = await this.downsampleStep(currentKey);
296-
}
297-
}
298-
299295
/**
300296
* Performs a single downsampling step from a child chunk to its parent.
301297
* @returns The key of the parent chunk that was updated, or null if the cascade should stop.

0 commit comments

Comments
 (0)