Stage 5: content-hash AssetStore; undo records asset keys, not pixels

- resource::AssetStore (core) keeps immutable images and sounds keyed by content
  hash for the life of the document; nothing is purged until it closes.
- Undo state holds spritesheet/sound id -> asset key maps (always tracked), so
  every edit can undo texture changes; the textures-only snapshot flag
  (edit_begin(label, true) / push(message, isTextures)) and the pixel/audio
  equality helpers are gone.
- Document::texture_get/sound_get read through the store; texture_set/sound_set
  add assets; texture_edit gives the pencil a private draft that becomes a new
  asset on the next change().
- Spritesheet dirty state compares path + asset key instead of hashing pixels.
- Preview audio reads sounds through the store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-03 15:53:34 -04:00
1 parent 65a3546c3b
commit 9f43a210c5
13 files changed
+195 -130

No files matched your search

+6 -7
View File
@@ -359,10 +359,10 @@ namespace anm2ed::imgui
auto fraction = current - glm::floor(current);
return glm::floor(value) + fraction;
};
auto edit_begin_push = [&](StringType label, bool isTextures = false)
auto edit_begin_push = [&](StringType label)
{
manager.command_push({manager.selected, [label, isTextures](Manager&, Document& document)
{ document.edit_begin(label, isTextures); }});
manager.command_push(
{manager.selected, [label](Manager&, Document& document) { document.edit_begin(label); }});
};
auto document_change_push = [&](Document::ChangeType changeType)
{
@@ -542,9 +542,8 @@ namespace anm2ed::imgui
auto queuedSpritesheet = referenceSpritesheet;
manager.command_push({manager.selected, [=](Manager&, Document& document)
{
auto texture = document.texture_get(queuedSpritesheet);
if (!texture) return;
texture->pixel_line(start, end, color);
if (auto texture = document.texture_edit(queuedSpritesheet))
texture->pixel_line(start, end, color);
}});
};
auto texture_change_push = [&]()
@@ -819,7 +818,7 @@ namespace anm2ed::imgui
{
if (!texture) break;
auto color = useTool == tool::DRAW ? toolColor : vec4();
if (isMouseClicked) edit_begin_push(useTool == tool::DRAW ? EDIT_DRAW : EDIT_ERASE, true);
if (isMouseClicked) edit_begin_push(useTool == tool::DRAW ? EDIT_DRAW : EDIT_ERASE);
if (isMouseDown) texture_line_apply(ivec2(previousTextureMousePos), ivec2(textureMousePos), color);
if (isMouseReleased) texture_change_push();
break;