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