Skip to content

Commit

Permalink
//brush deform: Add inputExtent parameter and separate in/outputTrans…
Browse files Browse the repository at this point in the history
…form for deformRegion
  • Loading branch information
TomyLobo committed Jul 17, 2024
1 parent fd02aec commit 29cb59e
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.InputExtent;
import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.function.Contextual;
import com.sk89q.worldedit.function.EditContext;
Expand Down Expand Up @@ -127,23 +128,26 @@ public Operation createFromContext(final EditContext context) {

final Transform transform = TransformUtil.createTransformForExpressionCommand(mode, min, max, offset);
LocalSession session = context.getSession();
EditSession editSession = (EditSession) context.getDestination();
return new DeformOperation(context.getDestination(), region, transform, expression,
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout(), editSession.getWorld(), transform);
}

private record DeformOperation(
Extent destination,
Region region,
Transform transform,
Transform outputTransform,
Expression expression,
int timeout
int timeout,
InputExtent inputExtent,
Transform inputTransform
) implements Operation {
@Override
public Operation resume(RunContext run) throws WorldEditException {
try {
// TODO: Move deformation code
final EditSession editSession = (EditSession) destination;
editSession.deformRegion(region, transform, expression, timeout, editSession.getWorld(), transform);
editSession.deformRegion(region, outputTransform, expression, timeout, inputExtent, inputTransform);
return null;
} catch (ExpressionException e) {
throw new RuntimeException("Failed to execute expression", e); // TODO: Better exception to throw here?
Expand Down

0 comments on commit 29cb59e

Please sign in to comment.