perf(scene): delta journal so edits touch only changed entities (phase 0-1)
Every geometry mutation previously bumped a monotonic geometry_epoch and each derived cache compared its stamp and, on a miss, re-walked the whole document — so drawing or moving one line rebuilt every hatch / image / mesh / wipeout model even though none of them changed. Add a per-mutation delta journal: bump_entities(&[(Handle, ChangeKind)]) records exactly which handles changed (Added / Removed / Modified), folding the memo drop and the epoch bump into one call a site cannot forget. A bounded ring keeps the recent deltas; replay_since(last_epoch) coalesces the changes past a consumer or returns None (full rebuild) when a spanned delta is `full` or the consumer fell off the ring. bump_geometry / bump_geometry_no_blocks push a `full` delta so the journal is never missing a step. Route the common single-entity ops through it: add (Added), update (Modified), erase (Removed), move/rotate/scale/mirror (Modified), copy (Added). Gate the four per-category model caches on category relevance — an edit whose handles are not in a category leaves that category cache warm; a removal is treated conservatively (the erased handle can no longer be classified), and the mesh cache also invalidates on any INSERT edit since it carries the instanced block meshes. Net: a plain-entity edit no longer rebuilds the hatch/image/mesh/wipeout model sets. The resident wire clone-all and the GPU re-upload are still whole-set — the journal is the groundwork for making those per-entity next. Adds 6 journal unit tests (replay, coalescing, full-fallback, ring overflow, category gate). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
4bcf5063e9
commit
57401f6f32
4 changed files with 365 additions and 32 deletions
|
|
@ -138,7 +138,9 @@ impl Scene {
|
|||
if affects_blocks {
|
||||
self.bump_geometry();
|
||||
} else {
|
||||
self.bump_geometry_no_blocks();
|
||||
// Plain top-level add: name the new handle so every derived cache
|
||||
// patches in just this one entity instead of rebuilding.
|
||||
self.bump_entities(&[(handle, ChangeKind::Added)]);
|
||||
}
|
||||
}
|
||||
handle
|
||||
|
|
@ -259,11 +261,14 @@ impl Scene {
|
|||
self.meshes.insert(handle, model);
|
||||
}
|
||||
|
||||
self.mark_entity_dirty(handle);
|
||||
if affects_blocks {
|
||||
self.mark_entity_dirty(handle);
|
||||
self.bump_geometry();
|
||||
} else {
|
||||
self.bump_geometry_no_blocks();
|
||||
// One entity changed in place: report just this handle so every
|
||||
// derived cache patches it instead of rebuilding (bump_entities also
|
||||
// drops it from the tessellation memos).
|
||||
self.bump_entities(&[(handle, ChangeKind::Modified)]);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue