geforkt von Mirrors/FastAsyncWorldEdit
Implement contract/expand(Vector...) for Cylinder & Ellipsoid
Dieser Commit ist enthalten in:
Ursprung
0346228310
Commit
1359a7fada
@ -213,6 +213,21 @@ public class CylinderRegion extends AbstractRegion {
|
|||||||
return (int) (2 * radius.getZ());
|
return (int) (2 * radius.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector2D getTotalXZChanges(Vector... changes) throws RegionOperationException {
|
||||||
|
Vector2D diff = new Vector2D();
|
||||||
|
Vector2D total = new Vector2D();
|
||||||
|
for (Vector change : changes) {
|
||||||
|
diff = diff.add(change.toVector2D());
|
||||||
|
total = total.add(change.toVector2D().positive());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diff.getBlockX() != 0 || diff.getBlockZ() != 0) {
|
||||||
|
throw new RegionOperationException("Cylinders changes must be equal for both directions of each horizontal dimensions.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return total.divide(2).floor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand the region.
|
* Expand the region.
|
||||||
*
|
*
|
||||||
@ -231,6 +246,20 @@ public class CylinderRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand the region.
|
||||||
|
* Expand the region.
|
||||||
|
*
|
||||||
|
* @param changes array/arguments with multiple related changes
|
||||||
|
* @throws RegionOperationException
|
||||||
|
*/
|
||||||
|
public void expand(Vector... changes) throws RegionOperationException {
|
||||||
|
radius = radius.add(getTotalXZChanges(changes));
|
||||||
|
for (Vector change : changes) {
|
||||||
|
expand(new Vector(0, change.getBlockY(), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contract the region.
|
* Contract the region.
|
||||||
*
|
*
|
||||||
@ -249,6 +278,20 @@ public class CylinderRegion extends AbstractRegion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contract the region.
|
||||||
|
*
|
||||||
|
* @param changes array/arguments with multiple related changes
|
||||||
|
* @throws RegionOperationException
|
||||||
|
*/
|
||||||
|
public void contract(Vector... changes) throws RegionOperationException {
|
||||||
|
Vector2D newRadius = radius.subtract(getTotalXZChanges(changes));
|
||||||
|
radius = Vector2D.getMaximum(new Vector2D(1.5, 1.5), newRadius);
|
||||||
|
for (Vector change : changes) {
|
||||||
|
contract(new Vector(0, change.getBlockY(), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shift(Vector change) throws RegionOperationException {
|
public void shift(Vector change) throws RegionOperationException {
|
||||||
setCenter(getCenter().add(change));
|
setCenter(getCenter().add(change));
|
||||||
|
@ -120,6 +120,22 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
return (int) (2 * radius.getZ());
|
return (int) (2 * radius.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Vector getTotalChanges(Vector... changes) throws RegionOperationException {
|
||||||
|
Vector diff = new Vector();
|
||||||
|
Vector total = new Vector();
|
||||||
|
for (Vector change : changes) {
|
||||||
|
diff = diff.add(change);
|
||||||
|
total = total.add(change.positive());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diff.getBlockX() != 0 || diff.getBlockY() != 0 || diff.getBlockZ() != 0) {
|
||||||
|
throw new RegionOperationException(
|
||||||
|
"Ellipsoid changes must be equal for both directions of each dimensions.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return total.divide(2).floor();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expands the ellipsoid in a direction.
|
* Expands the ellipsoid in a direction.
|
||||||
*
|
*
|
||||||
@ -128,6 +144,16 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
public void expand(Vector change) {
|
public void expand(Vector change) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand the region.
|
||||||
|
*
|
||||||
|
* @param changes array/arguments with multiple related changes
|
||||||
|
* @throws RegionOperationException
|
||||||
|
*/
|
||||||
|
public void expand(Vector... changes) throws RegionOperationException {
|
||||||
|
radius = radius.add(getTotalChanges(changes));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contracts the ellipsoid in a direction.
|
* Contracts the ellipsoid in a direction.
|
||||||
*
|
*
|
||||||
@ -136,6 +162,17 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
public void contract(Vector change) {
|
public void contract(Vector change) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contract the region.
|
||||||
|
*
|
||||||
|
* @param changes array/arguments with multiple related changes
|
||||||
|
* @throws RegionOperationException
|
||||||
|
*/
|
||||||
|
public void contract(Vector... changes) throws RegionOperationException {
|
||||||
|
Vector newRadius = radius.subtract(getTotalChanges(changes));
|
||||||
|
radius = Vector.getMaximum(new Vector(1.5, 1.5, 1.5), newRadius);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shift(Vector change) throws RegionOperationException {
|
public void shift(Vector change) throws RegionOperationException {
|
||||||
center = center.add(change);
|
center = center.add(change);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren