Skip to content

fix: Lay the cross section of //bc across the curve at its ends - #127

Merged
kous500 merged 1 commit into
mainfrom
fix/bc-curve-ends-20261114
Nov 14, 2026
Merged

kous500 merged 1 commit into
mainfrom
fix/bc-curve-ends-20261114

Conversation

@kous500

@kous500 kous500 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

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 //bc then laid the cross section along +x. CurveLayout stepped along the curve by adding 1 / fineness to t; that reached t = 1 only 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 reach t = 1 for any length from 1 to 300.

  • BezierSegment.tangent: the direction of the curve, also where direction is zero. At an end without a handle, the curve leaves p0 towards p2, or arrives at p3 from p1, which is the direction just beside the end; when that is zero too, from p0 to p3.
  • Steps of //bc: t is 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 is tangent, so the first step is at t = 0 instead of t = 0.00001.

How it was tested

  • New tests: CurveLayoutTest lays 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. BezierSegmentTest checks tangent where 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 that build runs them on. After the last change, to the Javadoc of tangent, only the compilation and checkCodeStyle were run again.
  • IntelliJ IDEA's inspections report no warnings in the changed files.
  • //bc was checked in the game by the maintainer.
  • Minecraft version: the versions of the game tests
  • Server software / loader: Fabric (game tests)
  • WorldEdit / FastAsyncWorldEdit version: the versions in the build

Notes

  • With the default fineness, a segment whose length is a whole number now also gets a step at its end; it usually falls on the same block as the step before it.

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.
@kous500
kous500 enabled auto-merge (squash) November 14, 2026 14:39
@kous500
kous500 merged commit b256fbb into main Nov 14, 2026
28 checks passed
@kous500
kous500 deleted the fix/bc-curve-ends-20261114 branch November 14, 2026 14:43
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.

1 participant