mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 04:46:40 +00:00
Refactor vector system to be cleaner
- Move Vector, etc. into `.math` package - Drop many methods that will be auto-promoted anyways, eg. with `divide(int)` and `divide(double)` the first is now gone. - Take Block vectors into their own class hierarchy - Make it clear throughout the API what takes blockvectors - many more improvements
This commit is contained in:
@ -19,10 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.iterator.RegionIterator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
@ -42,8 +41,8 @@ public abstract class AbstractRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getCenter() {
|
||||
return getMinimumPoint().add(getMaximumPoint()).divide(2);
|
||||
public Vector3 getCenter() {
|
||||
return getMinimumPoint().add(getMaximumPoint()).toVector3().divide(2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +51,7 @@ public abstract class AbstractRegion implements Region {
|
||||
* @return iterator of points inside the region
|
||||
*/
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return new RegionIterator(this);
|
||||
}
|
||||
|
||||
@ -67,7 +66,7 @@ public abstract class AbstractRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
expand(change);
|
||||
contract(change);
|
||||
}
|
||||
@ -82,20 +81,20 @@ public abstract class AbstractRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> polygonize(int maxPoints) {
|
||||
public List<BlockVector2> polygonize(int maxPoints) {
|
||||
if (maxPoints >= 0 && maxPoints < 4) {
|
||||
throw new IllegalArgumentException("Cannot polygonize an AbstractRegion with no overridden polygonize method into less than 4 points.");
|
||||
}
|
||||
|
||||
final BlockVector min = getMinimumPoint().toBlockVector();
|
||||
final BlockVector max = getMaximumPoint().toBlockVector();
|
||||
final BlockVector3 min = getMinimumPoint();
|
||||
final BlockVector3 max = getMaximumPoint();
|
||||
|
||||
final List<BlockVector2D> points = new ArrayList<>(4);
|
||||
final List<BlockVector2> points = new ArrayList<>(4);
|
||||
|
||||
points.add(new BlockVector2D(min.getX(), min.getZ()));
|
||||
points.add(new BlockVector2D(min.getX(), max.getZ()));
|
||||
points.add(new BlockVector2D(max.getX(), max.getZ()));
|
||||
points.add(new BlockVector2D(max.getX(), min.getZ()));
|
||||
points.add(new BlockVector2(min.getX(), min.getZ()));
|
||||
points.add(new BlockVector2(min.getX(), max.getZ()));
|
||||
points.add(new BlockVector2(max.getX(), max.getZ()));
|
||||
points.add(new BlockVector2(max.getX(), min.getZ()));
|
||||
|
||||
return points;
|
||||
}
|
||||
@ -107,12 +106,12 @@ public abstract class AbstractRegion implements Region {
|
||||
*/
|
||||
@Override
|
||||
public int getArea() {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
return (int)((max.getX() - min.getX() + 1) *
|
||||
(max.getY() - min.getY() + 1) *
|
||||
(max.getZ() - min.getZ() + 1));
|
||||
return (max.getX() - min.getX() + 1) *
|
||||
(max.getY() - min.getY() + 1) *
|
||||
(max.getZ() - min.getZ() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,10 +121,10 @@ public abstract class AbstractRegion implements Region {
|
||||
*/
|
||||
@Override
|
||||
public int getWidth() {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
return (int) (max.getX() - min.getX() + 1);
|
||||
return max.getX() - min.getX() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,10 +134,10 @@ public abstract class AbstractRegion implements Region {
|
||||
*/
|
||||
@Override
|
||||
public int getHeight() {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
return (int) (max.getY() - min.getY() + 1);
|
||||
return max.getY() - min.getY() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,10 +147,10 @@ public abstract class AbstractRegion implements Region {
|
||||
*/
|
||||
@Override
|
||||
public int getLength() {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
return (int) (max.getZ() - min.getZ() + 1);
|
||||
return max.getZ() - min.getZ() + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -160,21 +159,21 @@ public abstract class AbstractRegion implements Region {
|
||||
* @return a set of chunks
|
||||
*/
|
||||
@Override
|
||||
public Set<Vector2D> getChunks() {
|
||||
final Set<Vector2D> chunks = new HashSet<>();
|
||||
public Set<BlockVector2> getChunks() {
|
||||
final Set<BlockVector2> chunks = new HashSet<>();
|
||||
|
||||
final Vector min = getMinimumPoint();
|
||||
final Vector max = getMaximumPoint();
|
||||
final BlockVector3 min = getMinimumPoint();
|
||||
final BlockVector3 max = getMaximumPoint();
|
||||
|
||||
final int minY = min.getBlockY();
|
||||
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||
if (!contains(new Vector(x, minY, z))) {
|
||||
if (!contains(new BlockVector3(x, minY, z))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chunks.add(new BlockVector2D(
|
||||
chunks.add(new BlockVector2(
|
||||
x >> ChunkStore.CHUNK_SHIFTS,
|
||||
z >> ChunkStore.CHUNK_SHIFTS
|
||||
));
|
||||
@ -185,20 +184,20 @@ public abstract class AbstractRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Vector> getChunkCubes() {
|
||||
final Set<Vector> chunks = new HashSet<>();
|
||||
public Set<BlockVector3> getChunkCubes() {
|
||||
final Set<BlockVector3> chunks = new HashSet<>();
|
||||
|
||||
final Vector min = getMinimumPoint();
|
||||
final Vector max = getMaximumPoint();
|
||||
final BlockVector3 min = getMinimumPoint();
|
||||
final BlockVector3 max = getMaximumPoint();
|
||||
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||
if (!contains(new Vector(x, y, z))) {
|
||||
if (!contains(new BlockVector3(x, y, z))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chunks.add(new BlockVector(
|
||||
chunks.add(new BlockVector3(
|
||||
x >> ChunkStore.CHUNK_SHIFTS,
|
||||
y >> ChunkStore.CHUNK_SHIFTS,
|
||||
z >> ChunkStore.CHUNK_SHIFTS
|
||||
|
@ -21,7 +21,8 @@ package com.sk89q.worldedit.regions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.polyhedron.Edge;
|
||||
import com.sk89q.worldedit.regions.polyhedron.Triangle;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -40,7 +41,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
/**
|
||||
* Vertices that are contained in the convex hull.
|
||||
*/
|
||||
private final Set<Vector> vertices = new LinkedHashSet<>();
|
||||
private final Set<BlockVector3> vertices = new LinkedHashSet<>();
|
||||
|
||||
/**
|
||||
* Triangles that form the convex hull.
|
||||
@ -50,25 +51,25 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
/**
|
||||
* Vertices that are coplanar to the first 3 vertices.
|
||||
*/
|
||||
private final Set<Vector> vertexBacklog = new LinkedHashSet<>();
|
||||
private final Set<BlockVector3> vertexBacklog = new LinkedHashSet<>();
|
||||
|
||||
/**
|
||||
* Minimum point of the axis-aligned bounding box.
|
||||
*/
|
||||
private Vector minimumPoint;
|
||||
private BlockVector3 minimumPoint;
|
||||
|
||||
/**
|
||||
* Maximum point of the axis-aligned bounding box.
|
||||
*/
|
||||
private Vector maximumPoint;
|
||||
private BlockVector3 maximumPoint;
|
||||
|
||||
/**
|
||||
* Accumulator for the barycenter of the polyhedron. Divide by vertices.size() to get the actual center.
|
||||
*/
|
||||
private Vector centerAccum = Vector.ZERO;
|
||||
private BlockVector3 centerAccum = BlockVector3.ZERO;
|
||||
|
||||
/**
|
||||
* The last triangle that caused a {@link #contains(Vector)} to classify a point as "outside". Used for optimization.
|
||||
* The last triangle that caused a {@link #contains(Vector3)} to classify a point as "outside". Used for optimization.
|
||||
*/
|
||||
private Triangle lastTriangle;
|
||||
|
||||
@ -108,7 +109,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
|
||||
minimumPoint = null;
|
||||
maximumPoint = null;
|
||||
centerAccum = Vector.ZERO;
|
||||
centerAccum = BlockVector3.ZERO;
|
||||
lastTriangle = null;
|
||||
}
|
||||
|
||||
@ -118,7 +119,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
* @param vertex the vertex
|
||||
* @return true, if something changed.
|
||||
*/
|
||||
public boolean addVertex(Vector vertex) {
|
||||
public boolean addVertex(BlockVector3 vertex) {
|
||||
checkNotNull(vertex);
|
||||
|
||||
lastTriangle = null; // Probably not necessary
|
||||
@ -132,7 +133,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (containsRaw(vertex)) {
|
||||
if (containsRaw(vertex.toVector3())) {
|
||||
return vertexBacklog.add(vertex);
|
||||
}
|
||||
}
|
||||
@ -144,8 +145,8 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
if (minimumPoint == null) {
|
||||
minimumPoint = maximumPoint = vertex;
|
||||
} else {
|
||||
minimumPoint = Vector.getMinimum(minimumPoint, vertex);
|
||||
maximumPoint = Vector.getMaximum(maximumPoint, vertex);
|
||||
minimumPoint = minimumPoint.getMinimum(vertex);
|
||||
maximumPoint = maximumPoint.getMaximum(vertex);
|
||||
}
|
||||
|
||||
|
||||
@ -158,10 +159,10 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
|
||||
case 3:
|
||||
// Generate minimal mesh to start from
|
||||
final Vector[] v = vertices.toArray(new Vector[vertices.size()]);
|
||||
final BlockVector3[] v = vertices.toArray(new BlockVector3[vertices.size()]);
|
||||
|
||||
triangles.add((new Triangle(v[0], v[1], v[2])));
|
||||
triangles.add((new Triangle(v[0], v[2], v[1])));
|
||||
triangles.add((new Triangle(v[0].toVector3(), v[1].toVector3(), v[2].toVector3())));
|
||||
triangles.add((new Triangle(v[0].toVector3(), v[2].toVector3(), v[1].toVector3())));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -171,7 +172,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
final Triangle triangle = it.next();
|
||||
|
||||
// If the triangle can't be seen, it's not relevant
|
||||
if (!triangle.above(vertex)) {
|
||||
if (!triangle.above(vertex.toVector3())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -191,7 +192,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
|
||||
// Add triangles between the remembered edges and the new vertex.
|
||||
for (Edge edge : borderEdges) {
|
||||
triangles.add(edge.createTriangle(vertex));
|
||||
triangles.add(edge.createTriangle(vertex.toVector3()));
|
||||
}
|
||||
|
||||
if (!vertexBacklog.isEmpty()) {
|
||||
@ -199,9 +200,9 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
vertices.remove(vertex);
|
||||
|
||||
// Clone, clear and work through the backlog
|
||||
final List<Vector> vertexBacklog2 = new ArrayList<>(vertexBacklog);
|
||||
final List<BlockVector3> vertexBacklog2 = new ArrayList<>(vertexBacklog);
|
||||
vertexBacklog.clear();
|
||||
for (Vector vertex2 : vertexBacklog2) {
|
||||
for (BlockVector3 vertex2 : vertexBacklog2) {
|
||||
addVertex(vertex2);
|
||||
}
|
||||
|
||||
@ -217,39 +218,40 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return minimumPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return maximumPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getCenter() {
|
||||
return centerAccum.divide(vertices.size());
|
||||
public Vector3 getCenter() {
|
||||
return centerAccum.toVector3().divide(vertices.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
Vector3 vec = change.toVector3();
|
||||
shiftCollection(vertices, change);
|
||||
shiftCollection(vertexBacklog, change);
|
||||
|
||||
for (int i = 0; i < triangles.size(); ++i) {
|
||||
final Triangle triangle = triangles.get(i);
|
||||
|
||||
final Vector v0 = change.add(triangle.getVertex(0));
|
||||
final Vector v1 = change.add(triangle.getVertex(1));
|
||||
final Vector v2 = change.add(triangle.getVertex(2));
|
||||
final Vector3 v0 = vec.add(triangle.getVertex(0));
|
||||
final Vector3 v1 = vec.add(triangle.getVertex(1));
|
||||
final Vector3 v2 = vec.add(triangle.getVertex(2));
|
||||
|
||||
triangles.set(i, new Triangle(v0, v1, v2));
|
||||
}
|
||||
@ -260,16 +262,16 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
lastTriangle = null;
|
||||
}
|
||||
|
||||
private static void shiftCollection(Collection<Vector> collection, Vector change) {
|
||||
final List<Vector> tmp = new ArrayList<>(collection);
|
||||
private static void shiftCollection(Collection<BlockVector3> collection, BlockVector3 change) {
|
||||
final List<BlockVector3> tmp = new ArrayList<>(collection);
|
||||
collection.clear();
|
||||
for (Vector vertex : tmp) {
|
||||
for (BlockVector3 vertex : tmp) {
|
||||
collection.add(change.add(vertex));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
if (!isDefined()) {
|
||||
return false;
|
||||
}
|
||||
@ -278,8 +280,8 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
final int y = position.getBlockY();
|
||||
final int z = position.getBlockZ();
|
||||
|
||||
final Vector min = getMinimumPoint();
|
||||
final Vector max = getMaximumPoint();
|
||||
final BlockVector3 min = getMinimumPoint();
|
||||
final BlockVector3 max = getMaximumPoint();
|
||||
|
||||
if (x < min.getBlockX()) return false;
|
||||
if (x > max.getBlockX()) return false;
|
||||
@ -288,10 +290,10 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
if (z < min.getBlockZ()) return false;
|
||||
if (z > max.getBlockZ()) return false;
|
||||
|
||||
return containsRaw(position);
|
||||
return containsRaw(position.toVector3());
|
||||
}
|
||||
|
||||
private boolean containsRaw(Vector pt) {
|
||||
private boolean containsRaw(Vector3 pt) {
|
||||
if (lastTriangle != null && lastTriangle.above(pt)) {
|
||||
return false;
|
||||
}
|
||||
@ -310,12 +312,12 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Collection<Vector> getVertices() {
|
||||
public Collection<BlockVector3> getVertices() {
|
||||
if (vertexBacklog.isEmpty()) {
|
||||
return vertices;
|
||||
}
|
||||
|
||||
final List<Vector> ret = new ArrayList<>(vertices);
|
||||
final List<BlockVector3> ret = new ArrayList<>(vertices);
|
||||
ret.addAll(vertexBacklog);
|
||||
|
||||
return ret;
|
||||
|
@ -22,15 +22,14 @@ package com.sk89q.worldedit.regions;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -38,8 +37,8 @@ import java.util.Set;
|
||||
*/
|
||||
public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
private Vector pos1;
|
||||
private Vector pos2;
|
||||
private BlockVector3 pos1;
|
||||
private BlockVector3 pos2;
|
||||
|
||||
/**
|
||||
* Construct a new instance of this cuboid using two corners of the cuboid.
|
||||
@ -47,7 +46,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param pos1 the first position
|
||||
* @param pos2 the second position
|
||||
*/
|
||||
public CuboidRegion(Vector pos1, Vector pos2) {
|
||||
public CuboidRegion(BlockVector3 pos1, BlockVector3 pos2) {
|
||||
this(null, pos1, pos2);
|
||||
}
|
||||
|
||||
@ -58,7 +57,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param pos1 the first position
|
||||
* @param pos2 the second position
|
||||
*/
|
||||
public CuboidRegion(World world, Vector pos1, Vector pos2) {
|
||||
public CuboidRegion(World world, BlockVector3 pos1, BlockVector3 pos2) {
|
||||
super(world);
|
||||
checkNotNull(pos1);
|
||||
checkNotNull(pos2);
|
||||
@ -72,7 +71,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @return a position
|
||||
*/
|
||||
public Vector getPos1() {
|
||||
public BlockVector3 getPos1() {
|
||||
return pos1;
|
||||
}
|
||||
|
||||
@ -81,7 +80,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @param pos1 a position
|
||||
*/
|
||||
public void setPos1(Vector pos1) {
|
||||
public void setPos1(BlockVector3 pos1) {
|
||||
this.pos1 = pos1;
|
||||
}
|
||||
|
||||
@ -90,7 +89,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @return a position
|
||||
*/
|
||||
public Vector getPos2() {
|
||||
public BlockVector3 getPos2() {
|
||||
return pos2;
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @param pos2 a position
|
||||
*/
|
||||
public void setPos2(Vector pos2) {
|
||||
public void setPos2(BlockVector3 pos2) {
|
||||
this.pos2 = pos2;
|
||||
}
|
||||
|
||||
@ -117,21 +116,21 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
* @return a new complex region
|
||||
*/
|
||||
public Region getFaces() {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
return new RegionIntersection(
|
||||
// Project to Z-Y plane
|
||||
new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())),
|
||||
new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())),
|
||||
new CuboidRegion(pos1.withX(min.getX()), pos2.withX(min.getX())),
|
||||
new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())),
|
||||
|
||||
// Project to X-Y plane
|
||||
new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())),
|
||||
new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())),
|
||||
new CuboidRegion(pos1.withZ(min.getZ()), pos2.withZ(min.getZ())),
|
||||
new CuboidRegion(pos1.withZ(max.getZ()), pos2.withZ(max.getZ())),
|
||||
|
||||
// Project to the X-Z plane
|
||||
new CuboidRegion(pos1.setY(min.getY()), pos2.setY(min.getY())),
|
||||
new CuboidRegion(pos1.setY(max.getY()), pos2.setY(max.getY())));
|
||||
new CuboidRegion(pos1.withY(min.getY()), pos2.withY(min.getY())),
|
||||
new CuboidRegion(pos1.withY(max.getY()), pos2.withY(max.getY())));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,31 +140,27 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
* @return a new complex region
|
||||
*/
|
||||
public Region getWalls() {
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
return new RegionIntersection(
|
||||
// Project to Z-Y plane
|
||||
new CuboidRegion(pos1.setX(min.getX()), pos2.setX(min.getX())),
|
||||
new CuboidRegion(pos1.setX(max.getX()), pos2.setX(max.getX())),
|
||||
new CuboidRegion(pos1.withX(min.getX()), pos2.withX(min.getX())),
|
||||
new CuboidRegion(pos1.withX(max.getX()), pos2.withX(max.getX())),
|
||||
|
||||
// Project to X-Y plane
|
||||
new CuboidRegion(pos1.setZ(min.getZ()), pos2.setZ(min.getZ())),
|
||||
new CuboidRegion(pos1.setZ(max.getZ()), pos2.setZ(max.getZ())));
|
||||
new CuboidRegion(pos1.withZ(min.getZ()), pos2.withZ(min.getZ())),
|
||||
new CuboidRegion(pos1.withZ(max.getZ()), pos2.withZ(max.getZ())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return new Vector(Math.min(pos1.getX(), pos2.getX()),
|
||||
Math.min(pos1.getY(), pos2.getY()),
|
||||
Math.min(pos1.getZ(), pos2.getZ()));
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return pos1.getMinimum(pos2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return new Vector(Math.max(pos1.getX(), pos2.getX()),
|
||||
Math.max(pos1.getY(), pos2.getY()),
|
||||
Math.max(pos1.getZ(), pos2.getZ()));
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return pos1.getMaximum(pos2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -179,49 +174,49 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) {
|
||||
public void expand(BlockVector3... changes) {
|
||||
checkNotNull(changes);
|
||||
|
||||
for (Vector change : changes) {
|
||||
for (BlockVector3 change : changes) {
|
||||
if (change.getX() > 0) {
|
||||
if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
pos1 = pos1.add(change.getX(), 0, 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
pos2 = pos2.add(change.getX(), 0, 0);
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
pos1 = pos1.add(change.getX(), 0, 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
pos2 = pos2.add(change.getX(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getY() > 0) {
|
||||
if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
pos1 = pos1.add(0, change.getY(), 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
pos2 = pos2.add(0, change.getY(), 0);
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
pos1 = pos1.add(0, change.getY(), 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
pos2 = pos2.add(0, change.getY(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getZ() > 0) {
|
||||
if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
pos1 = pos1.add(0, 0, change.getZ());
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
pos2 = pos2.add(0, 0, change.getZ());
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
pos1 = pos1.add(0, 0, change.getZ());
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
pos2 = pos2.add(0, 0, change.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -230,49 +225,49 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) {
|
||||
public void contract(BlockVector3... changes) {
|
||||
checkNotNull(changes);
|
||||
|
||||
for (Vector change : changes) {
|
||||
for (BlockVector3 change : changes) {
|
||||
if (change.getX() < 0) {
|
||||
if (Math.max(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
pos1 = pos1.add(change.getX(), 0, 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
pos2 = pos2.add(change.getX(), 0, 0);
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getX(), pos2.getX()) == pos1.getX()) {
|
||||
pos1 = pos1.add(new Vector(change.getX(), 0, 0));
|
||||
pos1 = pos1.add(change.getX(), 0, 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(change.getX(), 0, 0));
|
||||
pos2 = pos2.add(change.getX(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getY() < 0) {
|
||||
if (Math.max(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
pos1 = pos1.add(0, change.getY(), 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
pos2 = pos2.add(0, change.getY(), 0);
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getY(), pos2.getY()) == pos1.getY()) {
|
||||
pos1 = pos1.add(new Vector(0, change.getY(), 0));
|
||||
pos1 = pos1.add(0, change.getY(), 0);
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, change.getY(), 0));
|
||||
pos2 = pos2.add(0, change.getY(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (change.getZ() < 0) {
|
||||
if (Math.max(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
pos1 = pos1.add(0, 0, change.getZ());
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
pos2 = pos2.add(0, 0, change.getZ());
|
||||
}
|
||||
} else {
|
||||
if (Math.min(pos1.getZ(), pos2.getZ()) == pos1.getZ()) {
|
||||
pos1 = pos1.add(new Vector(0, 0, change.getZ()));
|
||||
pos1 = pos1.add(0, 0, change.getZ());
|
||||
} else {
|
||||
pos2 = pos2.add(new Vector(0, 0, change.getZ()));
|
||||
pos2 = pos2.add(0, 0, change.getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -281,7 +276,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
pos1 = pos1.add(change);
|
||||
pos2 = pos2.add(change);
|
||||
|
||||
@ -289,15 +284,15 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Vector2D> getChunks() {
|
||||
Set<Vector2D> chunks = new HashSet<>();
|
||||
public Set<BlockVector2> getChunks() {
|
||||
Set<BlockVector2> chunks = new HashSet<>();
|
||||
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) {
|
||||
for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) {
|
||||
chunks.add(new BlockVector2D(x, z));
|
||||
chunks.add(new BlockVector2(x, z));
|
||||
}
|
||||
}
|
||||
|
||||
@ -305,16 +300,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Vector> getChunkCubes() {
|
||||
Set<Vector> chunks = new HashSet<>();
|
||||
public Set<BlockVector3> getChunkCubes() {
|
||||
Set<BlockVector3> chunks = new HashSet<>();
|
||||
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) {
|
||||
for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) {
|
||||
for (int y = min.getBlockY() >> ChunkStore.CHUNK_SHIFTS; y <= max.getBlockY() >> ChunkStore.CHUNK_SHIFTS; ++y) {
|
||||
chunks.add(new BlockVector(x, y, z));
|
||||
chunks.add(new BlockVector3(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -323,24 +318,18 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
int x = position.getBlockX();
|
||||
int y = position.getBlockY();
|
||||
int z = position.getBlockZ();
|
||||
public boolean contains(BlockVector3 position) {
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
|
||||
Vector min = getMinimumPoint();
|
||||
Vector max = getMaximumPoint();
|
||||
|
||||
return x >= min.getBlockX() && x <= max.getBlockX()
|
||||
&& y >= min.getBlockY() && y <= max.getBlockY()
|
||||
&& z >= min.getBlockZ() && z <= max.getBlockZ();
|
||||
return position.containedWithin(min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
return new Iterator<BlockVector>() {
|
||||
private Vector min = getMinimumPoint();
|
||||
private Vector max = getMaximumPoint();
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return new Iterator<BlockVector3>() {
|
||||
private BlockVector3 min = getMinimumPoint();
|
||||
private BlockVector3 max = getMaximumPoint();
|
||||
private int nextX = min.getBlockX();
|
||||
private int nextY = min.getBlockY();
|
||||
private int nextZ = min.getBlockZ();
|
||||
@ -351,9 +340,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector next() {
|
||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||
BlockVector answer = new BlockVector(nextX, nextY, nextZ);
|
||||
public BlockVector3 next() {
|
||||
if (!hasNext()) throw new NoSuchElementException();
|
||||
BlockVector3 answer = new BlockVector3(nextX, nextY, nextZ);
|
||||
if (++nextX > max.getBlockX()) {
|
||||
nextX = min.getBlockX();
|
||||
if (++nextY > max.getBlockY()) {
|
||||
@ -365,19 +354,14 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Vector2D> asFlatRegion() {
|
||||
return () -> new Iterator<Vector2D>() {
|
||||
private Vector min = getMinimumPoint();
|
||||
private Vector max = getMaximumPoint();
|
||||
public Iterable<BlockVector2> asFlatRegion() {
|
||||
return () -> new Iterator<BlockVector2>() {
|
||||
private BlockVector3 min = getMinimumPoint();
|
||||
private BlockVector3 max = getMaximumPoint();
|
||||
private int nextX = min.getBlockX();
|
||||
private int nextZ = min.getBlockZ();
|
||||
|
||||
@ -387,9 +371,9 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2D next() {
|
||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||
Vector2D answer = new Vector2D(nextX, nextZ);
|
||||
public BlockVector2 next() {
|
||||
if (!hasNext()) throw new NoSuchElementException();
|
||||
BlockVector2 answer = new BlockVector2(nextX, nextZ);
|
||||
if (++nextX > max.getBlockX()) {
|
||||
nextX = min.getBlockX();
|
||||
if (++nextZ > max.getBlockZ()) {
|
||||
@ -398,11 +382,6 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -435,10 +414,10 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param apothem the apothem, where 0 is the minimum value to make a 1x1 cuboid
|
||||
* @return a cuboid region
|
||||
*/
|
||||
public static CuboidRegion fromCenter(Vector origin, int apothem) {
|
||||
public static CuboidRegion fromCenter(BlockVector3 origin, int apothem) {
|
||||
checkNotNull(origin);
|
||||
checkArgument(apothem >= 0, "apothem => 0 required");
|
||||
Vector size = new Vector(1, 1, 1).multiply(apothem);
|
||||
BlockVector3 size = BlockVector3.ONE.multiply(apothem);
|
||||
return new CuboidRegion(origin.subtract(size), origin.add(size));
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ package com.sk89q.worldedit.regions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.geom.Polygons;
|
||||
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
|
||||
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
|
||||
@ -39,8 +39,8 @@ import java.util.List;
|
||||
*/
|
||||
public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
private Vector2D center;
|
||||
private Vector2D radius;
|
||||
private BlockVector2 center;
|
||||
private Vector2 radius;
|
||||
private int minY;
|
||||
private int maxY;
|
||||
private boolean hasY = false;
|
||||
@ -58,7 +58,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param world the world
|
||||
*/
|
||||
public CylinderRegion(World world) {
|
||||
this(world, new Vector(), new Vector2D(), 0, 0);
|
||||
this(world, BlockVector3.ZERO, Vector2.ZERO, 0, 0);
|
||||
hasY = false;
|
||||
}
|
||||
|
||||
@ -71,9 +71,9 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param minY the minimum Y, inclusive
|
||||
* @param maxY the maximum Y, inclusive
|
||||
*/
|
||||
public CylinderRegion(World world, Vector center, Vector2D radius, int minY, int maxY) {
|
||||
public CylinderRegion(World world, BlockVector3 center, Vector2 radius, int minY, int maxY) {
|
||||
super(world);
|
||||
setCenter(center.toVector2D());
|
||||
setCenter(center.toBlockVector2());
|
||||
setRadius(radius);
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
@ -88,9 +88,9 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param minY the minimum Y, inclusive
|
||||
* @param maxY the maximum Y, inclusive
|
||||
*/
|
||||
public CylinderRegion(Vector center, Vector2D radius, int minY, int maxY) {
|
||||
public CylinderRegion(BlockVector3 center, Vector2 radius, int minY, int maxY) {
|
||||
super(null);
|
||||
setCenter(center.toVector2D());
|
||||
setCenter(center.toBlockVector2());
|
||||
setRadius(radius);
|
||||
this.minY = minY;
|
||||
this.maxY = maxY;
|
||||
@ -98,13 +98,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
public CylinderRegion(CylinderRegion region) {
|
||||
this(region.world, region.getCenter(), region.getRadius(), region.minY, region.maxY);
|
||||
this(region.world, region.getCenter().toBlockPoint(), region.getRadius(), region.minY, region.maxY);
|
||||
hasY = region.hasY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getCenter() {
|
||||
return center.toVector((maxY + minY) / 2);
|
||||
public Vector3 getCenter() {
|
||||
return center.toVector3((maxY + minY) / 2);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -112,7 +112,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @param center the center point
|
||||
*/
|
||||
public void setCenter(Vector2D center) {
|
||||
public void setCenter(BlockVector2 center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @return the radius along the X and Z axes
|
||||
*/
|
||||
public Vector2D getRadius() {
|
||||
public Vector2 getRadius() {
|
||||
return radius.subtract(0.5, 0.5);
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @param radius the radius along the X and Z axes
|
||||
*/
|
||||
public void setRadius(Vector2D radius) {
|
||||
public void setRadius(Vector2 radius) {
|
||||
this.radius = radius.add(0.5, 0.5);
|
||||
}
|
||||
|
||||
@ -139,8 +139,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @param minRadius the minimum radius
|
||||
*/
|
||||
public void extendRadius(Vector2D minRadius) {
|
||||
setRadius(Vector2D.getMaximum(minRadius, getRadius()));
|
||||
public void extendRadius(Vector2 minRadius) {
|
||||
setRadius(minRadius.getMaximum(getRadius()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,13 +164,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return center.subtract(getRadius()).toVector(minY);
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return center.toVector2().subtract(getRadius()).toVector3(minY).toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return center.add(getRadius()).toVector(maxY);
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return center.toVector2().add(getRadius()).toVector3(maxY).toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -203,10 +203,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
return (int) (2 * radius.getZ());
|
||||
}
|
||||
|
||||
private Vector2D calculateDiff2D(Vector... changes) throws RegionOperationException {
|
||||
Vector2D diff = new Vector2D();
|
||||
for (Vector change : changes) {
|
||||
diff = diff.add(change.toVector2D());
|
||||
private BlockVector2 calculateDiff2D(BlockVector3... changes) throws RegionOperationException {
|
||||
BlockVector2 diff = BlockVector2.ZERO;
|
||||
for (BlockVector3 change : changes) {
|
||||
diff = diff.add(change.toBlockVector2());
|
||||
}
|
||||
|
||||
if ((diff.getBlockX() & 1) + (diff.getBlockZ() & 1) != 0) {
|
||||
@ -216,10 +216,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
return diff.divide(2).floor();
|
||||
}
|
||||
|
||||
private Vector2D calculateChanges2D(Vector... changes) {
|
||||
Vector2D total = new Vector2D();
|
||||
for (Vector change : changes) {
|
||||
total = total.add(change.toVector2D().positive());
|
||||
private BlockVector2 calculateChanges2D(BlockVector3... changes) {
|
||||
BlockVector2 total = BlockVector2.ZERO;
|
||||
for (BlockVector3 change : changes) {
|
||||
total = total.add(change.toBlockVector2().abs());
|
||||
}
|
||||
|
||||
return total.divide(2).floor();
|
||||
@ -233,10 +233,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
* @throws RegionOperationException
|
||||
*/
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
center = center.add(calculateDiff2D(changes));
|
||||
radius = radius.add(calculateChanges2D(changes));
|
||||
for (Vector change : changes) {
|
||||
radius = radius.add(calculateChanges2D(changes).toVector2());
|
||||
for (BlockVector3 change : changes) {
|
||||
int changeY = change.getBlockY();
|
||||
if (changeY > 0) {
|
||||
maxY += changeY;
|
||||
@ -253,11 +253,11 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
* @throws RegionOperationException
|
||||
*/
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
center = center.subtract(calculateDiff2D(changes));
|
||||
Vector2D newRadius = radius.subtract(calculateChanges2D(changes));
|
||||
radius = Vector2D.getMaximum(new Vector2D(1.5, 1.5), newRadius);
|
||||
for (Vector change : changes) {
|
||||
Vector2 newRadius = radius.subtract(calculateChanges2D(changes).toVector2());
|
||||
radius = new Vector2(1.5, 1.5).getMaximum(newRadius);
|
||||
for (BlockVector3 change : changes) {
|
||||
int height = maxY - minY;
|
||||
int changeY = change.getBlockY();
|
||||
if (changeY > 0) {
|
||||
@ -269,8 +269,8 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
center = center.add(change.toVector2D());
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
center = center.add(change.toBlockVector2());
|
||||
|
||||
int changeY = change.getBlockY();
|
||||
maxY += changeY;
|
||||
@ -281,13 +281,13 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
* Checks to see if a point is inside this region.
|
||||
*/
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
final int blockY = position.getBlockY();
|
||||
if (blockY < minY || blockY > maxY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return position.toVector2D().subtract(center).divide(radius).lengthSq() <= 1;
|
||||
return position.toBlockVector2().subtract(center).toVector2().divide(radius).lengthSq() <= 1;
|
||||
}
|
||||
|
||||
|
||||
@ -315,12 +315,12 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return new FlatRegion3DIterator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Vector2D> asFlatRegion() {
|
||||
public Iterable<BlockVector2> asFlatRegion() {
|
||||
return () -> new FlatRegionIterator(CylinderRegion.this);
|
||||
}
|
||||
|
||||
@ -341,7 +341,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> polygonize(int maxPoints) {
|
||||
public List<BlockVector2> polygonize(int maxPoints) {
|
||||
return Polygons.polygonizeCylinder(center, radius, maxPoints);
|
||||
}
|
||||
|
||||
@ -355,10 +355,10 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param radius the radius in the X and Z axes
|
||||
* @return a region
|
||||
*/
|
||||
public static CylinderRegion createRadius(Extent extent, Vector center, double radius) {
|
||||
public static CylinderRegion createRadius(Extent extent, BlockVector3 center, double radius) {
|
||||
checkNotNull(extent);
|
||||
checkNotNull(center);
|
||||
Vector2D radiusVec = new Vector2D(radius, radius);
|
||||
Vector2 radiusVec = new Vector2(radius, radius);
|
||||
int minY = extent.getMinimumPoint().getBlockY();
|
||||
int maxY = extent.getMaximumPoint().getBlockY();
|
||||
return new CylinderRegion(center, radiusVec, minY, maxY);
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
@ -37,12 +36,12 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
/**
|
||||
* Stores the center.
|
||||
*/
|
||||
private Vector center;
|
||||
private BlockVector3 center;
|
||||
|
||||
/**
|
||||
* Stores the radii plus 0.5 on each axis.
|
||||
*/
|
||||
private Vector radius;
|
||||
private Vector3 radius;
|
||||
|
||||
/**
|
||||
* Construct a new instance of this ellipsoid region.
|
||||
@ -50,7 +49,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
* @param pos1 the first position
|
||||
* @param pos2 the second position
|
||||
*/
|
||||
public EllipsoidRegion(Vector pos1, Vector pos2) {
|
||||
public EllipsoidRegion(BlockVector3 pos1, Vector3 pos2) {
|
||||
this(null, pos1, pos2);
|
||||
}
|
||||
|
||||
@ -61,7 +60,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
* @param center the center
|
||||
* @param radius the radius
|
||||
*/
|
||||
public EllipsoidRegion(World world, Vector center, Vector radius) {
|
||||
public EllipsoidRegion(World world, BlockVector3 center, Vector3 radius) {
|
||||
super(world);
|
||||
this.center = center;
|
||||
setRadius(radius);
|
||||
@ -72,13 +71,13 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return center.subtract(getRadius());
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return center.toVector3().subtract(getRadius()).toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return center.add(getRadius());
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return center.toVector3().add(getRadius()).toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -101,8 +100,8 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
return (int) (2 * radius.getZ());
|
||||
}
|
||||
|
||||
private Vector calculateDiff(Vector... changes) throws RegionOperationException {
|
||||
Vector diff = new Vector().add(changes);
|
||||
private BlockVector3 calculateDiff(BlockVector3... changes) throws RegionOperationException {
|
||||
BlockVector3 diff = BlockVector3.ZERO.add(changes);
|
||||
|
||||
if ((diff.getBlockX() & 1) + (diff.getBlockY() & 1) + (diff.getBlockZ() & 1) != 0) {
|
||||
throw new RegionOperationException(
|
||||
@ -112,30 +111,30 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
return diff.divide(2).floor();
|
||||
}
|
||||
|
||||
private Vector calculateChanges(Vector... changes) {
|
||||
Vector total = new Vector();
|
||||
for (Vector change : changes) {
|
||||
total = total.add(change.positive());
|
||||
private Vector3 calculateChanges(BlockVector3... changes) {
|
||||
Vector3 total = Vector3.ZERO;
|
||||
for (BlockVector3 change : changes) {
|
||||
total = total.add(change.abs().toVector3());
|
||||
}
|
||||
|
||||
return total.divide(2).floor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
center = center.add(calculateDiff(changes));
|
||||
radius = radius.add(calculateChanges(changes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
center = center.subtract(calculateDiff(changes));
|
||||
Vector newRadius = radius.subtract(calculateChanges(changes));
|
||||
radius = Vector.getMaximum(new Vector(1.5, 1.5, 1.5), newRadius);
|
||||
Vector3 newRadius = radius.subtract(calculateChanges(changes));
|
||||
radius = new Vector3(1.5, 1.5, 1.5).getMaximum(newRadius);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
center = center.add(change);
|
||||
}
|
||||
|
||||
@ -145,8 +144,8 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
* @return center
|
||||
*/
|
||||
@Override
|
||||
public Vector getCenter() {
|
||||
return center;
|
||||
public Vector3 getCenter() {
|
||||
return center.toVector3();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,7 +153,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
*
|
||||
* @param center the center
|
||||
*/
|
||||
public void setCenter(Vector center) {
|
||||
public void setCenter(BlockVector3 center) {
|
||||
this.center = center;
|
||||
}
|
||||
|
||||
@ -163,7 +162,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
*
|
||||
* @return radii
|
||||
*/
|
||||
public Vector getRadius() {
|
||||
public Vector3 getRadius() {
|
||||
return radius.subtract(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
@ -172,25 +171,25 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
*
|
||||
* @param radius the radius
|
||||
*/
|
||||
public void setRadius(Vector radius) {
|
||||
public void setRadius(Vector3 radius) {
|
||||
this.radius = radius.add(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Vector2D> getChunks() {
|
||||
final Set<Vector2D> chunks = new HashSet<>();
|
||||
public Set<BlockVector2> getChunks() {
|
||||
final Set<BlockVector2> chunks = new HashSet<>();
|
||||
|
||||
final Vector min = getMinimumPoint();
|
||||
final Vector max = getMaximumPoint();
|
||||
final int centerY = getCenter().getBlockY();
|
||||
final BlockVector3 min = getMinimumPoint();
|
||||
final BlockVector3 max = getMaximumPoint();
|
||||
final int centerY = center.getBlockY();
|
||||
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||
if (!contains(new BlockVector(x, centerY, z))) {
|
||||
if (!contains(new BlockVector3(x, centerY, z))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chunks.add(new BlockVector2D(
|
||||
chunks.add(new BlockVector2(
|
||||
x >> ChunkStore.CHUNK_SHIFTS,
|
||||
z >> ChunkStore.CHUNK_SHIFTS
|
||||
));
|
||||
@ -201,8 +200,8 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
return position.subtract(center).divide(radius).lengthSq() <= 1;
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return position.subtract(center).toVector3().divide(radius).lengthSq() <= 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,8 +215,8 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
return center + " - " + getRadius();
|
||||
}
|
||||
|
||||
public void extendRadius(Vector minRadius) {
|
||||
setRadius(Vector.getMaximum(minRadius, getRadius()));
|
||||
public void extendRadius(Vector3 minRadius) {
|
||||
setRadius(minRadius.getMaximum(getRadius()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
|
||||
public interface FlatRegion extends Region {
|
||||
|
||||
@ -42,5 +42,5 @@ public interface FlatRegion extends Region {
|
||||
*
|
||||
* @return a flat region iterable
|
||||
*/
|
||||
Iterable<Vector2D> asFlatRegion();
|
||||
Iterable<BlockVector2> asFlatRegion();
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -39,18 +38,18 @@ public class NullRegion implements Region {
|
||||
private World world;
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return new Vector(0, 0, 0);
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return new Vector(0, 0, 0);
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return BlockVector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getCenter() {
|
||||
return new Vector(0, 0, 0);
|
||||
public Vector3 getCenter() {
|
||||
return Vector3.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -74,32 +73,32 @@ public class NullRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new RegionOperationException("Cannot change NullRegion");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new RegionOperationException("Cannot change NullRegion");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
throw new RegionOperationException("Cannot change NullRegion");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Vector2D> getChunks() {
|
||||
public Set<BlockVector2> getChunks() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Vector> getChunkCubes() {
|
||||
public Set<BlockVector3> getChunkCubes() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@ -119,27 +118,22 @@ public class NullRegion implements Region {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> polygonize(int maxPoints) {
|
||||
public List<BlockVector2> polygonize(int maxPoints) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
return new Iterator<BlockVector>() {
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return new Iterator<BlockVector3>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector next() {
|
||||
public BlockVector3 next() {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Cannot remove");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
|
||||
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -37,9 +36,9 @@ import java.util.List;
|
||||
*/
|
||||
public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
private List<BlockVector2D> points;
|
||||
private Vector2D min;
|
||||
private Vector2D max;
|
||||
private List<BlockVector2> points;
|
||||
private BlockVector2 min;
|
||||
private BlockVector2 max;
|
||||
private int minY;
|
||||
private int maxY;
|
||||
private boolean hasY = false;
|
||||
@ -57,7 +56,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param world the world
|
||||
*/
|
||||
public Polygonal2DRegion(World world) {
|
||||
this(world, Collections.<BlockVector2D>emptyList(), 0, 0);
|
||||
this(world, Collections.emptyList(), 0, 0);
|
||||
hasY = false;
|
||||
}
|
||||
|
||||
@ -69,7 +68,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param minY minimum Y
|
||||
* @param maxY maximum Y
|
||||
*/
|
||||
public Polygonal2DRegion(World world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
public Polygonal2DRegion(World world, List<BlockVector2> points, int minY, int maxY) {
|
||||
super(world);
|
||||
this.points = new ArrayList<>(points);
|
||||
this.minY = minY;
|
||||
@ -93,7 +92,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @return a list of points
|
||||
*/
|
||||
public List<BlockVector2D> getPoints() {
|
||||
public List<BlockVector2> getPoints() {
|
||||
return Collections.unmodifiableList(points);
|
||||
}
|
||||
|
||||
@ -103,9 +102,9 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
*/
|
||||
protected void recalculate() {
|
||||
if (points.isEmpty()) {
|
||||
min = new Vector2D(0, 0);
|
||||
min = BlockVector2.ZERO;
|
||||
minY = 0;
|
||||
max = new Vector2D(0, 0);
|
||||
max = BlockVector2.ZERO;
|
||||
maxY = 0;
|
||||
return;
|
||||
}
|
||||
@ -115,7 +114,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
int maxX = points.get(0).getBlockX();
|
||||
int maxZ = points.get(0).getBlockZ();
|
||||
|
||||
for (BlockVector2D v : points) {
|
||||
for (BlockVector2 v : points) {
|
||||
int x = v.getBlockX();
|
||||
int z = v.getBlockZ();
|
||||
if (x < minX) minX = x;
|
||||
@ -132,8 +131,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
minY = Math.min(Math.max(0, minY), world == null ? 255 : world.getMaxY());
|
||||
maxY = Math.min(Math.max(0, maxY), world == null ? 255 : world.getMaxY());
|
||||
|
||||
min = new Vector2D(minX, minZ);
|
||||
max = new Vector2D(maxX, maxZ);
|
||||
min = new BlockVector2(minX, minZ);
|
||||
max = new BlockVector2(maxX, maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,17 +140,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @param position the position
|
||||
*/
|
||||
public void addPoint(Vector2D position) {
|
||||
points.add(position.toBlockVector2D());
|
||||
recalculate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a point to the list.
|
||||
*
|
||||
* @param position the position
|
||||
*/
|
||||
public void addPoint(BlockVector2D position) {
|
||||
public void addPoint(BlockVector2 position) {
|
||||
points.add(position);
|
||||
recalculate();
|
||||
}
|
||||
@ -161,8 +150,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
*
|
||||
* @param position the position
|
||||
*/
|
||||
public void addPoint(Vector position) {
|
||||
points.add(new BlockVector2D(position.getBlockX(), position.getBlockZ()));
|
||||
public void addPoint(BlockVector3 position) {
|
||||
points.add(new BlockVector2(position.getBlockX(), position.getBlockZ()));
|
||||
recalculate();
|
||||
}
|
||||
|
||||
@ -199,13 +188,13 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return min.toVector(minY);
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return min.toBlockVector3(minY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return max.toVector(maxY);
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return max.toBlockVector3(maxY);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -239,14 +228,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
for (Vector change : changes) {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
for (BlockVector3 change : changes) {
|
||||
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
||||
throw new RegionOperationException("Polygons can only be expanded vertically.");
|
||||
}
|
||||
}
|
||||
|
||||
for (Vector change : changes) {
|
||||
int changeY = change.getBlockY();
|
||||
if (changeY > 0) {
|
||||
maxY += changeY;
|
||||
@ -258,14 +244,11 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
for (Vector change : changes) {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
for (BlockVector3 change : changes) {
|
||||
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
||||
throw new RegionOperationException("Polygons can only be contracted vertically.");
|
||||
}
|
||||
}
|
||||
|
||||
for (Vector change : changes) {
|
||||
int changeY = change.getBlockY();
|
||||
if (changeY > 0) {
|
||||
minY += changeY;
|
||||
@ -277,14 +260,14 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
final double changeX = change.getX();
|
||||
final double changeY = change.getY();
|
||||
final double changeZ = change.getZ();
|
||||
|
||||
for (int i = 0; i < points.size(); ++i) {
|
||||
BlockVector2D point = points.get(i);
|
||||
points.set(i, new BlockVector2D(point.getX() + changeX, point.getZ() + changeZ));
|
||||
BlockVector2 point = points.get(i);
|
||||
points.set(i, new BlockVector2(point.getX() + changeX, point.getZ() + changeZ));
|
||||
}
|
||||
|
||||
minY += changeY;
|
||||
@ -294,7 +277,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return contains(points, minY, maxY, position);
|
||||
}
|
||||
|
||||
@ -307,7 +290,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param pt the position to check
|
||||
* @return true if the given polygon contains the given point
|
||||
*/
|
||||
public static boolean contains(List<BlockVector2D> points, int minY, int maxY, Vector pt) {
|
||||
public static boolean contains(List<BlockVector2> points, int minY, int maxY, BlockVector3 pt) {
|
||||
if (points.size() < 3) {
|
||||
return false;
|
||||
}
|
||||
@ -398,12 +381,12 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
return new FlatRegion3DIterator(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Vector2D> asFlatRegion() {
|
||||
public Iterable<BlockVector2> asFlatRegion() {
|
||||
return () -> new FlatRegionIterator(Polygonal2DRegion.this);
|
||||
}
|
||||
|
||||
@ -416,10 +399,10 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<BlockVector2D> pts = getPoints();
|
||||
Iterator<BlockVector2D> it = pts.iterator();
|
||||
List<BlockVector2> pts = getPoints();
|
||||
Iterator<BlockVector2> it = pts.iterator();
|
||||
while (it.hasNext()) {
|
||||
BlockVector2D current = it.next();
|
||||
BlockVector2 current = it.next();
|
||||
sb.append("(").append(current.getBlockX()).append(", ").append(current.getBlockZ()).append(")");
|
||||
if (it.hasNext()) sb.append(" - ");
|
||||
}
|
||||
@ -435,7 +418,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> polygonize(int maxPoints) {
|
||||
public List<BlockVector2> polygonize(int maxPoints) {
|
||||
if (maxPoints >= 0 && maxPoints < points.size()) {
|
||||
throw new IllegalArgumentException("Cannot polygonize a this Polygonal2DRegion into the amount of points given.");
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,21 +32,21 @@ import javax.annotation.Nullable;
|
||||
/**
|
||||
* Represents a physical shape.
|
||||
*/
|
||||
public interface Region extends Iterable<BlockVector>, Cloneable {
|
||||
public interface Region extends Iterable<BlockVector3>, Cloneable {
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
Vector getMinimumPoint();
|
||||
BlockVector3 getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
Vector getMaximumPoint();
|
||||
BlockVector3 getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the center point of a region.
|
||||
@ -56,7 +55,7 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
|
||||
*
|
||||
* @return center point
|
||||
*/
|
||||
Vector getCenter();
|
||||
Vector3 getCenter();
|
||||
|
||||
/**
|
||||
* Get the number of blocks in the region.
|
||||
@ -92,7 +91,7 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
|
||||
* @param changes array/arguments with multiple related changes
|
||||
* @throws RegionOperationException
|
||||
*/
|
||||
void expand(Vector... changes) throws RegionOperationException;
|
||||
void expand(BlockVector3... changes) throws RegionOperationException;
|
||||
|
||||
/**
|
||||
* Contract the region.
|
||||
@ -100,7 +99,7 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
|
||||
* @param changes array/arguments with multiple related changes
|
||||
* @throws RegionOperationException
|
||||
*/
|
||||
void contract(Vector... changes) throws RegionOperationException;
|
||||
void contract(BlockVector3... changes) throws RegionOperationException;
|
||||
|
||||
/**
|
||||
* Shift the region.
|
||||
@ -108,7 +107,7 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
|
||||
* @param change the change
|
||||
* @throws RegionOperationException
|
||||
*/
|
||||
void shift(Vector change) throws RegionOperationException;
|
||||
void shift(BlockVector3 change) throws RegionOperationException;
|
||||
|
||||
/**
|
||||
* Returns true based on whether the region contains the point.
|
||||
@ -116,21 +115,21 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
|
||||
* @param position the position
|
||||
* @return true if contained
|
||||
*/
|
||||
boolean contains(Vector position);
|
||||
boolean contains(BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Get a list of chunks.
|
||||
*
|
||||
* @return a list of chunk coordinates
|
||||
*/
|
||||
Set<Vector2D> getChunks();
|
||||
Set<BlockVector2> getChunks();
|
||||
|
||||
/**
|
||||
* Return a list of 16*16*16 chunks in a region
|
||||
*
|
||||
* @return the chunk cubes this region overlaps with
|
||||
*/
|
||||
Set<Vector> getChunkCubes();
|
||||
Set<BlockVector3> getChunkCubes();
|
||||
|
||||
/**
|
||||
* Sets the world that the selection is in.
|
||||
@ -159,5 +158,5 @@ public interface Region extends Iterable<BlockVector>, Cloneable {
|
||||
* @param maxPoints maximum number of points to generate. -1 for no limit.
|
||||
* @return the points.
|
||||
*/
|
||||
List<BlockVector2D> polygonize(int maxPoints);
|
||||
List<BlockVector2> polygonize(int maxPoints);
|
||||
}
|
||||
|
@ -23,8 +23,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -90,37 +89,37 @@ public class RegionIntersection extends AbstractRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
Vector minimum = regions.get(0).getMinimumPoint();
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
BlockVector3 minimum = regions.get(0).getMinimumPoint();
|
||||
for (int i = 1; i < regions.size(); i++) {
|
||||
minimum = Vector.getMinimum(regions.get(i).getMinimumPoint(), minimum);
|
||||
minimum = regions.get(i).getMinimumPoint().getMinimum(minimum);
|
||||
}
|
||||
return minimum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
Vector maximum = regions.get(0).getMaximumPoint();
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
BlockVector3 maximum = regions.get(0).getMaximumPoint();
|
||||
for (int i = 1; i < regions.size(); i++) {
|
||||
maximum = Vector.getMaximum(regions.get(i).getMaximumPoint(), maximum);
|
||||
maximum = regions.get(i).getMaximumPoint().getMaximum(maximum);
|
||||
}
|
||||
return maximum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
checkNotNull(changes);
|
||||
throw new RegionOperationException("Cannot expand a region intersection");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
checkNotNull(changes);
|
||||
throw new RegionOperationException("Cannot contract a region intersection");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
public boolean contains(BlockVector3 position) {
|
||||
checkNotNull(position);
|
||||
|
||||
for (Region region : regions) {
|
||||
@ -134,8 +133,8 @@ public class RegionIntersection extends AbstractRegion {
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
Iterator<BlockVector>[] iterators = (Iterator<BlockVector>[]) new Iterator[regions.size()];
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
Iterator<BlockVector3>[] iterators = (Iterator<BlockVector3>[]) new Iterator[regions.size()];
|
||||
for (int i = 0; i < regions.size(); i++) {
|
||||
iterators[i] = regions.get(i).iterator();
|
||||
}
|
||||
|
@ -19,11 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
@ -59,7 +58,7 @@ public interface RegionSelector {
|
||||
* @param position the position
|
||||
* @return true if something changed
|
||||
*/
|
||||
boolean selectPrimary(Vector position, SelectorLimits limits);
|
||||
boolean selectPrimary(BlockVector3 position, SelectorLimits limits);
|
||||
|
||||
/**
|
||||
* Called when the second point is selected.
|
||||
@ -67,7 +66,7 @@ public interface RegionSelector {
|
||||
* @param position the position
|
||||
* @return true if something changed
|
||||
*/
|
||||
boolean selectSecondary(Vector position, SelectorLimits limits);
|
||||
boolean selectSecondary(BlockVector3 position, SelectorLimits limits);
|
||||
|
||||
/**
|
||||
* Tell the player information about his/her primary selection.
|
||||
@ -76,7 +75,7 @@ public interface RegionSelector {
|
||||
* @param session the session
|
||||
* @param position position
|
||||
*/
|
||||
void explainPrimarySelection(Actor actor, LocalSession session, Vector position);
|
||||
void explainPrimarySelection(Actor actor, LocalSession session, BlockVector3 position);
|
||||
|
||||
/**
|
||||
* Tell the player information about his/her secondary selection.
|
||||
@ -85,7 +84,7 @@ public interface RegionSelector {
|
||||
* @param session the session
|
||||
* @param position position
|
||||
*/
|
||||
void explainSecondarySelection(Actor actor, LocalSession session, Vector position);
|
||||
void explainSecondarySelection(Actor actor, LocalSession session, BlockVector3 position);
|
||||
|
||||
/**
|
||||
* The the player information about the region's changes. This may resend
|
||||
@ -102,7 +101,7 @@ public interface RegionSelector {
|
||||
* @return the primary position
|
||||
* @throws IncompleteRegionException thrown if a region has not been fully defined
|
||||
*/
|
||||
BlockVector getPrimaryPosition() throws IncompleteRegionException;
|
||||
BlockVector3 getPrimaryPosition() throws IncompleteRegionException;
|
||||
|
||||
/**
|
||||
* Get the selection.
|
||||
|
@ -21,9 +21,9 @@ package com.sk89q.worldedit.regions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -98,17 +98,17 @@ public class TransformRegion extends AbstractRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMinimumPoint() {
|
||||
return transform.apply(region.getMinimumPoint());
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
return transform.apply(region.getMinimumPoint().toVector3()).toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getMaximumPoint() {
|
||||
return transform.apply(region.getMaximumPoint());
|
||||
public BlockVector3 getMaximumPoint() {
|
||||
return transform.apply(region.getMaximumPoint().toVector3()).toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getCenter() {
|
||||
public Vector3 getCenter() {
|
||||
return transform.apply(region.getCenter());
|
||||
}
|
||||
|
||||
@ -133,50 +133,50 @@ public class TransformRegion extends AbstractRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expand(Vector... changes) throws RegionOperationException {
|
||||
public void expand(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new RegionOperationException("Can't expand a TransformedRegion");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contract(Vector... changes) throws RegionOperationException {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
throw new RegionOperationException("Can't contract a TransformedRegion");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shift(Vector change) throws RegionOperationException {
|
||||
public void shift(BlockVector3 change) throws RegionOperationException {
|
||||
throw new RegionOperationException("Can't change a TransformedRegion");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Vector position) {
|
||||
return region.contains(transform.inverse().apply(position));
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return region.contains(transform.inverse().apply(position.toVector3()).toBlockPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockVector2D> polygonize(int maxPoints) {
|
||||
List<BlockVector2D> origPoints = region.polygonize(maxPoints);
|
||||
List<BlockVector2D> transformedPoints = new ArrayList<>();
|
||||
for (BlockVector2D vector : origPoints) {
|
||||
transformedPoints.add(transform.apply(vector.toVector(0)).toVector2D().toBlockVector2D());
|
||||
public List<BlockVector2> polygonize(int maxPoints) {
|
||||
List<BlockVector2> origPoints = region.polygonize(maxPoints);
|
||||
List<BlockVector2> transformedPoints = new ArrayList<>();
|
||||
for (BlockVector2 vector : origPoints) {
|
||||
transformedPoints.add(transform.apply(vector.toVector3(0)).toVector2().toBlockPoint());
|
||||
}
|
||||
return transformedPoints;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<BlockVector> iterator() {
|
||||
final Iterator<BlockVector> it = region.iterator();
|
||||
public Iterator<BlockVector3> iterator() {
|
||||
final Iterator<BlockVector3> it = region.iterator();
|
||||
|
||||
return new Iterator<BlockVector>() {
|
||||
return new Iterator<BlockVector3>() {
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector next() {
|
||||
BlockVector next = it.next();
|
||||
public BlockVector3 next() {
|
||||
BlockVector3 next = it.next();
|
||||
if (next != null) {
|
||||
return transform.apply(next).toBlockVector();
|
||||
return transform.apply(next.toVector3()).toBlockPoint();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -19,14 +19,14 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.factory;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class CuboidRegionFactory implements RegionFactory {
|
||||
|
||||
@Override
|
||||
public Region createCenteredAt(Vector position, double size) {
|
||||
public Region createCenteredAt(BlockVector3 position, double size) {
|
||||
return CuboidRegion.fromCenter(position, (int) size);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.factory;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
@ -33,8 +33,8 @@ public class CylinderRegionFactory implements RegionFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region createCenteredAt(Vector position, double size) {
|
||||
return new CylinderRegion(position, new Vector2D(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2));
|
||||
public Region createCenteredAt(BlockVector3 position, double size) {
|
||||
return new CylinderRegion(position, new Vector2(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,11 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.factory;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public interface RegionFactory {
|
||||
|
||||
Region createCenteredAt(Vector position, double size);
|
||||
Region createCenteredAt(BlockVector3 position, double size);
|
||||
|
||||
}
|
||||
|
@ -19,15 +19,16 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.factory;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.EllipsoidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class SphereRegionFactory implements RegionFactory {
|
||||
|
||||
@Override
|
||||
public Region createCenteredAt(Vector position, double size) {
|
||||
return new EllipsoidRegion(position, new Vector(size, size, size));
|
||||
public Region createCenteredAt(BlockVector3 position, double size) {
|
||||
return new EllipsoidRegion(position, new Vector3(size, size, size));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,23 +21,23 @@ package com.sk89q.worldedit.regions.iterator;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class FlatRegion3DIterator implements Iterator<BlockVector> {
|
||||
public class FlatRegion3DIterator implements Iterator<BlockVector3> {
|
||||
|
||||
private Iterator<Vector2D> flatIterator;
|
||||
private Iterator<BlockVector2> flatIterator;
|
||||
private int minY;
|
||||
private int maxY;
|
||||
|
||||
private Vector2D next2D;
|
||||
private BlockVector2 next2D;
|
||||
private int nextY;
|
||||
|
||||
public FlatRegion3DIterator(FlatRegion region, Iterator<Vector2D> flatIterator) {
|
||||
public FlatRegion3DIterator(FlatRegion region, Iterator<BlockVector2> flatIterator) {
|
||||
checkNotNull(region);
|
||||
checkNotNull(flatIterator);
|
||||
|
||||
@ -63,12 +63,12 @@ public class FlatRegion3DIterator implements Iterator<BlockVector> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector next() {
|
||||
public BlockVector3 next() {
|
||||
if (!hasNext()) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
BlockVector current = new BlockVector(next2D.getBlockX(), nextY, next2D.getBlockZ());
|
||||
BlockVector3 current = new BlockVector3(next2D.getBlockX(), nextY, next2D.getBlockZ());
|
||||
if (nextY < maxY) {
|
||||
nextY++;
|
||||
} else if (flatIterator.hasNext()) {
|
||||
|
@ -21,13 +21,14 @@ package com.sk89q.worldedit.regions.iterator;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class FlatRegionIterator implements Iterator<Vector2D> {
|
||||
public class FlatRegionIterator implements Iterator<BlockVector2> {
|
||||
|
||||
private Region region;
|
||||
private int y;
|
||||
@ -42,8 +43,8 @@ public class FlatRegionIterator implements Iterator<Vector2D> {
|
||||
|
||||
this.region = region;
|
||||
|
||||
Vector min = region.getMinimumPoint();
|
||||
Vector max = region.getMaximumPoint();
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
this.y = min.getBlockY();
|
||||
|
||||
@ -64,18 +65,18 @@ public class FlatRegionIterator implements Iterator<Vector2D> {
|
||||
}
|
||||
|
||||
private void forward() {
|
||||
while (hasNext() && !region.contains(new Vector(nextX, y, nextZ))) {
|
||||
while (hasNext() && !region.contains(new BlockVector3(nextX, y, nextZ))) {
|
||||
forwardOne();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2D next() {
|
||||
public BlockVector2 next() {
|
||||
if (!hasNext()) {
|
||||
throw new java.util.NoSuchElementException();
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
Vector2D answer = new Vector2D(nextX, nextZ);
|
||||
BlockVector2 answer = new BlockVector2(nextX, nextZ);
|
||||
|
||||
forwardOne();
|
||||
forward();
|
||||
@ -95,9 +96,4 @@ public class FlatRegionIterator implements Iterator<Vector2D> {
|
||||
nextX = Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,19 +21,18 @@ package com.sk89q.worldedit.regions.iterator;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class RegionIterator implements Iterator<BlockVector> {
|
||||
public class RegionIterator implements Iterator<BlockVector3> {
|
||||
|
||||
private final Region region;
|
||||
private final int maxX;
|
||||
private final int maxY;
|
||||
private final int maxZ;
|
||||
private final Vector min;
|
||||
private final BlockVector3 min;
|
||||
private int nextX;
|
||||
private int nextY;
|
||||
private int nextZ;
|
||||
@ -43,7 +42,7 @@ public class RegionIterator implements Iterator<BlockVector> {
|
||||
|
||||
this.region = region;
|
||||
|
||||
Vector max = region.getMaximumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
this.maxX = max.getBlockX();
|
||||
this.maxY = max.getBlockY();
|
||||
this.maxZ = max.getBlockZ();
|
||||
@ -62,16 +61,16 @@ public class RegionIterator implements Iterator<BlockVector> {
|
||||
}
|
||||
|
||||
private void forward() {
|
||||
while (hasNext() && !region.contains(new BlockVector(nextX, nextY, nextZ))) {
|
||||
while (hasNext() && !region.contains(new BlockVector3(nextX, nextY, nextZ))) {
|
||||
forwardOne();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector next() {
|
||||
public BlockVector3 next() {
|
||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||
|
||||
BlockVector answer = new BlockVector(nextX, nextY, nextZ);
|
||||
BlockVector3 answer = new BlockVector3(nextX, nextY, nextZ);
|
||||
|
||||
forwardOne();
|
||||
forward();
|
||||
|
@ -21,14 +21,14 @@ package com.sk89q.worldedit.regions.polyhedron;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
public class Edge {
|
||||
|
||||
private final Vector start;
|
||||
private final Vector end;
|
||||
private final Vector3 start;
|
||||
private final Vector3 end;
|
||||
|
||||
public Edge(Vector start, Vector end) {
|
||||
public Edge(Vector3 start, Vector3 end) {
|
||||
checkNotNull(start);
|
||||
checkNotNull(end);
|
||||
|
||||
@ -71,7 +71,7 @@ public class Edge {
|
||||
* @param vertex the 3rd vertex for the triangle
|
||||
* @return a triangle
|
||||
*/
|
||||
public Triangle createTriangle(Vector vertex) {
|
||||
public Triangle createTriangle(Vector3 vertex) {
|
||||
checkNotNull(vertex);
|
||||
return new Triangle(this.start, this.end, vertex);
|
||||
}
|
||||
@ -82,7 +82,7 @@ public class Edge {
|
||||
* @param vertex the second vertex
|
||||
* @return a new triangle
|
||||
*/
|
||||
public Triangle createTriangle2(Vector vertex) {
|
||||
public Triangle createTriangle2(Vector3 vertex) {
|
||||
checkNotNull(vertex);
|
||||
return new Triangle(this.start, vertex, this.end);
|
||||
}
|
||||
|
@ -21,13 +21,13 @@ package com.sk89q.worldedit.regions.polyhedron;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
public class Triangle {
|
||||
|
||||
private String tag = "Triangle";
|
||||
private final Vector[] vertices;
|
||||
private final Vector normal;
|
||||
private final Vector3[] vertices;
|
||||
private final Vector3 normal;
|
||||
private final double b;
|
||||
|
||||
/**
|
||||
@ -37,12 +37,12 @@ public class Triangle {
|
||||
* @param v1 second vertex
|
||||
* @param v2 third vertex
|
||||
*/
|
||||
public Triangle(Vector v0, Vector v1, Vector v2) {
|
||||
public Triangle(Vector3 v0, Vector3 v1, Vector3 v2) {
|
||||
checkNotNull(v0);
|
||||
checkNotNull(v1);
|
||||
checkNotNull(v2);
|
||||
|
||||
vertices = new Vector[] { v0, v1, v2 };
|
||||
vertices = new Vector3[] { v0, v1, v2 };
|
||||
|
||||
this.normal = v1.subtract(v0).cross(v2.subtract(v0)).normalize();
|
||||
this.b = Math.max(Math.max(normal.dot(v0), normal.dot(v1)), normal.dot(v2));
|
||||
@ -54,7 +54,7 @@ public class Triangle {
|
||||
* @param index Vertex index. Valid input: 0..2
|
||||
* @return a vertex
|
||||
*/
|
||||
public Vector getVertex(int index) {
|
||||
public Vector3 getVertex(int index) {
|
||||
return vertices[index];
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ public class Triangle {
|
||||
* @param pt the point to test
|
||||
* @return true if the point is below
|
||||
*/
|
||||
public boolean below(Vector pt) {
|
||||
public boolean below(Vector3 pt) {
|
||||
checkNotNull(pt);
|
||||
return normal.dot(pt) < b;
|
||||
}
|
||||
@ -88,7 +88,7 @@ public class Triangle {
|
||||
* @param pt the point to test
|
||||
* @return true if the point is above
|
||||
*/
|
||||
public boolean above(Vector pt) {
|
||||
public boolean above(Vector3 pt) {
|
||||
checkNotNull(pt);
|
||||
return normal.dot(pt) > b;
|
||||
}
|
||||
|
@ -21,15 +21,14 @@ package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPolygonEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.ConvexPolyhedralRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
@ -52,7 +51,7 @@ import javax.annotation.Nullable;
|
||||
public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private final transient ConvexPolyhedralRegion region;
|
||||
private transient BlockVector pos1;
|
||||
private transient BlockVector3 pos1;
|
||||
|
||||
/**
|
||||
* Create a new selector with a {@code null} world.
|
||||
@ -97,9 +96,9 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
|
||||
region = new ConvexPolyhedralRegion(oldRegion.getWorld());
|
||||
|
||||
for (final BlockVector2D pt : new ArrayList<>(oldRegion.polygonize(Integer.MAX_VALUE))) {
|
||||
region.addVertex(pt.toVector(minY));
|
||||
region.addVertex(pt.toVector(maxY));
|
||||
for (final BlockVector2 pt : new ArrayList<>(oldRegion.polygonize(Integer.MAX_VALUE))) {
|
||||
region.addVertex(pt.toBlockVector3(minY));
|
||||
region.addVertex(pt.toBlockVector3(maxY));
|
||||
}
|
||||
|
||||
learnChanges();
|
||||
@ -118,15 +117,15 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
checkNotNull(position);
|
||||
clear();
|
||||
pos1 = position.toBlockVector();
|
||||
pos1 = position;
|
||||
return region.addVertex(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
checkNotNull(position);
|
||||
|
||||
Optional<Integer> vertexLimit = limits.getPolyhedronVertexLimit();
|
||||
@ -139,7 +138,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
|
||||
return pos1;
|
||||
}
|
||||
|
||||
@ -169,7 +168,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
pos1 = region.getVertices().iterator().next().toBlockVector();
|
||||
pos1 = region.getVertices().iterator().next();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -194,7 +193,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
checkNotNull(player);
|
||||
checkNotNull(session);
|
||||
checkNotNull(pos);
|
||||
@ -205,7 +204,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
checkNotNull(player);
|
||||
checkNotNull(session);
|
||||
checkNotNull(pos);
|
||||
@ -237,12 +236,12 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
checkNotNull(player);
|
||||
checkNotNull(session);
|
||||
|
||||
Collection<Vector> vertices = region.getVertices();
|
||||
Collection<BlockVector3> vertices = region.getVertices();
|
||||
Collection<Triangle> triangles = region.getTriangles();
|
||||
|
||||
Map<Vector, Integer> vertexIds = new HashMap<>(vertices.size());
|
||||
Map<BlockVector3, Integer> vertexIds = new HashMap<>(vertices.size());
|
||||
int lastVertexId = -1;
|
||||
for (Vector vertex : vertices) {
|
||||
for (BlockVector3 vertex : vertices) {
|
||||
vertexIds.put(vertex, ++lastVertexId);
|
||||
session.dispatchCUIEvent(player, new SelectionPointEvent(lastVertexId, vertex, getArea()));
|
||||
}
|
||||
@ -250,7 +249,7 @@ public class ConvexPolyhedralRegionSelector implements RegionSelector, CUIRegion
|
||||
for (Triangle triangle : triangles) {
|
||||
final int[] v = new int[3];
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
v[i] = vertexIds.get(triangle.getVertex(i));
|
||||
v[i] = vertexIds.get(triangle.getVertex(i).toBlockPoint());
|
||||
}
|
||||
session.dispatchCUIEvent(player, new SelectionPolygonEvent(v));
|
||||
}
|
||||
|
@ -21,13 +21,12 @@ package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
@ -44,8 +43,8 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected transient BlockVector position1;
|
||||
protected transient BlockVector position2;
|
||||
protected transient BlockVector3 position1;
|
||||
protected transient BlockVector3 position2;
|
||||
protected transient CuboidRegion region;
|
||||
|
||||
/**
|
||||
@ -61,7 +60,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
* @param world the world, which may be {@code null}
|
||||
*/
|
||||
public CuboidRegionSelector(@Nullable World world) {
|
||||
region = new CuboidRegion(world, new Vector(), new Vector());
|
||||
region = new CuboidRegion(world, BlockVector3.ZERO, BlockVector3.ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,8 +84,8 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return;
|
||||
}
|
||||
|
||||
position1 = oldRegion.getMinimumPoint().toBlockVector();
|
||||
position2 = oldRegion.getMaximumPoint().toBlockVector();
|
||||
position1 = oldRegion.getMinimumPoint();
|
||||
position2 = oldRegion.getMaximumPoint();
|
||||
}
|
||||
|
||||
region.setPos1(position1);
|
||||
@ -100,12 +99,12 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
* @param position1 position 1
|
||||
* @param position2 position 2
|
||||
*/
|
||||
public CuboidRegionSelector(@Nullable World world, Vector position1, Vector position2) {
|
||||
public CuboidRegionSelector(@Nullable World world, BlockVector3 position1, BlockVector3 position2) {
|
||||
this(world);
|
||||
checkNotNull(position1);
|
||||
checkNotNull(position2);
|
||||
this.position1 = position1.toBlockVector();
|
||||
this.position2 = position2.toBlockVector();
|
||||
this.position1 = position1;
|
||||
this.position2 = position2;
|
||||
region.setPos1(position1);
|
||||
region.setPos2(position2);
|
||||
}
|
||||
@ -122,33 +121,33 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
checkNotNull(position);
|
||||
|
||||
if (position1 != null && (position.compareTo(position1) == 0)) {
|
||||
if (position1 != null && position1.equals(position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
position1 = position.toBlockVector();
|
||||
position1 = position;
|
||||
region.setPos1(position1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
checkNotNull(position);
|
||||
|
||||
if (position2 != null && (position.compareTo(position2)) == 0) {
|
||||
if (position2 != null && position2.equals(position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
position2 = position.toBlockVector();
|
||||
position2 = position;
|
||||
region.setPos2(position2);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
checkNotNull(player);
|
||||
checkNotNull(session);
|
||||
checkNotNull(pos);
|
||||
@ -163,7 +162,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
checkNotNull(player);
|
||||
checkNotNull(session);
|
||||
checkNotNull(pos);
|
||||
@ -192,7 +191,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (position1 == null) {
|
||||
throw new IncompleteRegionException();
|
||||
}
|
||||
@ -221,8 +220,8 @@ public class CuboidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
position1 = region.getPos1().toBlockVector();
|
||||
position2 = region.getPos2().toBlockVector();
|
||||
position1 = region.getPos1();
|
||||
position2 = region.getPos2();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,16 +21,17 @@ package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionCylinderEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionMinMaxEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.CylinderRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
@ -92,12 +93,12 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
return;
|
||||
}
|
||||
|
||||
Vector pos1 = oldRegion.getMinimumPoint();
|
||||
Vector pos2 = oldRegion.getMaximumPoint();
|
||||
BlockVector3 pos1 = oldRegion.getMinimumPoint();
|
||||
BlockVector3 pos2 = oldRegion.getMaximumPoint();
|
||||
|
||||
Vector center = pos1.add(pos2).divide(2).floor();
|
||||
region.setCenter(center.toVector2D());
|
||||
region.setRadius(pos2.toVector2D().subtract(center.toVector2D()));
|
||||
BlockVector3 center = pos1.add(pos2).divide(2).floor();
|
||||
region.setCenter(center.toBlockVector2());
|
||||
region.setRadius(pos2.toBlockVector2().subtract(center.toBlockVector2()).toVector2());
|
||||
|
||||
region.setMaximumY(Math.max(pos1.getBlockY(), pos2.getBlockY()));
|
||||
region.setMinimumY(Math.min(pos1.getBlockY(), pos2.getBlockY()));
|
||||
@ -113,7 +114,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
* @param minY the minimum Y
|
||||
* @param maxY the maximum Y
|
||||
*/
|
||||
public CylinderRegionSelector(@Nullable World world, Vector2D center, Vector2D radius, int minY, int maxY) {
|
||||
public CylinderRegionSelector(@Nullable World world, BlockVector2 center, Vector2 radius, int minY, int maxY) {
|
||||
this(world);
|
||||
|
||||
region.setCenter(center);
|
||||
@ -135,27 +136,27 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector position, SelectorLimits limits) {
|
||||
if (!region.getCenter().equals(Vector.ZERO) && position.compareTo(region.getCenter()) == 0) {
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (!region.getCenter().equals(Vector3.ZERO) && position.equals(region.getCenter().toBlockPoint())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
region = new CylinderRegion(region.getWorld());
|
||||
region.setCenter(position.toVector2D());
|
||||
region.setCenter(position.toBlockVector2());
|
||||
region.setY(position.getBlockY());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
Vector center = region.getCenter();
|
||||
if ((center.compareTo(Vector.ZERO)) == 0) {
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
Vector3 center = region.getCenter();
|
||||
if (center.equals(Vector3.ZERO)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Vector2D diff = position.subtract(center).toVector2D();
|
||||
final Vector2D minRadius = Vector2D.getMaximum(diff, diff.multiply(-1.0));
|
||||
final Vector2 diff = position.toVector3().subtract(center).toVector2();
|
||||
final Vector2 minRadius = diff.getMaximum(diff.multiply(-1.0));
|
||||
region.extendRadius(minRadius);
|
||||
|
||||
region.setY(position.getBlockY());
|
||||
@ -164,17 +165,17 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Starting a new cylindrical selection at " + pos + ".");
|
||||
|
||||
session.describeCUI(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
Vector center = region.getCenter();
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
Vector3 center = region.getCenter();
|
||||
|
||||
if (!center.equals(Vector.ZERO)) {
|
||||
if (!center.equals(Vector3.ZERO)) {
|
||||
player.print("Radius set to " + NUMBER_FORMAT.format(region.getRadius().getX()) + "/" + NUMBER_FORMAT.format(region.getRadius().getZ()) + " blocks. (" + region.getArea() + ").");
|
||||
} else {
|
||||
player.printError("You must select the center point before setting the radius.");
|
||||
@ -190,12 +191,12 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (!isDefined()) {
|
||||
throw new IncompleteRegionException();
|
||||
}
|
||||
|
||||
return region.getCenter().toBlockVector();
|
||||
return region.getCenter().toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -214,7 +215,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return !region.getRadius().equals(Vector2D.ZERO);
|
||||
return !region.getRadius().equals(Vector2.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -235,10 +236,10 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
|
||||
if (!region.getCenter().equals(Vector.ZERO)) {
|
||||
if (!region.getCenter().equals(Vector3.ZERO)) {
|
||||
lines.add("Center: " + region.getCenter());
|
||||
}
|
||||
if (!region.getRadius().equals(Vector2D.ZERO)) {
|
||||
if (!region.getRadius().equals(Vector2.ZERO)) {
|
||||
lines.add("Radius: " + region.getRadius());
|
||||
}
|
||||
|
||||
@ -252,7 +253,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void describeCUI(LocalSession session, Actor player) {
|
||||
session.dispatchCUIEvent(player, new SelectionCylinderEvent(region.getCenter(), region.getRadius()));
|
||||
session.dispatchCUIEvent(player, new SelectionCylinderEvent(region.getCenter().toBlockPoint(), region.getRadius()));
|
||||
session.dispatchCUIEvent(player, new SelectionMinMaxEvent(region.getMinimumY(), region.getMaximumY()));
|
||||
}
|
||||
|
||||
|
@ -21,14 +21,14 @@ package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionEllipsoidPointEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPointEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.EllipsoidRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
@ -61,7 +61,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
* @param world the world, which may be {@code null}
|
||||
*/
|
||||
public EllipsoidRegionSelector(@Nullable World world) {
|
||||
region = new EllipsoidRegion(world, new Vector(), new Vector());
|
||||
region = new EllipsoidRegion(world, BlockVector3.ZERO, Vector3.ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,12 +83,12 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
return;
|
||||
}
|
||||
|
||||
BlockVector pos1 = oldRegion.getMinimumPoint().toBlockVector();
|
||||
BlockVector pos2 = oldRegion.getMaximumPoint().toBlockVector();
|
||||
BlockVector3 pos1 = oldRegion.getMinimumPoint();
|
||||
BlockVector3 pos2 = oldRegion.getMaximumPoint();
|
||||
|
||||
Vector center = pos1.add(pos2).divide(2).floor();
|
||||
BlockVector3 center = pos1.add(pos2).divide(2).floor();
|
||||
region.setCenter(center);
|
||||
region.setRadius(pos2.subtract(center));
|
||||
region.setRadius(pos2.subtract(center).toVector3());
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
* @param center the center
|
||||
* @param radius the radius
|
||||
*/
|
||||
public EllipsoidRegionSelector(@Nullable World world, Vector center, Vector radius) {
|
||||
public EllipsoidRegionSelector(@Nullable World world, BlockVector3 center, Vector3 radius) {
|
||||
this(world);
|
||||
|
||||
region.setCenter(center);
|
||||
@ -118,32 +118,32 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (position.equals(region.getCenter()) && region.getRadius().lengthSq() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
region.setCenter(position.toBlockVector());
|
||||
region.setRadius(new Vector());
|
||||
region.setCenter(position);
|
||||
region.setRadius(Vector3.ZERO);
|
||||
started = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (!started) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Vector diff = position.subtract(region.getCenter());
|
||||
final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0));
|
||||
final Vector3 diff = position.toVector3().subtract(region.getCenter());
|
||||
final Vector3 minRadius = diff.getMaximum(diff.multiply(-1.0));
|
||||
region.extendRadius(minRadius);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Center position set to " + region.getCenter() + " (" + region.getArea() + ").");
|
||||
} else {
|
||||
@ -154,7 +154,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Radius set to " + region.getRadius() + " (" + region.getArea() + ").");
|
||||
} else {
|
||||
@ -194,8 +194,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
region.setCenter(new Vector());
|
||||
region.setRadius(new Vector());
|
||||
region.setCenter(BlockVector3.ZERO);
|
||||
region.setRadius(Vector3.ZERO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -207,12 +207,12 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
public List<String> getInformationLines() {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
|
||||
final Vector center = region.getCenter();
|
||||
final Vector3 center = region.getCenter();
|
||||
if (center.lengthSq() > 0) {
|
||||
lines.add("Center: " + center);
|
||||
}
|
||||
|
||||
final Vector radius = region.getRadius();
|
||||
final Vector3 radius = region.getRadius();
|
||||
if (radius.lengthSq() > 0) {
|
||||
lines.add("X/Y/Z radius: " + radius);
|
||||
}
|
||||
@ -227,8 +227,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void describeCUI(LocalSession session, Actor player) {
|
||||
session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(0, region.getCenter()));
|
||||
session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(1, region.getRadius()));
|
||||
session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(0, region.getCenter().toBlockPoint()));
|
||||
session.dispatchCUIEvent(player, new SelectionEllipsoidPointEvent(1, region.getRadius().toBlockPoint()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -253,8 +253,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
return region.getCenter().toBlockVector();
|
||||
public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
|
||||
return region.getCenter().toBlockPoint();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -63,8 +62,8 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
return;
|
||||
}
|
||||
|
||||
position1 = region.getMinimumPoint().toBlockVector();
|
||||
position2 = region.getMaximumPoint().toBlockVector();
|
||||
position1 = region.getMinimumPoint();
|
||||
position2 = region.getMaximumPoint();
|
||||
region.setPos1(position1);
|
||||
region.setPos2(position2);
|
||||
}
|
||||
@ -76,28 +75,28 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
* @param position1 the first position
|
||||
* @param position2 the second position
|
||||
*/
|
||||
public ExtendingCuboidRegionSelector(@Nullable World world, Vector position1, Vector position2) {
|
||||
public ExtendingCuboidRegionSelector(@Nullable World world, BlockVector3 position1, BlockVector3 position2) {
|
||||
this(world);
|
||||
position1 = Vector.getMinimum(position1, position2);
|
||||
position2 = Vector.getMaximum(position1, position2);
|
||||
position1 = position1.getMinimum(position2);
|
||||
position2 = position1.getMaximum(position2);
|
||||
region.setPos1(position1);
|
||||
region.setPos2(position2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector position, SelectorLimits limits) {
|
||||
if (position1 != null && position2 != null && position.compareTo(position1) == 0 && position.compareTo(position2) == 0) {
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (position1 != null && position2 != null && position.equals(position1) && position.equals(position2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
position1 = position2 = position.toBlockVector();
|
||||
position1 = position2 = position;
|
||||
region.setPos1(position1);
|
||||
region.setPos2(position2);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (position1 == null || position2 == null) {
|
||||
return selectPrimary(position, limits);
|
||||
}
|
||||
@ -114,10 +113,10 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
double y2 = Math.max(position.getY(), position2.getY());
|
||||
double z2 = Math.max(position.getZ(), position2.getZ());
|
||||
|
||||
final BlockVector o1 = position1;
|
||||
final BlockVector o2 = position2;
|
||||
position1 = new BlockVector(x1, y1, z1);
|
||||
position2 = new BlockVector(x2, y2, z2);
|
||||
final BlockVector3 o1 = position1;
|
||||
final BlockVector3 o2 = position2;
|
||||
position1 = new BlockVector3(x1, y1, z1);
|
||||
position2 = new BlockVector3(x2, y2, z2);
|
||||
region.setPos1(position1);
|
||||
region.setPos2(position2);
|
||||
|
||||
@ -129,14 +128,14 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Started selection at " + pos + " (" + region.getArea() + ").");
|
||||
|
||||
explainRegionAdjust(player, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Extended selection to encompass " + pos + " (" + region.getArea() + ").");
|
||||
|
||||
explainRegionAdjust(player, session);
|
||||
|
@ -21,16 +21,15 @@ package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionMinMaxEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionPoint2DEvent;
|
||||
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
@ -48,7 +47,7 @@ import javax.annotation.Nullable;
|
||||
*/
|
||||
public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
private transient BlockVector pos1;
|
||||
private transient BlockVector3 pos1;
|
||||
private transient Polygonal2DRegion region;
|
||||
|
||||
/**
|
||||
@ -91,9 +90,9 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
final int minY = oldRegion.getMinimumPoint().getBlockY();
|
||||
final int maxY = oldRegion.getMaximumPoint().getBlockY();
|
||||
|
||||
List<BlockVector2D> points = oldRegion.polygonize(Integer.MAX_VALUE);
|
||||
List<BlockVector2> points = oldRegion.polygonize(Integer.MAX_VALUE);
|
||||
|
||||
pos1 = points.get(0).toVector(minY).toBlockVector();
|
||||
pos1 = points.get(0).toBlockVector3(minY);
|
||||
region = new Polygonal2DRegion(oldRegion.getWorld(), points, minY, maxY);
|
||||
}
|
||||
}
|
||||
@ -106,11 +105,11 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
* @param minY the minimum Y
|
||||
* @param maxY the maximum Y
|
||||
*/
|
||||
public Polygonal2DRegionSelector(@Nullable World world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
public Polygonal2DRegionSelector(@Nullable World world, List<BlockVector2> points, int minY, int maxY) {
|
||||
checkNotNull(points);
|
||||
|
||||
final BlockVector2D pos2D = points.get(0);
|
||||
pos1 = new BlockVector(pos2D.getX(), minY, pos2D.getZ());
|
||||
final BlockVector2 pos2D = points.get(0);
|
||||
pos1 = new BlockVector3(pos2D.getX(), minY, pos2D.getZ());
|
||||
region = new Polygonal2DRegion(world, points, minY, maxY);
|
||||
}
|
||||
|
||||
@ -126,12 +125,12 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (position.equals(pos1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
pos1 = position.toBlockVector();
|
||||
pos1 = position;
|
||||
region = new Polygonal2DRegion(region.getWorld());
|
||||
region.addPoint(position);
|
||||
region.expandY(position.getBlockY());
|
||||
@ -140,11 +139,11 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (region.size() > 0) {
|
||||
final List<BlockVector2D> points = region.getPoints();
|
||||
final List<BlockVector2> points = region.getPoints();
|
||||
|
||||
final BlockVector2D lastPoint = points.get(region.size() - 1);
|
||||
final BlockVector2 lastPoint = points.get(region.size() - 1);
|
||||
if (lastPoint.getBlockX() == position.getBlockX() && lastPoint.getBlockZ() == position.getBlockZ()) {
|
||||
return false;
|
||||
}
|
||||
@ -163,7 +162,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainPrimarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Starting a new polygon at " + pos + ".");
|
||||
|
||||
session.dispatchCUIEvent(player, new SelectionShapeEvent(getTypeID()));
|
||||
@ -172,7 +171,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
player.print("Added point #" + region.size() + " at " + pos + ".");
|
||||
|
||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(region.size() - 1, pos, getArea()));
|
||||
@ -186,7 +185,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector getPrimaryPosition() throws IncompleteRegionException {
|
||||
public BlockVector3 getPrimaryPosition() throws IncompleteRegionException {
|
||||
if (pos1 == null) {
|
||||
throw new IncompleteRegionException();
|
||||
}
|
||||
@ -215,8 +214,8 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
BlockVector2D pt = region.getPoints().get(0);
|
||||
pos1 = new BlockVector(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
|
||||
BlockVector2 pt = region.getPoints().get(0);
|
||||
pos1 = new BlockVector3(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -251,7 +250,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void describeCUI(LocalSession session, Actor player) {
|
||||
final List<BlockVector2D> points = region.getPoints();
|
||||
final List<BlockVector2> points = region.getPoints();
|
||||
for (int id = 0; id < points.size(); id++) {
|
||||
session.dispatchCUIEvent(player, new SelectionPoint2DEvent(id, points.get(id), getArea()));
|
||||
}
|
||||
|
@ -20,8 +20,9 @@
|
||||
package com.sk89q.worldedit.regions.selector;
|
||||
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.regions.selector.limit.SelectorLimits;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -56,9 +57,9 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
*/
|
||||
public SphereRegionSelector(RegionSelector oldSelector) {
|
||||
super(oldSelector);
|
||||
final Vector radius = region.getRadius();
|
||||
final Vector3 radius = region.getRadius();
|
||||
final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ());
|
||||
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
||||
region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,24 +69,24 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
* @param center the center position
|
||||
* @param radius the radius
|
||||
*/
|
||||
public SphereRegionSelector(@Nullable World world, Vector center, int radius) {
|
||||
super(world, center, new Vector(radius, radius, radius));
|
||||
public SphereRegionSelector(@Nullable World world, BlockVector3 center, int radius) {
|
||||
super(world, center, new Vector3(radius, radius, radius));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector position, SelectorLimits limits) {
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (!started) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final double radiusScalar = Math.ceil(position.distance(region.getCenter()));
|
||||
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
||||
final double radiusScalar = Math.ceil(position.toVector3().distance(region.getCenter()));
|
||||
region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) {
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
if (isDefined()) {
|
||||
player.print("Radius set to " + region.getRadius().getX() + " (" + region.getArea() + ").");
|
||||
} else {
|
||||
|
@ -20,7 +20,7 @@
|
||||
package com.sk89q.worldedit.regions.shape;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.FlatRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
@ -48,8 +48,8 @@ public abstract class ArbitraryBiomeShape {
|
||||
this.extent = new CuboidRegion(extent.getWorld(), extent.getMinimumPoint(), extent.getMaximumPoint());
|
||||
}
|
||||
|
||||
Vector2D min = extent.getMinimumPoint().toVector2D();
|
||||
Vector2D max = extent.getMaximumPoint().toVector2D();
|
||||
BlockVector2 min = extent.getMinimumPoint().toBlockVector2();
|
||||
BlockVector2 max = extent.getMaximumPoint().toBlockVector2();
|
||||
|
||||
cacheOffsetX = min.getBlockX() - 1;
|
||||
cacheOffsetZ = min.getBlockZ() - 1;
|
||||
@ -60,7 +60,7 @@ public abstract class ArbitraryBiomeShape {
|
||||
cache = new BaseBiome[cacheSizeX * cacheSizeZ];
|
||||
}
|
||||
|
||||
protected Iterable<Vector2D> getExtent() {
|
||||
protected Iterable<BlockVector2> getExtent() {
|
||||
return extent.asFlatRegion();
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public abstract class ArbitraryBiomeShape {
|
||||
public int generate(EditSession editSession, BaseBiome baseBiome, boolean hollow) {
|
||||
int affected = 0;
|
||||
|
||||
for (Vector2D position : getExtent()) {
|
||||
for (BlockVector2 position : getExtent()) {
|
||||
int x = position.getBlockX();
|
||||
int z = position.getBlockZ();
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.shape;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -65,7 +65,7 @@ public abstract class ArbitraryShape {
|
||||
public int generate(EditSession editSession, Pattern pattern, boolean hollow) throws MaxChangedBlocksException {
|
||||
int affected = 0;
|
||||
|
||||
for (BlockVector position : getExtent()) {
|
||||
for (BlockVector3 position : getExtent()) {
|
||||
int x = position.getBlockX();
|
||||
int y = position.getBlockY();
|
||||
int z = position.getBlockZ();
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.shape;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
@ -35,7 +35,7 @@ public class RegionShape extends ArbitraryShape {
|
||||
|
||||
@Override
|
||||
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
|
||||
if (!this.extent.contains(new Vector(x, y, z))) {
|
||||
if (!this.extent.contains(new BlockVector3(x, y, z))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -19,30 +19,30 @@
|
||||
|
||||
package com.sk89q.worldedit.regions.shape;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
||||
|
||||
private final Vector unit;
|
||||
private final Vector zero2;
|
||||
private Vector current = new Vector();
|
||||
private final Vector3 unit;
|
||||
private final Vector3 zero2;
|
||||
private Vector3 current = Vector3.ZERO;
|
||||
private EditSession editSession;
|
||||
|
||||
public WorldEditExpressionEnvironment(EditSession editSession, Vector unit, Vector zero) {
|
||||
public WorldEditExpressionEnvironment(EditSession editSession, Vector3 unit, Vector3 zero) {
|
||||
this.editSession = editSession;
|
||||
this.unit = unit;
|
||||
this.zero2 = zero.add(0.5, 0.5, 0.5);
|
||||
}
|
||||
|
||||
public BlockVector toWorld(double x, double y, double z) {
|
||||
public BlockVector3 toWorld(double x, double y, double z) {
|
||||
// unscale, unoffset, round-nearest
|
||||
return new Vector(x, y, z).multiply(unit).add(zero2).toBlockPoint();
|
||||
return new Vector3(x, y, z).multiply(unit).add(zero2).toBlockPoint();
|
||||
}
|
||||
|
||||
public Vector toWorldRel(double x, double y, double z) {
|
||||
public Vector3 toWorldRel(double x, double y, double z) {
|
||||
return current.add(x, y, z);
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setCurrentBlock(Vector current) {
|
||||
public void setCurrentBlock(Vector3 current) {
|
||||
this.current = current;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user