Repository navigation
fix: Lay the cross section of //bc across the curve at its ends - #127
Merged
Merged
Conversation
At an end whose handle is at its point, the curve has no direction, and //bc laid the cross section along +x there. It stepped along the curve by adding 1 / fineness to t, which reached t = 1 only for some lengths, such as most short ones with a fineness of 1: then the end of a curve along x got its cross section along the curve, past its end. - BezierSegment.tangent gives the direction also where it is zero: at an end without a handle, the curve leaves towards, or arrives from, the other handle. - //bc takes its steps as whole steps divided by the fineness, so the end of a segment is always one, and uses tangent for the direction there instead of starting at t = 0.00001.
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.
What and why
At an end of a segment whose handle is at its point, the curve has no direction (its derivative is zero), and
//bcthen laid the cross section along +x.CurveLayoutstepped along the curve by adding1 / finenesstot; that reachedt = 1only for some lengths, because of rounding. With a fineness of 1 it did for lengths such as 1 - 5, 8, 12 and 16: a straight curve along x from 0 to 4 with a selection three blocks wide got the blocks (4, 0) and (5, 0) at its end instead of (4, -1), (4, 0) and (4, 1). With the default fineness of 10 it did not reacht = 1for any length from 1 to 300.BezierSegment.tangent: the direction of the curve, also wheredirectionis zero. At an end without a handle, the curve leavesp0towardsp2, or arrives atp3fromp1, which is the direction just beside the end; when that is zero too, fromp0top3.//bc:tis a whole step divided by the fineness, so the end of a segment is always a step when the fineness is whole, and it does not drift with rounding (by up to 1.6e-13 before). The direction istangent, so the first step is att = 0instead oft = 0.00001.How it was tested
CurveLayoutTestlays a straight curve along x with one step per block and checks the blocks at its end; it fails on the code before this change.BezierSegmentTestcheckstangentwhere there is a direction, at the ends of a straight segment, at an end without a handle, and for a segment at one place../gradlew build :curvebuilding-fabric:26.3:runGameTest checkCodeStyle --warning-mode all: the build and unit tests pass, with no Gradle, javac or Checkstyle warnings. The game tests pass on the six versions thatbuildruns them on. After the last change, to the Javadoc oftangent, only the compilation andcheckCodeStylewere run again.//bcwas checked in the game by the maintainer.Notes