fix(editor): polygon vertex/edge edit honors the active snapping mode
The shared polygon-vertex affordance snapped via snapPointToGrid(rawPoint), whose default step is the hardcoded WALL_GRID_STEP (0.5m) — so slab/zone/ceiling vertex, edge, and add-vertex edits always quantized to half-meters regardless of the active mode OR the user's grid-step setting (plan open bugs #1-2). Use the mode-aware getSegmentGridStep() (0 in non-grid modes) so grid quantizes to the live step, lines/off pass through to the wall-snap/alignment resolver. Drop the legacy shiftKey bypass from the slab/ceiling magnetic resolvers (they already gate on isMagneticSnapActive). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
167f0868ef
commit
ac14443fa6
@@ -28,8 +28,9 @@ const ceilingSnapOptions = {
|
|||||||
levelId: resolveLevelId(node, sceneNodes),
|
levelId: resolveLevelId(node, sceneNodes),
|
||||||
excludeId: node.id,
|
excludeId: node.id,
|
||||||
nodes: sceneNodes,
|
nodes: sceneNodes,
|
||||||
|
// Magnetic wall-snap/alignment gates on `isMagneticSnapActive()` (the
|
||||||
|
// `lines` mode), so no Shift bypass — Alt still force-skips alignment.
|
||||||
altKey: modifiers.altKey,
|
altKey: modifiers.altKey,
|
||||||
shiftKey: modifiers.shiftKey,
|
|
||||||
}).point
|
}).point
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ import {
|
|||||||
type FloorplanAffordanceSession,
|
type FloorplanAffordanceSession,
|
||||||
useScene,
|
useScene,
|
||||||
} from '@pascal-app/core'
|
} from '@pascal-app/core'
|
||||||
import { snapPointToGrid, type WallPlanPoint } from '@pascal-app/editor'
|
import {
|
||||||
|
getSegmentGridStep,
|
||||||
|
snapPointToGrid,
|
||||||
|
snapScalarToGrid,
|
||||||
|
type WallPlanPoint,
|
||||||
|
} from '@pascal-app/editor'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shared "edit polygon" floor-plan affordances. Used by kinds whose
|
* Shared "edit polygon" floor-plan affordances. Used by kinds whose
|
||||||
@@ -123,7 +128,11 @@ export function createPolygonVertexAffordance<N extends PolygonShape & { id: Any
|
|||||||
affectedIds: [node.id],
|
affectedIds: [node.id],
|
||||||
apply({ planPoint, modifiers }) {
|
apply({ planPoint, modifiers }) {
|
||||||
const rawPoint: WallPlanPoint = [planPoint[0], planPoint[1]]
|
const rawPoint: WallPlanPoint = [planPoint[0], planPoint[1]]
|
||||||
const fallbackPoint = modifiers.shiftKey ? rawPoint : snapPointToGrid(rawPoint)
|
// Mode-driven grid snap (matches the chip): `getSegmentGridStep()` is
|
||||||
|
// 0 in any non-`grid` mode, so `lines` / `off` pass the raw point
|
||||||
|
// through (the resolver's wall-snap/alignment handles `lines`); `grid`
|
||||||
|
// quantizes to the live grid step. No Shift hold-to-bypass.
|
||||||
|
const fallbackPoint = snapPointToGrid(rawPoint, getSegmentGridStep())
|
||||||
const snapped = resolveAffordancePlanPoint(options, {
|
const snapped = resolveAffordancePlanPoint(options, {
|
||||||
node,
|
node,
|
||||||
nodes,
|
nodes,
|
||||||
@@ -207,7 +216,11 @@ export function createPolygonAddVertexAffordance<N extends PolygonShape & { id:
|
|||||||
affectedIds: [node.id],
|
affectedIds: [node.id],
|
||||||
apply({ planPoint, modifiers }) {
|
apply({ planPoint, modifiers }) {
|
||||||
const rawPoint: WallPlanPoint = [planPoint[0], planPoint[1]]
|
const rawPoint: WallPlanPoint = [planPoint[0], planPoint[1]]
|
||||||
const fallbackPoint = modifiers.shiftKey ? rawPoint : snapPointToGrid(rawPoint)
|
// Mode-driven grid snap (matches the chip): `getSegmentGridStep()` is
|
||||||
|
// 0 in any non-`grid` mode, so `lines` / `off` pass the raw point
|
||||||
|
// through (the resolver's wall-snap/alignment handles `lines`); `grid`
|
||||||
|
// quantizes to the live grid step. No Shift hold-to-bypass.
|
||||||
|
const fallbackPoint = snapPointToGrid(rawPoint, getSegmentGridStep())
|
||||||
const snapped = resolveAffordancePlanPoint(options, {
|
const snapped = resolveAffordancePlanPoint(options, {
|
||||||
node,
|
node,
|
||||||
nodes,
|
nodes,
|
||||||
@@ -301,12 +314,13 @@ export function createPolygonMoveEdgeAffordance<N extends PolygonShape & { id: A
|
|||||||
const rawPoint: WallPlanPoint = [planPoint[0], planPoint[1]]
|
const rawPoint: WallPlanPoint = [planPoint[0], planPoint[1]]
|
||||||
const deltaX = rawPoint[0] - startX
|
const deltaX = rawPoint[0] - startX
|
||||||
const deltaY = rawPoint[1] - startY
|
const deltaY = rawPoint[1] - startY
|
||||||
let projection = deltaX * normalX + deltaY * normalY
|
// Mode-driven snap of the perpendicular distance (matches the chip):
|
||||||
if (!modifiers.shiftKey) {
|
// `getSegmentGridStep()` is 0 in non-`grid` modes, so `snapScalarToGrid`
|
||||||
// Snap the projection scalar to a 0.5m grid (legacy uses the
|
// passes the raw projection through; `grid` quantizes to the live step.
|
||||||
// same half-meter snap for slab edges).
|
const projection = snapScalarToGrid(
|
||||||
projection = Math.round(projection * 2) / 2
|
deltaX * normalX + deltaY * normalY,
|
||||||
}
|
getSegmentGridStep(),
|
||||||
|
)
|
||||||
const fallbackPoint: WallPlanPoint = [
|
const fallbackPoint: WallPlanPoint = [
|
||||||
startX + normalX * projection,
|
startX + normalX * projection,
|
||||||
startY + normalY * projection,
|
startY + normalY * projection,
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ const slabSnapOptions = {
|
|||||||
levelId: resolveLevelId(node, sceneNodes),
|
levelId: resolveLevelId(node, sceneNodes),
|
||||||
excludeId: node.id,
|
excludeId: node.id,
|
||||||
nodes: sceneNodes,
|
nodes: sceneNodes,
|
||||||
|
// Magnetic wall-snap/alignment gates on `isMagneticSnapActive()` (the
|
||||||
|
// `lines` mode), so no Shift bypass — Alt still force-skips alignment.
|
||||||
altKey: modifiers.altKey,
|
altKey: modifiers.altKey,
|
||||||
shiftKey: modifiers.shiftKey,
|
|
||||||
}).point
|
}).point
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user