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;
+6 -8
View File
@@ -303,7 +303,8 @@ import {
} from './opening-dimensions';
import { safeStoredColor } from './color';
import {
gridCellFieldToCm, gridCellFieldValue, gridVisualScale, gridVisualUnits, newSpaceCellCm,
gridCellFieldToCm, gridCellFieldValue, gridVisualScale, gridVisualUnits,
newSpaceCellCm, wallThickHoverHalfUnits,
} from './grid-scale';
import {
applySpaceOrder, canStartTabDrag, markersNeedingPlacement, passedDragThreshold,
@@ -11746,13 +11747,10 @@ class HouseplanCard extends LitElement {
if (!this._markup || this._tool !== 'wallthick' || !this._cursorPt || this._wallDialog) return null;
const hit = this._wallThickHit(this._cursorPt);
if (!hit) return null;
// Whole-wall strip: real half-depth when thickness is set, else a visible
// minimum so thin centreline walls still light up under the cursor.
const cm = hit.cm;
const depth = cm > 0
? wallCmToUnits(cm, this._cellCm, this._gridPitch)
: this._gridPitch * 3;
const half = Math.max(depth / 2, this._gridPitch * 1.25);
// The visible strip follows the physical wall body. Only a zero-thickness
// centreline receives a scale-independent visual minimum; hit testing keeps
// its deliberately generous and separate radius in _wallThickHit().
const half = wallThickHoverHalfUnits(hit.cm, this._cellCm, this._gridPitch);
let d = '';
for (const sg of hit.segs) {
d += (d ? ' ' : '') + drawWallPreviewD(