diff --git a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp index b82a932a..7694efa9 100644 --- a/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp +++ b/src/nostalgia/modules/core/src/studio/tilesheeteditor/tilesheeteditormodel.cpp @@ -30,6 +30,17 @@ Palette const TileSheetEditorModel::s_defaultPalette = { .pages = {ox::Vector(128)}, }; +// delete pixels of all non-leaf nodes +static void normalizeSubsheets(TileSheet::SubSheet &ss) noexcept { + if (ss.subsheets.empty()) { + for (auto &child : ss.subsheets) { + normalizeSubsheets(child); + } + } else { + ss.pixels.clear(); + } +} + TileSheetEditorModel::TileSheetEditorModel(turbine::Context &ctx, ox::StringView path, studio::UndoStack &undoStack): m_ctx(ctx), m_path(path), @@ -37,6 +48,7 @@ TileSheetEditorModel::TileSheetEditorModel(turbine::Context &ctx, ox::StringView // ignore failure to load palette m_pal(readObj(keelCtx(m_ctx), m_img.defaultPalette).value), m_undoStack(undoStack) { + normalizeSubsheets(m_img.subsheet); m_pal.updated.connect(this, &TileSheetEditorModel::markUpdated); m_undoStack.changeTriggered.connect(this, &TileSheetEditorModel::markUpdatedCmdId); }