Cover which tilemap layer and texture frame get a collision fill
f4cc681 fills tilemap solids only for the selected map and layer, and
texture collision only for the selected frame. Neither the scene view
wiring nor the texture canvas had a test for that.
- __gm.tilemap.solids() now reports the cells that were filled, and
__gm.texture.drawInfo() counts the filled outlines.
- e2e 40l-iii: a selected tile fills nothing. The map selected with
the upper layer fills only cell (4,0), with the lower layer only the
3x3 block. Two selected objects fill nothing again.
- e2e 42: a selected frame fills its one outline. Deselected it fills
none, while the outline stays visible.
- README check total goes from 1375 to 1377. CI confirmed 1375, the
new total is counted, not yet measured.
Tests:
- ./check.sh: 159 files, 2337 tests, CHECK EXIT 0
- e2e 39-43: ALL PASSED, 147 checks (before 145)
- Counter checks: a scene view that fills every map fails only the
tilemap check. A texture canvas that fills every frame fails only
the texture check.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f29b88cc9
commit
c1a6d63edb
5 files changed
+96
-7
No files matched your search
@@ -120,6 +120,9 @@ export class TextureCanvas extends SheetCanvas<TextureAsset> {
|
||||
private sheetKey: unknown[] = [];
|
||||
private sheetBuilds = 0;
|
||||
private sheetOutlines = 0;
|
||||
/** Outlines drawn tinted, on the sheet and on the overlay – only the selected frame's should be. */
|
||||
private sheetFilled = 0;
|
||||
private overlayFilled = 0;
|
||||
private readonly labels = new Map<string, Text>();
|
||||
private readonly labelLayer = new Container();
|
||||
private readonly plates = new Graphics();
|
||||
@@ -180,6 +183,7 @@ export class TextureCanvas extends SheetCanvas<TextureAsset> {
|
||||
return {
|
||||
sheetBuilds: this.sheetBuilds,
|
||||
sheetOutlines: this.sheetOutlines,
|
||||
filled: { sheet: this.sheetFilled, overlay: this.overlayFilled },
|
||||
origin: { x: origin.x, y: origin.y },
|
||||
labels: [...this.labels.values()]
|
||||
.filter((label) => label.visible)
|
||||
@@ -604,15 +608,18 @@ export class TextureCanvas extends SheetCanvas<TextureAsset> {
|
||||
this.sheet.clear();
|
||||
const others = frames.filter((f) => f.id !== selectedId);
|
||||
for (const frame of others) this.drawFrame(this.sheet, view, frame, false);
|
||||
for (const frame of others) this.drawOutlines(this.sheet, view, frame, false, false);
|
||||
this.sheetFilled = 0;
|
||||
for (const frame of others)
|
||||
this.sheetFilled += this.drawOutlines(this.sheet, view, frame, false, false);
|
||||
this.sheetBuilds += 1;
|
||||
this.sheetOutlines = others.reduce((n, f) => n + (f.collision?.length ?? 0), 0);
|
||||
}
|
||||
this.overlay.clear();
|
||||
this.overlayFilled = 0;
|
||||
const selected = frames.find((f) => f.id === selectedId);
|
||||
if (selected) {
|
||||
this.drawFrame(this.overlay, view, selected, true);
|
||||
this.drawOutlines(this.overlay, view, selected, this.collision, true);
|
||||
this.overlayFilled = this.drawOutlines(this.overlay, view, selected, this.collision, true);
|
||||
if (!this.collision) {
|
||||
this.drawBorders(view, selected);
|
||||
this.drawHandles(view, selected);
|
||||
@@ -656,7 +663,7 @@ export class TextureCanvas extends SheetCanvas<TextureAsset> {
|
||||
* A frame's collision outlines (#141), always shown so one sees which frames block with them; on
|
||||
* the edited frame the active outline is drawn heavier and every corner of every outline gets a
|
||||
* handle. An outline that is no polygon is drawn in red. Only the selected frame's outlines are
|
||||
* `filled`, so the tint does not lie over the art of every other frame.
|
||||
* `filled`, so the tint does not lie over the art of every other frame. Returns how many were tinted.
|
||||
*/
|
||||
private drawOutlines(
|
||||
g: Graphics,
|
||||
@@ -664,16 +671,20 @@ export class TextureCanvas extends SheetCanvas<TextureAsset> {
|
||||
frame: TextureFrame,
|
||||
edited: boolean,
|
||||
filled: boolean,
|
||||
): void {
|
||||
): number {
|
||||
const outlines = frame.collision ?? [];
|
||||
const active = edited ? this.activeOutline(frame, outlines) : -1;
|
||||
let tinted = 0;
|
||||
for (const [index, points] of outlines.entries()) {
|
||||
const screen = points.map((p) => imageToLocal(view, frame.x + p.x, frame.y + p.y));
|
||||
const color = isPolygon(points) ? Theme.colors.collider : Theme.colors.danger;
|
||||
const width = index === active ? 2 : 1;
|
||||
if (screen.length >= 3) {
|
||||
g.poly(screen, true);
|
||||
if (filled) g.fill({ color, alpha: COLLIDER_FILL_ALPHA });
|
||||
if (filled) {
|
||||
g.fill({ color, alpha: COLLIDER_FILL_ALPHA });
|
||||
tinted += 1;
|
||||
}
|
||||
g.stroke({ width, color });
|
||||
} else if (screen.length === 2)
|
||||
g.moveTo(screen[0]!.x, screen[0]!.y).lineTo(screen[1]!.x, screen[1]!.y).stroke({ width: 2, color });
|
||||
@@ -684,6 +695,7 @@ export class TextureCanvas extends SheetCanvas<TextureAsset> {
|
||||
.fill(index === active ? Theme.colors.accentText : Theme.colors.viewport)
|
||||
.stroke({ width: 1, color });
|
||||
}
|
||||
return tinted;
|
||||
}
|
||||
|
||||
private drawHandles(view: SheetView, frame: TextureFrame): void {
|
||||
|
||||
Reference in new issue
Block a user