Repository navigation
chore: Lay the cross section and the particle lines with vector operations - #126
Merged
Merged
Conversation
…tions - //bc turns the direction of the curve a quarter turn on the xz plane to lay its cross section across it, instead of turning it into an angle and back with cos and sin. BezierSegment.direction gives that direction, and angle, which nothing else used, is removed. - The cross of a handle goes from each corner of the block towards its center, and the handle line from the point towards the handle, written with vectors instead of each coordinate. - The length of a segment and the distance along it use Vector3.distance.
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
Some of the math of
//bcand of the particle preview went through angles or wrote each coordinate out, which hid what it computes. This writes it with vector operations.//bc:CurveLayoutturned the direction of the curve into an angle withatan2and back withcos(-angle)andsin(-angle)to lay the cross section across the curve. It now turns the direction a quarter turn on the xz plane (the way that takes +z to +x) and scales it to length 1. A curve that does not move on the xz plane still gets +x.Samplekeeps this vector instead of the angle.BezierSegment.direction: gives the direction of the curve (the derivative divided by 3) as a vector.angle, whose only caller wasCurveLayout, is removed.corner + (center - corner) * i / density, instead of0.5 * x + (density * x + (-x * 2 + 1) * i) / density * 0.5for each coordinate.start + (handle - point) * tinstead of each coordinate.BezierSegment.lengthandCurveLayoutuseVector3.distanceinstead of writing the square root out; the result is the same to the bit.How it was tested
//bcplaces the blocks beside the curve was compared with the angle version on 20,000 random curves (68 million positions): 2 differ, both at exactly .5, where the rounding went the other way by about 1e-15../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.BezierSegmentTestchecksdirection(the ends go towards their handles, the weights at t = 0.5, and no direction at an end without a handle) instead ofangle, and a newCurveLayoutTestchecks that the cross section is laid across a curve along z, as the existing one does along x.//bcand the particle preview in the game.Notes