mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-21 04:49:51 +08:00
The Sphere selector can now also shrink the region.
The radius is set to ceil(distanceToCenter).
This commit is contained in:
parent
878c26a8f0
commit
77219a8b3e
@ -763,7 +763,7 @@ public void select(CommandContext args, LocalSession session, LocalPlayer player
|
||||
player.print("Ellipsoid selector: left click=center, right click to extend");
|
||||
} else if (typeName.equalsIgnoreCase("sphere")) {
|
||||
selector = new SphereRegionSelector(oldSelector);
|
||||
player.print("Sphere selector: left click=center, right click to extend");
|
||||
player.print("Sphere selector: left click=center, right click to set radius");
|
||||
} else if (typeName.equalsIgnoreCase("cyl")) {
|
||||
selector = new CylinderRegionSelector(oldSelector);
|
||||
player.print("Cylindrical selector: Left click=center, right click to extend.");
|
||||
|
@ -41,7 +41,7 @@ public SphereRegionSelector() {
|
||||
public SphereRegionSelector(RegionSelector oldSelector) {
|
||||
super(oldSelector);
|
||||
final Vector radius = region.getRadius();
|
||||
double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ());
|
||||
final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ());
|
||||
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
||||
}
|
||||
|
||||
@ -51,12 +51,9 @@ public SphereRegionSelector(LocalWorld world, Vector center, int radius) {
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(Vector pos) {
|
||||
final Vector diff = pos.subtract(region.getCenter());
|
||||
final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0));
|
||||
final double radiusScalar = Math.ceil(pos.distance(region.getCenter()));
|
||||
region.setRadius(new Vector(radiusScalar, radiusScalar, radiusScalar));
|
||||
|
||||
double minRadiusScalar = Math.max(Math.max(minRadius.getX(), minRadius.getY()), minRadius.getZ());
|
||||
|
||||
region.extendRadius(new Vector(minRadiusScalar, minRadiusScalar, minRadiusScalar));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user