Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-25 18:40:05 +01:00
Add support for expand with reverse dir for Cylinder & Ellipsoid
Dieser Commit ist enthalten in:
Ursprung
760f77e681
Commit
857f721bb5
@ -271,8 +271,6 @@ public class SelectionCommands {
|
|||||||
public void expand(CommandContext args, LocalSession session, LocalPlayer player,
|
public void expand(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
Vector dir;
|
|
||||||
|
|
||||||
// Special syntax (//expand vert) to expand the selection between
|
// Special syntax (//expand vert) to expand the selection between
|
||||||
// sky and bedrock.
|
// sky and bedrock.
|
||||||
if (args.getString(0).equalsIgnoreCase("vert")
|
if (args.getString(0).equalsIgnoreCase("vert")
|
||||||
@ -295,6 +293,7 @@ public class SelectionCommands {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector dir;
|
||||||
int change = args.getInteger(0);
|
int change = args.getInteger(0);
|
||||||
int reverseChange = 0;
|
int reverseChange = 0;
|
||||||
|
|
||||||
@ -302,7 +301,7 @@ public class SelectionCommands {
|
|||||||
case 2:
|
case 2:
|
||||||
// Either a reverse amount or a direction
|
// Either a reverse amount or a direction
|
||||||
try {
|
try {
|
||||||
reverseChange = args.getInteger(1) * -1;
|
reverseChange = args.getInteger(1);
|
||||||
dir = we.getDirection(player, "me");
|
dir = we.getDirection(player, "me");
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
dir = we.getDirection(player,
|
dir = we.getDirection(player,
|
||||||
@ -312,7 +311,7 @@ public class SelectionCommands {
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// Both reverse amount and direction
|
// Both reverse amount and direction
|
||||||
reverseChange = args.getInteger(1) * -1;
|
reverseChange = args.getInteger(1);
|
||||||
dir = we.getDirection(player,
|
dir = we.getDirection(player,
|
||||||
args.getString(2).toLowerCase());
|
args.getString(2).toLowerCase());
|
||||||
break;
|
break;
|
||||||
@ -322,10 +321,11 @@ public class SelectionCommands {
|
|||||||
|
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
int oldSize = region.getArea();
|
int oldSize = region.getArea();
|
||||||
region.expand(dir.multiply(change));
|
|
||||||
|
|
||||||
if (reverseChange != 0) {
|
if (reverseChange == 0) {
|
||||||
region.expand(dir.multiply(reverseChange));
|
region.expand(dir.multiply(change));
|
||||||
|
} else {
|
||||||
|
region.expand(dir.multiply(change), dir.multiply(-reverseChange));
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
@ -356,7 +356,7 @@ public class SelectionCommands {
|
|||||||
case 2:
|
case 2:
|
||||||
// Either a reverse amount or a direction
|
// Either a reverse amount or a direction
|
||||||
try {
|
try {
|
||||||
reverseChange = args.getInteger(1) * -1;
|
reverseChange = args.getInteger(1);
|
||||||
dir = we.getDirection(player, "me");
|
dir = we.getDirection(player, "me");
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
dir = we.getDirection(player, args.getString(1).toLowerCase());
|
dir = we.getDirection(player, args.getString(1).toLowerCase());
|
||||||
@ -365,7 +365,7 @@ public class SelectionCommands {
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
// Both reverse amount and direction
|
// Both reverse amount and direction
|
||||||
reverseChange = args.getInteger(1) * -1;
|
reverseChange = args.getInteger(1);
|
||||||
dir = we.getDirection(player, args.getString(2).toLowerCase());
|
dir = we.getDirection(player, args.getString(2).toLowerCase());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -375,9 +375,10 @@ public class SelectionCommands {
|
|||||||
try {
|
try {
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
int oldSize = region.getArea();
|
int oldSize = region.getArea();
|
||||||
region.contract(dir.multiply(change));
|
if (reverseChange == 0) {
|
||||||
if (reverseChange != 0) {
|
region.contract(dir.multiply(change));
|
||||||
region.contract(dir.multiply(reverseChange));
|
} else {
|
||||||
|
region.contract(dir.multiply(change), dir.multiply(-reverseChange));
|
||||||
}
|
}
|
||||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||||
int newSize = region.getArea();
|
int newSize = region.getArea();
|
||||||
|
@ -213,39 +213,28 @@ public class CylinderRegion extends AbstractRegion {
|
|||||||
return (int) (2 * radius.getZ());
|
return (int) (2 * radius.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector2D getTotalXZChanges(Vector... changes) throws RegionOperationException {
|
private Vector2D calculateDiff2D(Vector... changes) throws RegionOperationException {
|
||||||
Vector2D diff = new Vector2D();
|
Vector2D diff = new Vector2D();
|
||||||
Vector2D total = new Vector2D();
|
|
||||||
for (Vector change : changes) {
|
for (Vector change : changes) {
|
||||||
diff = diff.add(change.toVector2D());
|
diff = diff.add(change.toVector2D());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((diff.getBlockX() & 1) + (diff.getBlockZ() & 1) != 0) {
|
||||||
|
throw new RegionOperationException("Cylinders changes must be even for each horizontal dimensions.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff.divide(2).floor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector2D calculateChanges2D(Vector... changes) {
|
||||||
|
Vector2D total = new Vector2D();
|
||||||
|
for (Vector change : changes) {
|
||||||
total = total.add(change.toVector2D().positive());
|
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();
|
return total.divide(2).floor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Expand the region.
|
|
||||||
*
|
|
||||||
* @param change
|
|
||||||
*/
|
|
||||||
public void expand(Vector change) throws RegionOperationException {
|
|
||||||
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
|
||||||
throw new RegionOperationException("Cylinders can only be expanded vertically.");
|
|
||||||
}
|
|
||||||
|
|
||||||
int changeY = change.getBlockY();
|
|
||||||
if (changeY > 0) {
|
|
||||||
maxY += changeY;
|
|
||||||
} else {
|
|
||||||
minY += changeY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand the region.
|
* Expand the region.
|
||||||
* Expand the region.
|
* Expand the region.
|
||||||
@ -254,27 +243,15 @@ public class CylinderRegion extends AbstractRegion {
|
|||||||
* @throws RegionOperationException
|
* @throws RegionOperationException
|
||||||
*/
|
*/
|
||||||
public void expand(Vector... changes) throws RegionOperationException {
|
public void expand(Vector... changes) throws RegionOperationException {
|
||||||
radius = radius.add(getTotalXZChanges(changes));
|
setCenter(getCenter().add(calculateDiff2D(changes).toVector()));
|
||||||
|
radius = radius.add(calculateChanges2D(changes));
|
||||||
for (Vector change : changes) {
|
for (Vector change : changes) {
|
||||||
expand(new Vector(0, change.getBlockY(), 0));
|
int changeY = change.getBlockY();
|
||||||
}
|
if (changeY > 0) {
|
||||||
}
|
maxY += changeY;
|
||||||
|
} else {
|
||||||
/**
|
minY += changeY;
|
||||||
* Contract the region.
|
}
|
||||||
*
|
|
||||||
* @param change
|
|
||||||
*/
|
|
||||||
public void contract(Vector change) throws RegionOperationException {
|
|
||||||
if (change.getBlockX() != 0 || change.getBlockZ() != 0) {
|
|
||||||
throw new RegionOperationException("Cylinders can only be expanded vertically.");
|
|
||||||
}
|
|
||||||
|
|
||||||
int changeY = change.getBlockY();
|
|
||||||
if (changeY > 0) {
|
|
||||||
minY += changeY;
|
|
||||||
} else {
|
|
||||||
maxY += changeY;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,10 +262,16 @@ public class CylinderRegion extends AbstractRegion {
|
|||||||
* @throws RegionOperationException
|
* @throws RegionOperationException
|
||||||
*/
|
*/
|
||||||
public void contract(Vector... changes) throws RegionOperationException {
|
public void contract(Vector... changes) throws RegionOperationException {
|
||||||
Vector2D newRadius = radius.subtract(getTotalXZChanges(changes));
|
setCenter(getCenter().subtract(calculateDiff2D(changes).toVector()));
|
||||||
|
Vector2D newRadius = radius.subtract(calculateChanges2D(changes));
|
||||||
radius = Vector2D.getMaximum(new Vector2D(1.5, 1.5), newRadius);
|
radius = Vector2D.getMaximum(new Vector2D(1.5, 1.5), newRadius);
|
||||||
for (Vector change : changes) {
|
for (Vector change : changes) {
|
||||||
contract(new Vector(0, change.getBlockY(), 0));
|
int changeY = change.getBlockY();
|
||||||
|
if (changeY > 0) {
|
||||||
|
minY += changeY;
|
||||||
|
} else {
|
||||||
|
maxY += changeY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,30 +120,26 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
return (int) (2 * radius.getZ());
|
return (int) (2 * radius.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector getTotalChanges(Vector... changes) throws RegionOperationException {
|
private Vector calculateDiff(Vector... changes) throws RegionOperationException {
|
||||||
Vector diff = new Vector();
|
Vector diff = new Vector().add(changes);
|
||||||
|
|
||||||
|
if ((diff.getBlockX() & 1) + (diff.getBlockY() & 1) + (diff.getBlockZ() & 1) != 0) {
|
||||||
|
throw new RegionOperationException(
|
||||||
|
"Ellipsoid changes must be even for each dimensions.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff.divide(2).floor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector calculateChanges(Vector... changes) {
|
||||||
Vector total = new Vector();
|
Vector total = new Vector();
|
||||||
for (Vector change : changes) {
|
for (Vector change : changes) {
|
||||||
diff = diff.add(change);
|
|
||||||
total = total.add(change.positive());
|
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();
|
return total.divide(2).floor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Expands the ellipsoid in a direction.
|
|
||||||
*
|
|
||||||
* @param change
|
|
||||||
*/
|
|
||||||
public void expand(Vector change) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand the region.
|
* Expand the region.
|
||||||
*
|
*
|
||||||
@ -151,15 +147,8 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
* @throws RegionOperationException
|
* @throws RegionOperationException
|
||||||
*/
|
*/
|
||||||
public void expand(Vector... changes) throws RegionOperationException {
|
public void expand(Vector... changes) throws RegionOperationException {
|
||||||
radius = radius.add(getTotalChanges(changes));
|
center = center.add(calculateDiff(changes));
|
||||||
}
|
radius = radius.add(calculateChanges(changes));
|
||||||
|
|
||||||
/**
|
|
||||||
* Contracts the ellipsoid in a direction.
|
|
||||||
*
|
|
||||||
* @param change
|
|
||||||
*/
|
|
||||||
public void contract(Vector change) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,7 +158,8 @@ public class EllipsoidRegion extends AbstractRegion {
|
|||||||
* @throws RegionOperationException
|
* @throws RegionOperationException
|
||||||
*/
|
*/
|
||||||
public void contract(Vector... changes) throws RegionOperationException {
|
public void contract(Vector... changes) throws RegionOperationException {
|
||||||
Vector newRadius = radius.subtract(getTotalChanges(changes));
|
center = center.subtract(calculateDiff(changes));
|
||||||
|
Vector newRadius = radius.subtract(calculateChanges(changes));
|
||||||
radius = Vector.getMaximum(new Vector(1.5, 1.5, 1.5), newRadius);
|
radius = Vector.getMaximum(new Vector(1.5, 1.5, 1.5), newRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren