mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-07 23:19:14 +00:00
v1.59.0-rc.1: optimize plans and polish editor feedback
This commit is contained in:
@@ -83,6 +83,15 @@ test('degradeWalls drops a key with no matching room edge', () => {
|
||||
assert.equal(kept[0].key, live);
|
||||
});
|
||||
|
||||
test('degradeWalls keeps an exact maximal run even when another breakpoint subdivides it', () => {
|
||||
const rooms = [{ id: 'r1', poly: [[0, 0], [1, 0], [1, 1], [0, 1]] }];
|
||||
const walls = setWallThickness([], [0, 0], [0.4, 0], 18, pitch);
|
||||
const kept = degradeWalls(walls, rooms, pitch);
|
||||
assert.equal(kept.length, 1);
|
||||
assert.deepEqual(kept[0].a, [0, 0]);
|
||||
assert.deepEqual(kept[0].b, [0.4, 0]);
|
||||
});
|
||||
|
||||
test('rekeyWallsAfterMove rewrites the key when a span shifts by one cell', () => {
|
||||
const oldA = [0.1, 0.2], oldB = [0.4, 0.2];
|
||||
const newA = [0.1, 0.2 + pitch], newB = [0.4, 0.2 + pitch];
|
||||
@@ -107,6 +116,16 @@ test('rekeyWallsAfterMove carries atomic remainders of a partially virtual wall'
|
||||
]);
|
||||
});
|
||||
|
||||
test('rekeyWallsAfterMove carries exact interval endpoints with the wall', () => {
|
||||
const oldA = [0.2, 0.1], oldB = [0.2, 0.4];
|
||||
const newA = [0.3, 0.1], newB = [0.3, 0.4];
|
||||
const walls = setWallThickness([], oldA, oldB, 22, pitch);
|
||||
const next = rekeyWallsAfterMove(walls, [[oldA, oldB]], [[newA, newB]], pitch);
|
||||
assert.equal(next[0].key, wallKey(newA, newB, pitch));
|
||||
assert.deepEqual(next[0].a, newA);
|
||||
assert.deepEqual(next[0].b, newB);
|
||||
});
|
||||
|
||||
test('setWallThickness upserts and removes', () => {
|
||||
const a = [0, 0], b = [1, 0];
|
||||
let walls = setWallThickness([], a, b, 12, pitch);
|
||||
@@ -176,7 +195,11 @@ test('equal solid atomic pieces compact back to one whole-wall key', () => {
|
||||
{ key: wallKey([5, 4], [5, 10], pitch), cm: 30 },
|
||||
];
|
||||
const next = normalizeWallIntervals(rooms, walls, [], pitch, cellCm, GRID_PITCH);
|
||||
assert.deepEqual(next, [{ key: wallKey([5, 0], [5, 10], pitch), cm: 30 }]);
|
||||
assert.equal(next.length, 1);
|
||||
assert.equal(next[0].key, wallKey([5, 0], [5, 10], pitch));
|
||||
assert.equal(next[0].cm, 30);
|
||||
assert.deepEqual(next[0].a, [5, 0]);
|
||||
assert.deepEqual(next[0].b, [5, 10]);
|
||||
});
|
||||
|
||||
test('different solid thicknesses remain separate atomic keys', () => {
|
||||
@@ -191,6 +214,33 @@ test('different solid thicknesses remain separate atomic keys', () => {
|
||||
assert.ok(!next.some((w) => w.key === wallKey([5, 0], [5, 10], pitch)));
|
||||
});
|
||||
|
||||
test('closing the sole geometric split preserves different thicknesses', () => {
|
||||
const rooms = [
|
||||
{ id: 'a', poly: [[0, 0], [5, 0], [5, 10], [0, 10]] },
|
||||
{ id: 'b', poly: [[5, 0], [10, 0], [10, 10], [5, 10]] },
|
||||
];
|
||||
// No neighbour endpoint and no open cut remains at y=4. Exact endpoints in
|
||||
// new wall entries are therefore the only record of this intentional break.
|
||||
let walls = setWallThickness([], [5, 0], [5, 4], 20, pitch);
|
||||
walls = setWallThickness(walls, [5, 4], [5, 10], 30, pitch);
|
||||
const next = normalizeWallIntervals(rooms, walls, [], pitch, cellCm, GRID_PITCH);
|
||||
assert.equal(next.length, 2);
|
||||
assert.deepEqual(new Set(next.map((w) => w.cm)), new Set([20, 30]));
|
||||
assert.ok(next.some((w) => w.a?.[1] === 4 || w.b?.[1] === 4));
|
||||
});
|
||||
|
||||
test('exact endpoints do not prevent equal closed pieces from compacting', () => {
|
||||
const rooms = [
|
||||
{ id: 'a', poly: [[0, 0], [5, 0], [5, 10], [0, 10]] },
|
||||
{ id: 'b', poly: [[5, 0], [10, 0], [10, 10], [5, 10]] },
|
||||
];
|
||||
let walls = setWallThickness([], [5, 0], [5, 4], 20, pitch);
|
||||
walls = setWallThickness(walls, [5, 4], [5, 10], 20, pitch);
|
||||
const next = normalizeWallIntervals(rooms, walls, [], pitch, cellCm, GRID_PITCH);
|
||||
assert.equal(next.length, 1);
|
||||
assert.equal(next[0].key, wallKey([5, 0], [5, 10], pitch));
|
||||
});
|
||||
|
||||
// An open span that does NOT contain the parent edge's midpoint used to leave
|
||||
// the key in place, so the wall body stayed solid straight across the passage.
|
||||
test('open span away from the edge midpoint clears only its own interval', () => {
|
||||
|
||||
Reference in New Issue
Block a user