Buffer protocol / numpy views for ColorLayer and TileLayer #335
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
Reference
john/McRogueFace#335
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the 2026-07-02 memory-model review. Additive API. Blocked by the bulk-edit convention decision (#328) -- these layers have dirty state that raw writes bypass.
Why the storage is already ready
ColorLayer:std::vector<sf::Color>(src/GridLayers.h:88) -- contiguous(h, w, 4)uint8 RGBA.TileLayer:std::vector<int>(src/GridLayers.h:146) -- contiguous(h, w)int32, -1 = empty.Both are per-layer SoA and contiguous across the whole grid (layer chunking is only in the render cache,
chunk_textures/chunk_dirtyatsrc/GridLayers.h:42-45, not in the data).What needs the convention
Cell writes today go one-at-a-time through
layer->at(x,y)+markDirty(x,y)(src/UIGridPoint.cpp:167-256,src/GridLayers.h:222-249); the only bulk ops arefill/fill_rect. A raw numpy write bypassesmarkDirty, so stale chunk textures would render. Implementation per whichever idiom wins:with layer.edit() as arr:marking dirty on exit, or view + mandatorylayer.mark_dirty().Payoff
Wave-function-collapse, LDtk post-processing, heightmap coloring, and agent observation extraction (tile indices + RGBA planes) all become single vectorized numpy expressions instead of Python per-cell loops.
Together with DiscreteMap and (post-#332) walkable/transparent planes, a gym-style observation is a stack of zero-copy planes assembled in a few lines -- see #55/#154.