Spritesheet Editor draws SVG sheets sharp when zoomed

vector_image_get takes an image and a scale, so the editor shares the
preview's per-zoom-level cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-08 17:48:41 -04:00
1 parent 54f62529e0
commit 5d274e547a
3 files changed
+12 -2

No files matched your search

+7 -1
View File
@@ -412,7 +412,7 @@ namespace anm2ed
return names; return names;
} }
// A layer draw's spritesheet image; a vector one is drawn again (cached) when `scale` canvas pixels show each pixel. // A layer draw's spritesheet image, at `scale` (see vector_image_get).
const resource::Image* Document::draw_image_get(const model::Draw& draw, float scale) const const resource::Image* Document::draw_image_get(const model::Draw& draw, float scale) const
{ {
const resource::Image* image{}; const resource::Image* image{};
@@ -420,6 +420,12 @@ namespace anm2ed
for (const auto& [path, library] : libraries) for (const auto& [path, library] : libraries)
if (&library.model == draw.source) if (&library.model == draw.source)
if (auto found = library.images.find(draw.spritesheetId); found != library.images.end()) image = &found->second; if (auto found = library.images.find(draw.spritesheetId); found != library.images.end()) image = &found->second;
return vector_image_get(image, scale);
}
// A vector image drawn again (cached) for when `scale` screen pixels show each of its pixels; others as they are.
const resource::Image* Document::vector_image_get(const resource::Image* image, float scale) const
{
if (!image || !image->is_vector() || scale <= 1.0f) return image; if (!image || !image->is_vector() || scale <= 1.0f) return image;
auto level = std::min((int)std::ceil(std::log2(scale)), document::VECTOR_LEVEL_MAX); auto level = std::min((int)std::ceil(std::log2(scale)), document::VECTOR_LEVEL_MAX);
+1
View File
@@ -129,6 +129,7 @@ namespace anm2ed
model::LibraryGet library_resolver_get() const; model::LibraryGet library_resolver_get() const;
std::vector<std::string> animation_names_get(int) const; std::vector<std::string> animation_names_get(int) const;
const resource::Image* draw_image_get(const model::Draw&, float = 1.0f) const; const resource::Image* draw_image_get(const model::Draw&, float = 1.0f) const;
const resource::Image* vector_image_get(const resource::Image*, float) const;
void libraries_sync(); void libraries_sync();
bool libraries_reload(); bool libraries_reload();
void library_reload(int); void library_reload(int);
+4 -1
View File
@@ -420,7 +420,10 @@ namespace anm2ed::imgui
auto spritesheetTransform = transform * spritesheetModel; auto spritesheetTransform = transform * spritesheetModel;
if (baseTexture && baseTexture->is_valid()) if (baseTexture && baseTexture->is_valid())
texture_render(shaderTexture, resource::texture::id_get(*baseTexture), spritesheetTransform); texture_render(
shaderTexture,
resource::texture::id_get(*document.vector_image_get(baseTexture, math::percent_to_unit(zoom))),
spritesheetTransform);
if (isGrid) grid_render(shaderGrid, zoom, pan, gridSize, gridOffset, gridColor); if (isGrid) grid_render(shaderGrid, zoom, pan, gridSize, gridOffset, gridColor);