3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-05 11:00:05 +01:00

//sel poly now keeps the previous selection, converting its outline into a polygon if necessary.

This loses some blocks, if anyone cares
Dieser Commit ist enthalten in:
TomyLobo 2011-12-27 12:07:11 +01:00
Ursprung 76fd63d64b
Commit 7d503fdc5c
4 geänderte Dateien mit 45 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -616,7 +616,7 @@ public class SelectionCommands {
selector = new ExtendingCuboidRegionSelector(oldSelector);
player.print("Cuboid: left click for a starting point, right click to extend");
} else if (typeName.equalsIgnoreCase("poly")) {
selector = new Polygonal2DRegionSelector(world);
selector = new Polygonal2DRegionSelector(oldSelector);
player.print("2D polygon selector: Left/right click to add a point.");
} else {
player.printError("Only 'cuboid', 'extend' and 'poly' are accepted.");

Datei anzeigen

@ -49,7 +49,7 @@ public class CuboidRegionSelector implements RegionSelector, CUIPointBasedRegion
}
public CuboidRegionSelector(RegionSelector oldSelector) {
region = new CuboidRegion(oldSelector.getIncompleteRegion().getWorld(), new Vector(), new Vector());
this(oldSelector.getIncompleteRegion().getWorld());
if (oldSelector instanceof CuboidRegionSelector) {
final CuboidRegionSelector cuboidRegionSelector = (CuboidRegionSelector) oldSelector;

Datei anzeigen

@ -50,7 +50,7 @@ public class Polygonal2DRegion implements Region {
* Construct the region
*/
public Polygonal2DRegion() {
this(null);
this((LocalWorld) null);
}
/**
@ -84,6 +84,11 @@ public class Polygonal2DRegion implements Region {
recalculate();
}
public Polygonal2DRegion(Polygonal2DRegion region) {
this(region.world, region.points, region.minY, region.maxY);
hasY = region.hasY;
}
/**
* Get the list of points.
*

Datei anzeigen

@ -19,6 +19,7 @@
package com.sk89q.worldedit.regions;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import com.sk89q.worldedit.BlockVector;
@ -46,6 +47,39 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIPointBasedR
region = new Polygonal2DRegion(world);
}
public Polygonal2DRegionSelector(RegionSelector oldSelector) {
this(oldSelector.getIncompleteRegion().getWorld());
if (oldSelector instanceof Polygonal2DRegionSelector) {
final Polygonal2DRegionSelector polygonal2DRegionSelector = (Polygonal2DRegionSelector) oldSelector;
pos1 = polygonal2DRegionSelector.pos1;
region = new Polygonal2DRegion(polygonal2DRegionSelector.region);
} else {
final Region oldRegion;
try {
oldRegion = oldSelector.getRegion();
} catch (IncompleteRegionException e) {
return;
}
BlockVector min = oldRegion.getMinimumPoint().toBlockVector();
BlockVector max = oldRegion.getMaximumPoint().toBlockVector();
int minY = min.getBlockY();
int maxY = max.getBlockY();
List<BlockVector2D> points = new ArrayList<BlockVector2D>(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()));
pos1 = min;
region = new Polygonal2DRegion(oldRegion.getWorld(), points, minY, maxY);
}
}
public boolean selectPrimary(Vector pos) {
if (pos.equals(pos1)) {
return false;