mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-01-06 12:16:11 +08:00
Added Transform.inverse() as a standard operation.
This commit is contained in:
parent
a74bab7f98
commit
63411b427a
@ -21,8 +21,10 @@
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -60,6 +62,15 @@ public Vector apply(Vector vector) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transform inverse() {
|
||||
List<Transform> list = new ArrayList<Transform>();
|
||||
for (int i = transforms.length - 1; i >= 0; i--) {
|
||||
list.add(transforms[i].inverse());
|
||||
}
|
||||
return new CombinedTransform(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transform combine(Transform other) {
|
||||
checkNotNull(other);
|
||||
|
@ -31,6 +31,11 @@ public Vector apply(Vector vector) {
|
||||
return vector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transform inverse() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transform combine(Transform other) {
|
||||
if (other instanceof Identity) {
|
||||
|
@ -27,6 +27,13 @@
|
||||
*/
|
||||
public interface Transform extends Function<Vector, Vector> {
|
||||
|
||||
/**
|
||||
* Create a new inverse transform.
|
||||
*
|
||||
* @return a new inverse transform
|
||||
*/
|
||||
Transform inverse();
|
||||
|
||||
/**
|
||||
* Create a new {@link Transform} that combines this transform with another.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user