Place inserted pieces under the cursor and aligned to studs. Fixes #1020. - #1025
Open
roor0 wants to merge 1 commit into
Open
Place inserted pieces under the cursor and aligned to studs. Fixes #1020.#1025roor0 wants to merge 1 commit into
roor0 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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::GetMouseInsertPieceInfotook 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
Testing