Commit 7d7dfb8
fix(segmentation): undoable overlap labelmap strokes, faster eager stroke resolution, brush hover guard (#2785)
* fix(segmentation): make overlap labelmap strokes fully undoable
A stroke that forces a segment move to a private labelmap layer changed
three things outside its history memo: the bulk voxel move, the layer
registration, and the segment rebinding. Cross-layer overwrite erases were
also unrecorded. Undo then restored only the stroke's own voxels, leaving
the moved voxels stranded on a layer that should not exist at that point
in history.
Labelmap memos now carry ordered restore steps (priorSteps/postSteps):
moveSegmentToPrivateLabelmap emits a step that reverses/replays the whole
move, cross-layer erases are recorded per layer through
crossLayerEraseCallback, and a mid-stroke voxel-manager swap rides the
committed earlier memo along. Undo walks steps in reverse-chronological
order, redo chronologically, so each stroke restores as one unit.
* perf(segmentation): memoize labelmap image reference scans
Every eager (non-lazy) brush or eraser drag event re-ran
isReferenceViewable over ALL labelmap imageIds via
updateLabelmapSegmentationImageReferences, each call doing full metadata
and slice-basis resolution. On a two-layer, 120-image labelmap this cost
about 51ms per drag event (about 19fps while erasing).
The resolver now remembers completed scans per segmentation, keyed by the
viewport's current image plus a fingerprint of the labelmap imageId set,
and replays the stored mapping instead of rescanning. Layer additions or
removals change the fingerprint and force a fresh scan; removeSegmentation
and reset clear the memo. Same scenario now costs about 2ms per event.
* fix(BrushTool): bail out of preMouseDown when hover data cannot be created
preMouseDownCallback dereferenced this._hoverData.viewport without
guarding the case where createHoverData returns undefined (no active
segment index yet, or the viewport camera is not resolvable), crashing
with 'Cannot read properties of undefined (reading viewport)'. Every
other createHoverData call site already guards this; do the same here and
undo the draw activation before bailing.
* fix(tools): cache labelmap scan results by viewport
* test(tools): assert viewport scan replay coverage
---------
Co-authored-by: Bill Wallace <wayfarer3130@gmail.com>1 parent 30f3b60 commit 7d7dfb8
10 files changed
Lines changed: 1016 additions & 20 deletions
File tree
- packages/tools/src
- stateManagement/segmentation/labelmapModel
- tools/segmentation
- strategies
- utils
- utilities/segmentation
Lines changed: 44 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
16 | 25 | | |
17 | 26 | | |
18 | 27 | | |
19 | | - | |
| 28 | + | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| |||
39 | 49 | | |
40 | 50 | | |
41 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
42 | 56 | | |
43 | 57 | | |
44 | 58 | | |
| |||
62 | 76 | | |
63 | 77 | | |
64 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
65 | 82 | | |
66 | 83 | | |
67 | 84 | | |
| |||
197 | 214 | | |
198 | 215 | | |
199 | 216 | | |
| 217 | + | |
| 218 | + | |
200 | 219 | | |
201 | 220 | | |
202 | 221 | | |
203 | 222 | | |
204 | 223 | | |
205 | 224 | | |
206 | | - | |
| 225 | + | |
| 226 | + | |
207 | 227 | | |
208 | 228 | | |
209 | 229 | | |
| |||
234 | 254 | | |
235 | 255 | | |
236 | 256 | | |
| 257 | + | |
237 | 258 | | |
238 | 259 | | |
239 | 260 | | |
| |||
329 | 350 | | |
330 | 351 | | |
331 | 352 | | |
| 353 | + | |
332 | 354 | | |
333 | 355 | | |
334 | 356 | | |
| |||
343 | 365 | | |
344 | 366 | | |
345 | 367 | | |
| 368 | + | |
346 | 369 | | |
347 | 370 | | |
348 | 371 | | |
349 | 372 | | |
350 | 373 | | |
351 | 374 | | |
352 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
353 | 384 | | |
354 | 385 | | |
355 | 386 | | |
| |||
373 | 404 | | |
374 | 405 | | |
375 | 406 | | |
| 407 | + | |
376 | 408 | | |
377 | 409 | | |
378 | 410 | | |
| |||
387 | 419 | | |
388 | 420 | | |
389 | 421 | | |
| 422 | + | |
390 | 423 | | |
391 | 424 | | |
392 | 425 | | |
393 | 426 | | |
394 | 427 | | |
395 | 428 | | |
396 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
397 | 438 | | |
398 | 439 | | |
399 | 440 | | |
| |||
440 | 481 | | |
441 | 482 | | |
442 | 483 | | |
| 484 | + | |
443 | 485 | | |
444 | 486 | | |
445 | 487 | | |
| |||
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
218 | 253 | | |
219 | 254 | | |
220 | 255 | | |
| |||
Lines changed: 87 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
| |||
40 | 51 | | |
41 | 52 | | |
42 | 53 | | |
| 54 | + | |
43 | 55 | | |
44 | 56 | | |
45 | 57 | | |
46 | 58 | | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | 62 | | |
| |||
142 | 155 | | |
143 | 156 | | |
144 | 157 | | |
145 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
146 | 165 | | |
147 | | - | |
| 166 | + | |
148 | 167 | | |
149 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
150 | 223 | | |
151 | 224 | | |
152 | 225 | | |
| |||
382 | 455 | | |
383 | 456 | | |
384 | 457 | | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
385 | 470 | | |
386 | 471 | | |
387 | 472 | | |
| |||
0 commit comments