Skip to content

Place inserted pieces under the cursor and aligned to studs. Fixes #1020. - #1025

Open
roor0 wants to merge 1 commit into
leozide:masterfrom
roor0:oddBrickSnap
Open

Place inserted pieces under the cursor and aligned to studs. Fixes #1020.#1025
roor0 wants to merge 1 commit into
leozide:masterfrom
roor0:oddBrickSnap

Conversation

@roor0

@roor0 roor0 commented Jun 10, 2026

Copy link
Copy Markdown

Summary

Fixes #1020 — inserting an odd-sized part (1x1, 1x3, …) onto an even-sized part (2x2, 1x2, …) landed it half a stud off, between studs.

Root cause

When inserting a piece onto an existing piece, lcView::GetMouseInsertPieceInfo took the position from the hit-face vector (ObjectRayTest.PieceInfoRayTest.Plane), which is zero on the two in-face axes — it only identifies which face was hit. The new piece was therefore always placed at the target piece's origin, ignoring where the cursor actually was.

Because a piece's local origin sits on a stud for odd stud counts but between studs for even counts, an odd-sized part dropped onto an even-sized part landed half a stud off. Same-parity pairs (odd-on-odd, even-on-even) happened to line up, which is why other bricks seemed fine.

Fix

  • Use the actual cursor hit point on the surface for the two in-face axes (instead of the target origin), so pieces land where you point.
  • Snap those axes to the stud grid with a half-stud phase when the inserted and target pieces have different stud-count parity on that axis, so studs line up on studs.
  • A finer (half-stud) snap still reaches the positions between studs — e.g. placing a round 1x1 in the centre of a 2x2 — so no placement is lost.
  • The hit-face axis keeps the existing "abut against the face" offset, and vertical stacking rounding is unchanged.

Testing

  • Builds cleanly (Qt 6.6.3, macOS) and verified in the app.
  • Checked 1x1 / 1x3 / round-1x1 onto 2x2, 1x2, and 1x1 targets, at both 1-stud and half-stud move snap. At 1-stud snap pieces land on studs; at half-stud snap the between-stud positions remain reachable. Vertical stacking is unchanged.

…ozide#1020.

When inserting a piece onto an existing piece, the position came from the
hit-face vector, which is zero on the two in-face axes. The new piece was
therefore always placed at the target piece's origin, ignoring the cursor.
Because a piece's origin is on a stud for odd stud counts but between studs
for even counts, an odd-sized part (1x1, 1x3, ...) dropped onto an
even-sized part (2x2, 1x2, ...) landed half a stud off.

Use the actual cursor hit point on the surface for the in-face axes, and
snap them to the stud grid with a half-stud phase when the inserted and
target pieces have different stud-count parity, so studs line up. A
half-stud snap still reaches the positions between studs (e.g. a round 1x1
in the centre of a 2x2). Vertical stacking rounding is unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Snapping of 1x1 bricks doesn't work

1 participant