fix(image): erasing a broken raster reference clears its placeholder text

A raster reference that cannot be resolved is the only framed entity whose
to_render emits a RenderObject::Text: the frame and its diagonals are lines,
but the saved file path becomes a real glyph run in the SDF text buffer.

gather_text_verts reuses the whole previous vertex buffer when
text_unchanged(epoch) says no text-bearing entity moved, and that asks
entity_affects_text_cache -- which enumerated Text, MText, Dimension,
MultiLeader, Leader, Table, Tolerance, attributes and Insert, but not
RasterImage. So an erase never raised CACHE_CATEGORY_TEXT, the stale buffer
was taken as valid, and the path kept drawing over empty space. The reuse
branch then re-stamps that buffer with the current epoch, which froze it
until a full rebuild. CACHE_CATEGORY_IMAGE did not cover the gap: it is set
from images.contains_key(handle), and a missing reference has no ImageModel
at all.

The same gap broke three more flows from the Added/Modified side: ATTACH of
a missing reference showed no text, MOVE and grip-drag left the text behind
while the frame followed, and UNDO after an erase did not bring it back.

entity_affects_text_cache now counts a RasterImage whose reference does not
resolve, reusing the converter's memoised resolve_image probe so the two
cannot disagree. Kept a probe rather than a blanket type match so a healthy
image does not rebuild every glyph in the drawing on each mouse move of a
grip-drag.

Four regression tests, each confirmed to fail without the fix. The main one
is end-to-end on the buffer the GPU draws: before, the erased placeholder
left 300 glyph vertices on screen (50 chars x 6).

Also: to_render ran the same resolve probe twice; now once, shared by the
outline and placeholder branches. Moved text_unchanged's doc comment off
draw_ranks_stable, where it had drifted, and recorded the rule that every
entity able to emit a GlyphRun must be declared there.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
PanosandClaude Opus 5 committed 2026-10-01 17:42:38 +03:00
1 parent 350742f2b0
commit 7e12dab89e
2 files changed
+144 -19

No files matched your search

+14 -13
View File
@@ -142,9 +142,11 @@ impl RenderConvertible for RasterImage {
// Diagonals are the BROKEN-reference placeholder; a resolvable image
// draws its pixels inside the frame, so the X would scribble over it.
let path_probe = self.file_path.trim();
let resolvable = path_probe.is_empty()
|| crate::scene::model::image_model::resolve_image(path_probe).is_some();
// One probe for the whole conversion: the outline below and the
// placeholder branch further down must agree on a single answer.
let path = self.file_path.trim();
let resolvable =
path.is_empty() || crate::scene::model::image_model::resolve_image(path).is_some();
// Outline: the clip boundary, or — when it hides its inside — the
// frame with the boundary as a hole. Must match the raster's own clip
// triangulation in `ImageModel` so outline and pixels align.
@@ -166,16 +168,15 @@ impl RenderConvertible for RasterImage {
// A raster OCS can display renders its pixels (built separately) inside
// this frame — just draw the frame/clip outline. A reference it cannot
// resolve (an offline/broken URL, a missing or renamed file) gets
// AutoCAD's broken-reference treatment: the frame plus the saved path
// drawn as text, so the user sees WHICH reference is unresolved instead
// of an empty box. `resolve_image` is memoised and shared with the
// raster loader, so a URL that fetches online is treated as resolvable
// (no placeholder — the image shows) while an offline one falls back to
// the path text, and neither is fetched twice.
let path = self.file_path.trim();
let resolvable =
path.is_empty() || crate::scene::model::image_model::resolve_image(path).is_some();
// resolve (an offline/broken URL, a missing or renamed file) gets the
// usual broken-reference treatment: the frame plus the saved path drawn
// as text, so the user sees WHICH reference is unresolved instead of an
// empty box. `resolve_image` is memoised and shared with the raster
// loader, so a URL that fetches online is treated as resolvable (no
// placeholder — the image shows) while an offline one falls back to the
// path text, and neither is fetched twice. The scene's text-cache
// classifier runs the same probe, so erasing this placeholder drops its
// glyphs from the text buffer instead of leaving them on screen.
if resolvable {
return Some(RenderEntity {
// Picked on its frame only (shown or hidden), like the other