Repository navigation
feature: Lay //bc around corners and up slopes without crossing itself - #136
Merged
Merged
Conversation
…tself Where the curve turns at a point, the cross section turns around the point to fill the outside of the corner, with only the columns on the outside. Where two segments meet turning by more than a degree on the xz plane, neither places anything on a column of blocks, at any height, where the other has laid first, so that inside the corner the two cross sections meet along the line where they are equally far from the middle, instead of crossing each other where the curve climbs or falls. The segments are laid together once all are added: row by row from the top, column by column from the middle, each column along every segment before the next, keeping the first block laid.
Name the steps and the segments laid as such, keep the size of the cross section and of the repeat in fields, and split out the side of a column, the block of a position, the columns taken at corners, the block of the selection and the loop that lays everything. No block placed changes.
The blocks laid are kept in a HashMap and given back unsorted, as the order they are placed in does not change what WorldEdit places. A curve of about 120,000 blocks is laid in about 48 ms instead of 70 ms.
…z cell The rows of the cross section are laid from the bottom up again. Where the curve climbs or falls within a column of blocks, each row passes two blocks there and the row below has laid on the lower one first, so every row keeps one block. For the bottom row, a row below it is worked out first, laying nothing, to keep the bottom row of the same segment off those blocks.
The columns of blocks that segments take at corners are keyed by a record of their x and z instead of a long packing both, and hold the indexes of the segments that took them in a set instead of a BitSet. No block placed changes.
…ells The record, the field and the method for the blocks at one x and z, at any height, are named XzCell, xzCellsTaken and takeXzCell, so that they are not mistaken for the columns of the cross section. The comments and the tests say xz cell for them too.
The rows of the cross section are laid from the middle outwards, the lower first of two as far, like its columns. Where the curve climbs or falls within an xz cell, the blocks that the rows share go to the rows nearest the middle, so that with three rows or more the top and bottom rows keep one block each. The row below the bottom row, which dropped the lower block of the bottom row, is no longer worked out: steep slopes stay connected and the block the curve starts in is laid.
A segment that climbs or falls more along its steps than it goes across the xz plane, such as one going straight up between two points, passes few xz cells, most of which the segment beside it took first at a corner, so it lost nearly all its blocks and the curve broke off. Such steep segments split no xz cells with the segments beside them.
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
Where a curve turned at a point without handles, the cross section of
//bcleft a gap outside the corner, and inside it the cross sections of the two segments overlapped. When the curve climbed or fell around the corner, the two overlapping cross sections were at different heights, so both stayed and crossed each other. On slopes, the bottom row also got an extra block wherever the curve climbed into the next block within one xz cell (the blocks at one x and z, at any height).addonly prepares the segments, andblockslays them all together: row by row from the middle outwards (the lower first of two as far), and in each row column by column from the middle outwards, each column along every segment in order before the next. The first block laid on a block is kept. Where the curve climbs or falls within an xz cell, the blocks the rows share go to the rows nearest the middle, so with three rows or more the top and bottom rows keep one block each. Steep slopes stay connected, and the block the curve starts in is laid.HashMapand returned unsorted; the order does not change what WorldEdit places.0 1 2 / 1 1 2 / 2 2 2)How it was tested
./gradlew build checkCodeStyle :curvebuilding-fabric:26.3:runGameTest: the build, the unit tests and the game tests on 26.3 pass, with no Checkstyle warnings. IntelliJ's inspections report nothing in the changed files.CurveLayoutTest: the inside and the outside of a turn, a turn that goes down, two segments going on the same way, a steep part between corners, a curve passing over itself, top and bottom rows up a slope, a steep slope staying connected from its start, and-areading each block once.//bcwith these changes.Notes
//bcplaces at corners without handles, on slopes and where the curve passes over itself. Straight curves and gentle curves with one or two rows are laid as before.