fix: match wall thickness hover to masonry

Issue: #303
User-Visible: yes
This commit is contained in:
Matysh
2026-08-25 12:49:41 +03:00
parent 0f71d869e3
commit 36992d68bd
10 changed files with 205 additions and 12 deletions
+16
View File
@@ -1,3 +1,5 @@
import { wallCmToUnits } from './wall-thickness';
/** Historical plan-cell size whose raw SVG constants define the visual baseline. */
export const GRID_VISUAL_REFERENCE_CELL_CM = 5;
@@ -16,6 +18,20 @@ export function gridVisualUnits(baseUnits: number, cellCm: unknown): number {
return baseUnits * gridVisualScale(cellCm);
}
/** Half-width of the Plan-editor wall-thickness hover strip, in plan units. */
export function wallThickHoverHalfUnits(
cm: number, cellCm: number, gridPitch: number,
): number {
const thicknessCm = Number.isFinite(cm) && cm > 0 ? cm : 0;
const normalizedCellCm = Number.isFinite(cellCm) && cellCm > 0
? cellCm
: GRID_VISUAL_REFERENCE_CELL_CM;
const normalizedPitch = Number.isFinite(gridPitch) && gridPitch > 0 ? gridPitch : 0;
return thicknessCm > 0
? wallCmToUnits(thicknessCm, normalizedCellCm, normalizedPitch) / 2
: gridVisualUnits(normalizedPitch * 1.5, normalizedCellCm);
}
/** Default only for newly-created spaces. Read compatibility keeps its own 5 cm fallback. */
export function newSpaceCellCm(imperial: boolean): number {
return imperial ? GRID_IMPERIAL_CELL_CM : 1;