Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 16:12:51 +02:00
Update Upstream
5a7cbfd Fix selecting at 0,0,0 or radius 0 cyl/ellipse (1734)
Dieser Commit ist enthalten in:
Ursprung
b7f595cc50
Commit
d2dee87ab9
@ -56,6 +56,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected static final transient NumberFormat NUMBER_FORMAT;
|
||||
protected transient CylinderRegion region;
|
||||
protected transient boolean selectedCenter;
|
||||
protected transient boolean selectedRadius;
|
||||
|
||||
static {
|
||||
NUMBER_FORMAT = (NumberFormat) NumberFormat.getInstance().clone();
|
||||
@ -95,6 +97,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
final CylinderRegionSelector cylSelector = (CylinderRegionSelector) oldSelector;
|
||||
|
||||
region = new CylinderRegion(cylSelector.region);
|
||||
selectedCenter = cylSelector.selectedCenter;
|
||||
selectedRadius = cylSelector.selectedRadius;
|
||||
} else {
|
||||
final Region oldRegion;
|
||||
try {
|
||||
@ -112,6 +116,9 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
region.setMaximumY(Math.max(pos1.getBlockY(), pos2.getBlockY()));
|
||||
region.setMinimumY(Math.min(pos1.getBlockY(), pos2.getBlockY()));
|
||||
|
||||
selectedCenter = true;
|
||||
selectedRadius = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,6 +139,9 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
region.setMinimumY(Math.min(minY, maxY));
|
||||
region.setMaximumY(Math.max(minY, maxY));
|
||||
|
||||
selectedCenter = true;
|
||||
selectedRadius = true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -147,7 +157,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (!region.getCenter().equals(Vector3.ZERO) && position.equals(region.getCenter().toBlockPoint())) {
|
||||
if (selectedCenter && position.equals(region.getCenter().toBlockPoint()) && !selectedRadius) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -155,22 +165,26 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
region.setCenter(position.toBlockVector2());
|
||||
region.setY(position.getBlockY());
|
||||
|
||||
selectedCenter = true;
|
||||
selectedRadius = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean selectSecondary(BlockVector3 position, SelectorLimits limits) {
|
||||
Vector3 center = region.getCenter();
|
||||
if (center.equals(Vector3.ZERO)) {
|
||||
if (!selectedCenter) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Vector2 diff = position.toVector3().subtract(center).toVector2();
|
||||
final Vector2 diff = position.toVector3().subtract(region.getCenter()).toVector2();
|
||||
final Vector2 minRadius = diff.getMaximum(diff.multiply(-1.0));
|
||||
region.extendRadius(minRadius);
|
||||
|
||||
region.setY(position.getBlockY());
|
||||
|
||||
selectedRadius = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -183,9 +197,7 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public void explainSecondarySelection(Actor player, LocalSession session, BlockVector3 pos) {
|
||||
Vector3 center = region.getCenter();
|
||||
|
||||
if (!center.equals(Vector3.ZERO)) {
|
||||
if (selectedCenter) {
|
||||
player.print(Caption.of(
|
||||
"worldedit.selection.cylinder.explain.secondary",
|
||||
TextComponent.of(NUMBER_FORMAT.format(region.getRadius().getX())),
|
||||
@ -230,7 +242,8 @@ public class CylinderRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return !region.getRadius().equals(Vector2.ZERO);
|
||||
// selectedCenter is implied by selectedRadius
|
||||
return selectedRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +52,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
protected transient EllipsoidRegion region;
|
||||
protected transient boolean started = false;
|
||||
protected transient boolean selectedRadius = false;
|
||||
|
||||
/**
|
||||
* Create a new selector with a {@code null} world.
|
||||
@ -81,6 +82,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
region = new EllipsoidRegion(ellipsoidRegionSelector.getIncompleteRegion());
|
||||
started = ellipsoidRegionSelector.started;
|
||||
selectedRadius = ellipsoidRegionSelector.selectedRadius;
|
||||
} else {
|
||||
Region oldRegion;
|
||||
try {
|
||||
@ -96,6 +98,7 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
region.setCenter(center);
|
||||
region.setRadius(pos2.subtract(center).toVector3());
|
||||
started = true;
|
||||
selectedRadius = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,6 +114,9 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
region.setCenter(center);
|
||||
region.setRadius(radius);
|
||||
|
||||
started = true;
|
||||
selectedRadius = true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -126,13 +132,14 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public boolean selectPrimary(BlockVector3 position, SelectorLimits limits) {
|
||||
if (position.equals(region.getCenter().toBlockPoint()) && region.getRadius().lengthSq() == 0) {
|
||||
if (started && position.equals(region.getCenter().toBlockPoint()) && !selectedRadius) {
|
||||
return false;
|
||||
}
|
||||
|
||||
region.setCenter(position);
|
||||
region.setRadius(Vector3.ZERO);
|
||||
started = true;
|
||||
selectedRadius = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -146,6 +153,9 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
final Vector3 diff = position.toVector3().subtract(region.getCenter());
|
||||
final Vector3 minRadius = diff.getMaximum(diff.multiply(-1.0));
|
||||
region.extendRadius(minRadius);
|
||||
|
||||
selectedRadius = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -192,7 +202,8 @@ public class EllipsoidRegionSelector implements RegionSelector, CUIRegion {
|
||||
|
||||
@Override
|
||||
public boolean isDefined() {
|
||||
return started && region.getRadius().lengthSq() > 0;
|
||||
// started implied by selectedRadius
|
||||
return selectedRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,9 +59,11 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
*/
|
||||
public SphereRegionSelector(RegionSelector oldSelector) {
|
||||
super(oldSelector);
|
||||
final Vector3 radius = region.getRadius();
|
||||
final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ());
|
||||
region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar));
|
||||
if (selectedRadius) {
|
||||
final Vector3 radius = region.getRadius();
|
||||
final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ());
|
||||
region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,6 +86,8 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
final double radiusScalar = Math.ceil(position.toVector3().distance(region.getCenter()));
|
||||
region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar));
|
||||
|
||||
selectedRadius = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren