3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 18:40:05 +01:00
Dieser Commit ist enthalten in:
Jesse Boyd 2019-06-29 02:09:56 +10:00
Ursprung 7a9adacc32
Commit ec8422bc13
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
2 geänderte Dateien mit 38 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -723,7 +723,7 @@ public class SelectionCommands {
@Command( @Command(
aliases = {"/sel", ";", "/desel", "/deselect"}, aliases = {"/sel", ";", "/desel", "/deselect"},
flags = "d", flags = "d",
usage = "[cuboid|extend|poly|ellipsoid|sphere|cyl|convex]", usage = "[cuboid|extend|poly|polyhedron|ellipsoid|sphere|cyl|convex|fuzzy]",
desc = "Choose a region selector", desc = "Choose a region selector",
min = 0, min = 0,
max = 1 max = 1

Datei anzeigen

@ -43,6 +43,10 @@ public class EllipsoidRegion extends AbstractRegion {
*/ */
private Vector3 radius; private Vector3 radius;
private Vector3 radiusSqr;
private int radiusLengthSqr;
private boolean sphere;
/** /**
* Construct a new instance of this ellipsoid region. * Construct a new instance of this ellipsoid region.
* *
@ -92,7 +96,7 @@ public class EllipsoidRegion extends AbstractRegion {
@Override @Override
public int getHeight() { public int getHeight() {
return (int) (2 * radius.getY()); return Math.max((int) (2 * radius.getY()), 256);
} }
@Override @Override
@ -123,14 +127,14 @@ public class EllipsoidRegion extends AbstractRegion {
@Override @Override
public void expand(BlockVector3... changes) throws RegionOperationException { public void expand(BlockVector3... changes) throws RegionOperationException {
center = center.add(calculateDiff(changes)); center = center.add(calculateDiff(changes));
radius = radius.add(calculateChanges(changes)); setRadius(radius.add(calculateChanges(changes)));
} }
@Override @Override
public void contract(BlockVector3... changes) throws RegionOperationException { public void contract(BlockVector3... changes) throws RegionOperationException {
center = center.subtract(calculateDiff(changes)); center = center.subtract(calculateDiff(changes));
Vector3 newRadius = radius.subtract(calculateChanges(changes)); Vector3 newRadius = radius.subtract(calculateChanges(changes));
radius = Vector3.at(1.5, 1.5, 1.5).getMaximum(newRadius); setRadius(Vector3.at(1.5, 1.5, 1.5).getMaximum(newRadius));
} }
@Override @Override
@ -172,7 +176,14 @@ public class EllipsoidRegion extends AbstractRegion {
* @param radius the radius * @param radius the radius
*/ */
public void setRadius(Vector3 radius) { public void setRadius(Vector3 radius) {
this.radius = radius.add(0.5, 0.5, 0.5); this.radius = radius;
radiusSqr = radius.multiply(radius);
radiusLengthSqr = (int) radiusSqr.getX();
if (radius.getY() == radius.getX() && radius.getX() == radius.getZ()) {
this.sphere = true;
} else {
this.sphere = false;
}
} }
@Override @Override
@ -201,7 +212,28 @@ public class EllipsoidRegion extends AbstractRegion {
@Override @Override
public boolean contains(BlockVector3 position) { public boolean contains(BlockVector3 position) {
return position.subtract(center).toVector3().divide(radius).lengthSq() <= 1; int cx = position.getBlockX() - center.getBlockX();
int cx2 = cx * cx;
if (cx2 > radiusSqr.getBlockX()) {
return false;
}
int cz = position.getBlockZ() - center.getBlockZ();
int cz2 = cz * cz;
if (cz2 > radiusSqr.getBlockZ()) {
return false;
}
int cy = position.getBlockY() - center.getBlockY();
int cy2 = cy * cy;
if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) {
return false;
}
if (sphere) {
return cx2 + cy2 + cz2 <= radiusLengthSqr;
}
double cxd = (double) cx / radius.getBlockX();
double cyd = (double) cy / radius.getBlockY();
double czd = (double) cz / radius.getBlockZ();
return cxd * cxd + cyd * cyd + czd * czd <= 1;
} }
/** /**