Don't cache location for circle brush, fix #970

Also, allow filled circles (very cool feature)
Dieser Commit ist enthalten in:
Hannes Greule 2021-04-10 01:07:51 +02:00
Ursprung 911d3a00eb
Commit 19592df1f6
3 geänderte Dateien mit 16 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -10,16 +10,22 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
public class CircleBrush implements Brush {
private final Player player;
public CircleBrush(Player player) {
this.player = player;
private final boolean filled;
public CircleBrush(boolean filled) {
this.filled = filled;
}
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
Player player = editSession.getPlayer();
if (player == null) {
return;
}
Vector3 normal = position.toVector3().subtract(player.getLocation());
editSession.makeCircle(position, pattern, size, size, size, false, normal);
editSession.makeCircle(position, pattern, size, size, size, filled, normal);
}
private Vector3 any90Rotate(Vector3 normal) {

Datei anzeigen

@ -1985,8 +1985,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable {
double threshold = 0.5;
LocalBlockVectorSet set = new LocalBlockVectorSet();
double nextXn = 0;
double dx;
double dy;

Datei anzeigen

@ -221,13 +221,16 @@ public class BrushCommands {
desc = "Creates a circle, which revolves around your facing direction"
)
@CommandPermissions("worldedit.brush.sphere")
public void circleBrush(Player player, InjectedValueAccess context,
public void circleBrush(InjectedValueAccess context,
@Arg(desc = "Pattern")
Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius) throws WorldEditException {
Expression radius,
@Arg(name = "filled", desc = "Whether the circle should be filled", def = "false")
boolean filled
) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
set(context, new CircleBrush(player)).setSize(radius).setFill(fill);
set(context, new CircleBrush(filled)).setSize(radius).setFill(fill);
}
@Command(