-
-
Notifications
You must be signed in to change notification settings - Fork 927
Add clipboard support to //deform #2276
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8943abd
Rename offset arguments on //deform, //generate and //generatebiome t…
TomyLobo 04588fe
More accurate comments
TomyLobo 484d4b5
Give some variables more appropriate names
TomyLobo a209a7f
Add ScaleAndTranslateTransform class
TomyLobo dbd49be
Use ScaleAndTranslateTransform in WorldEditExpressionEnvironment
TomyLobo 8a93e84
Use ScaleAndTranslateTransform in everything using WorldEditExpressio…
TomyLobo bbb851e
Add inputExtent parameter and separate in/outputTransform for deformR…
TomyLobo 46b171c
Add clipboard support to //deform
TomyLobo effacee
Remove deprecated internal methods
TomyLobo ac647cb
Adjust JavaDoc to make it not seem specific to //deform
TomyLobo a9bad34
Add @deprecated links to newly @Deprecated methods
TomyLobo 320514f
Add JavaDoc to EditSession#makeBiomeShape
TomyLobo 7cba16e
Update worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape…
me4502 41ad1ff
Fix compile errors
me4502 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
172 changes: 151 additions & 21 deletions
172
worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
97 changes: 97 additions & 0 deletions
97
worldedit-core/src/main/java/com/sk89q/worldedit/internal/util/TransformUtil.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * WorldEdit, a Minecraft world manipulation toolkit | ||
| * Copyright (C) sk89q <http://www.sk89q.com> | ||
| * Copyright (C) WorldEdit team and contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.sk89q.worldedit.internal.util; | ||
|
|
||
| import com.sk89q.worldedit.IncompleteRegionException; | ||
| import com.sk89q.worldedit.LocalSession; | ||
| import com.sk89q.worldedit.extension.platform.Actor; | ||
| import com.sk89q.worldedit.math.Vector3; | ||
| import com.sk89q.worldedit.math.transform.Identity; | ||
| import com.sk89q.worldedit.math.transform.ScaleAndTranslateTransform; | ||
| import com.sk89q.worldedit.math.transform.Transform; | ||
| import com.sk89q.worldedit.regions.Region; | ||
|
|
||
| /** | ||
| * Various internal utility methods related to {@link Transform}s. | ||
| */ | ||
| public final class TransformUtil { | ||
|
|
||
| private TransformUtil() { | ||
| } | ||
|
|
||
| /** | ||
| * Creates a {@link Transform} for various expression commands. | ||
| * | ||
| * @param actor Actor that ran the command | ||
| * @param session Session that the command was run in | ||
| * @param region Selection that the command was run in | ||
| * @param useRawCoords Use the game's coordinate origin | ||
| * @param offsetPlacement Use the placement's coordinate origin | ||
| * @param offsetCenter Use the selection's center as origin | ||
| * @return A transform from the expression coordinate system to the raw coordinate system | ||
| */ | ||
| public static Transform createTransformForExpressionCommand(Actor actor, LocalSession session, Region region, boolean useRawCoords, boolean offsetPlacement, boolean offsetCenter) throws IncompleteRegionException { | ||
| final Vector3 placement = session.getPlacementPosition(actor).toVector3(); | ||
| final Vector3 min = region.getMinimumPoint().toVector3(); | ||
| final Vector3 max = region.getMaximumPoint().toVector3(); | ||
|
|
||
| return createTransformForExpressionCommand(useRawCoords, offsetPlacement, offsetCenter, min, max, placement); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a {@link Transform} for various expression commands from raw min/max/placement values. | ||
| * | ||
| * @param useRawCoords Use the game's coordinate origin | ||
| * @param offsetPlacement Use the placement's coordinate origin | ||
| * @param offsetCenter Use the selection's center as origin | ||
| * @param min Minimum of the selection/clipboard | ||
| * @param max Maximum of the selection/clipboard | ||
| * @param placement Placement position | ||
| * @return A transform from the expression coordinate system to the world/clipboard coordinate system | ||
| */ | ||
| public static Transform createTransformForExpressionCommand(boolean useRawCoords, boolean offsetPlacement, boolean offsetCenter, Vector3 min, Vector3 max, Vector3 placement) { | ||
| if (useRawCoords) { | ||
| return new Identity(); | ||
| } | ||
|
|
||
| if (offsetPlacement) { | ||
| return new ScaleAndTranslateTransform(placement, Vector3.ONE); | ||
| } | ||
|
|
||
| final Vector3 center = max.add(min).multiply(0.5); | ||
|
|
||
| if (offsetCenter) { | ||
| return new ScaleAndTranslateTransform(center, Vector3.ONE); | ||
| } | ||
|
|
||
| Vector3 scale = max.subtract(center); | ||
|
|
||
| if (scale.x() == 0) { | ||
| scale = scale.withX(1.0); | ||
| } | ||
| if (scale.y() == 0) { | ||
| scale = scale.withY(1.0); | ||
| } | ||
| if (scale.z() == 0) { | ||
| scale = scale.withZ(1.0); | ||
| } | ||
| return new ScaleAndTranslateTransform(center, scale); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.