Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add settings to rotate/mirror schematics #4452

Merged

Conversation

ZacSharp
Copy link
Collaborator

@ZacSharp ZacSharp commented Aug 1, 2024

Closes #3711


@Override
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return mirror(schematic.desiredState(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this flips the schematic in memory each time you call desiredState, I feel as though this could get really laggy on large schematics. Can we instead mirror it once in the constructor?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because the underlying schematic might have changed since the last call. We can only do this for static schematics, which most of our schematics are not (at least not reliably), and even then we might end up wasting memory by copying a sparse schematic into a dense array.
Also I think baking things in the wrapper schematic itself is actually a bad idea in most cases, because it forces the result to be static while we actually want it to be static iff it wraps a static schematic. Baking should be done separately from constructing the transformed schematic (i.e. schematic = new BakedSchematic(schematic)).

IIRC mirroring block states is fairly fast (cache lookup) so the potentially laggy part here is transforming up to 36 states from approxPlaceable. Given that we know how BuilderProcess uses desiredState we could commit a caching crime here (reuse last transformed if last untransformed == new untransformed, assuming the input wasn't mutated).


@Override
public BlockState desiredState(int x, int y, int z, BlockState current, List<BlockState> approxPlaceable) {
return rotate(schematic.desiredState(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@leijurv leijurv merged commit d25d6c2 into cabaletta:1.19.4 Sep 16, 2024
3 of 4 checks passed
This was referenced Oct 20, 2024
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.

Ability to rotate schematics / copied selections
2 participants