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 clipboard support to //deform and //brush deform #2276

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

TomyLobo
Copy link
Collaborator

@TomyLobo TomyLobo commented Mar 8, 2023

This adds a -l flag to //deform and //brush deform which, when used, will fetch blocks from the clipboard instead of the world.
Additionally, coordinate transformations that would normally be based on the selection position+size are based on the clipboard's position+size when using that mode.

Example usage:
image
The shape on the right is the result of copying the square shape on the left and deforming the selection with the command on screen.

image
This is the following brush using the same clipboard contents as before:
//brush deform -l sphere 6 x=-x;y=0;z=-z

Addresses parts of #1554

@TomyLobo TomyLobo force-pushed the deform-clipboard branch 2 times, most recently from d7499d1 to 7077c74 Compare March 8, 2023 04:35
@codecov
Copy link

codecov bot commented Mar 8, 2023

Codecov Report

Merging #2276 (6116518) into master (acc4b59) will increase coverage by 0.02%.
The diff coverage is 6.93%.

❗ Current head 6116518 differs from pull request most recent head 7f88a3e. Consider uploading reports for the commit 7f88a3e to get more accurate results

@@             Coverage Diff             @@
##             master   #2276      +/-   ##
===========================================
+ Coverage      8.68%   8.71%   +0.02%     
- Complexity     1041    1044       +3     
===========================================
  Files           881     883       +2     
  Lines         46291   46370      +79     
  Branches       5160    5158       -2     
===========================================
+ Hits           4022    4042      +20     
- Misses        42087   42144      +57     
- Partials        182     184       +2     
Impacted Files Coverage Δ
...src/main/java/com/sk89q/worldedit/EditSession.java 0.77% <0.00%> (-0.01%) ⬇️
...rc/main/java/com/sk89q/worldedit/LocalSession.java 0.00% <0.00%> (ø)
...ava/com/sk89q/worldedit/command/BrushCommands.java 3.68% <0.00%> (-0.13%) ⬇️
...a/com/sk89q/worldedit/command/GeneralCommands.java 8.67% <0.00%> (-0.28%) ⬇️
...om/sk89q/worldedit/command/GenerationCommands.java 3.30% <0.00%> (ø)
...va/com/sk89q/worldedit/command/RegionCommands.java 1.20% <0.00%> (-0.05%) ⬇️
...a/com/sk89q/worldedit/function/factory/Deform.java 0.00% <0.00%> (ø)
...k89q/worldedit/math/transform/SimpleTransform.java 0.00% <0.00%> (ø)
.../regions/shape/WorldEditExpressionEnvironment.java 0.00% <0.00%> (ø)
...in/java/com/sk89q/worldedit/session/Placement.java 0.00% <0.00%> (ø)
... and 3 more

... and 4 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

this(destination, region, expression, mode, false);
}

public Deform(Extent destination, Region region, String expression, Mode mode, boolean useClipboard) {
Copy link
Member

Choose a reason for hiding this comment

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

I sort of feel a sourceExtent & sourceRegion would be more useful here as something to pass in rather than useClipboard. Would also allow deform brushes to "bake in" the clipboard so you can have multiple different ones

Copy link
Collaborator Author

@TomyLobo TomyLobo Mar 16, 2023

Choose a reason for hiding this comment

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

Sorry, I only just saw your comment.
We'd have to offer both, because some people would want the current clipboard, some wouldn't.
The -o flag also needs to offer both static and dynamic modes.
That'd probably a separate PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

baking in is the default for most things and should probably be consistent for ux. (see clipboard brush, #sel vs #dsel masks, etc)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok I wasn't aware //brush clipboard already baked in the clipboard.
I use brushes so rarely :)
guess I'll have to bake that in before merging it then

Copy link
Collaborator Author

@TomyLobo TomyLobo Mar 19, 2023

Choose a reason for hiding this comment

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

-o, on the other hand, is not so simple.

  1. Do we read placement type at //brush time or at click time?
  2. Do we read pos1 at //brush time or at click time?
  3. Do we read the clipboard at //brush time or at click time?
  4. Do we read player position at //brush time or at click time?

  1. Probably at //brush time
  2. That'd be the difference between #sel and #dsel, so we'd probably want to offer both
  3. We said we want to bake it in at //brush time, but if we offer both in 2., offering both here as well actually saves code
  4. EDIT: If the player wants this fixed to certain position, they can use pos1. I also added a here placement mode in my other PR to have a static variant of player. Given that, we'd probably want to always use the dynamic position here, right?

@TomyLobo
Copy link
Collaborator Author

rebased

@TomyLobo TomyLobo force-pushed the deform-clipboard branch 2 times, most recently from 39257c9 to bb880d3 Compare March 23, 2023 02:43
@TomyLobo
Copy link
Collaborator Author

rebased this on top of most of the //placement PR in order to be able to use the new Placement system for the Deform brush.
Also marked as draft because the Current code is a WIP

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.

None yet

3 participants