|
32 | 32 | import com.sk89q.worldedit.function.operation.RunContext;
|
33 | 33 | import com.sk89q.worldedit.internal.expression.Expression;
|
34 | 34 | import com.sk89q.worldedit.internal.expression.ExpressionException;
|
| 35 | +import com.sk89q.worldedit.internal.util.TransformUtil; |
35 | 36 | import com.sk89q.worldedit.math.Vector3;
|
36 |
| -import com.sk89q.worldedit.math.transform.Identity; |
37 |
| -import com.sk89q.worldedit.math.transform.SimpleTransform; |
38 | 37 | import com.sk89q.worldedit.math.transform.Transform;
|
39 | 38 | import com.sk89q.worldedit.regions.NullRegion;
|
40 | 39 | import com.sk89q.worldedit.regions.Region;
|
@@ -123,37 +122,10 @@ public String toString() {
|
123 | 122 | public Operation createFromContext(final EditContext context) {
|
124 | 123 |
|
125 | 124 | Region region = firstNonNull(context.getRegion(), this.region);
|
| 125 | + final Vector3 min = region.getMinimumPoint().toVector3(); |
| 126 | + final Vector3 max = region.getMaximumPoint().toVector3(); |
126 | 127 |
|
127 |
| - final Transform transform; |
128 |
| - switch (mode) { |
129 |
| - case UNIT_CUBE: |
130 |
| - final Vector3 min = region.getMinimumPoint().toVector3(); |
131 |
| - final Vector3 max = region.getMaximumPoint().toVector3(); |
132 |
| - final Vector3 zero = max.add(min).multiply(0.5); |
133 |
| - Vector3 unit = max.subtract(zero); |
134 |
| - |
135 |
| - if (unit.x() == 0) { |
136 |
| - unit = unit.withX(1.0); |
137 |
| - } |
138 |
| - if (unit.y() == 0) { |
139 |
| - unit = unit.withY(1.0); |
140 |
| - } |
141 |
| - if (unit.z() == 0) { |
142 |
| - unit = unit.withZ(1.0); |
143 |
| - } |
144 |
| - |
145 |
| - transform = new SimpleTransform(zero, unit); |
146 |
| - break; |
147 |
| - |
148 |
| - case RAW_COORD: |
149 |
| - transform = new Identity(); |
150 |
| - break; |
151 |
| - |
152 |
| - case OFFSET: |
153 |
| - default: |
154 |
| - transform = new SimpleTransform(offset, Vector3.ONE); |
155 |
| - break; |
156 |
| - } |
| 128 | + final Transform transform = TransformUtil.createTransformForExpressionCommand(mode, min, max, offset); |
157 | 129 | LocalSession session = context.getSession();
|
158 | 130 | return new DeformOperation(context.getDestination(), region, transform, expression,
|
159 | 131 | session == null ? WorldEdit.getInstance().getConfiguration().calculationTimeout : session.getTimeout());
|
|
0 commit comments