Add -s flag for heightmap to disable smoothing
This commit is contained in:
parent
ac5d5de394
commit
0fd7786f82
@ -13,8 +13,8 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
public class FlattenBrush extends HeightBrush {
|
public class FlattenBrush extends HeightBrush {
|
||||||
|
|
||||||
public FlattenBrush(InputStream stream, int rotation, double yscale, boolean layers, Clipboard clipboard, ScalableHeightMap.Shape shape) {
|
public FlattenBrush(InputStream stream, int rotation, double yscale, boolean layers, boolean smooth, Clipboard clipboard, ScalableHeightMap.Shape shape) {
|
||||||
super(stream, rotation, yscale, layers, clipboard, shape);
|
super(stream, rotation, yscale, layers, smooth, clipboard, shape);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -26,6 +26,6 @@ public class FlattenBrush extends HeightBrush {
|
|||||||
}
|
}
|
||||||
HeightMap map = getHeightMap();
|
HeightMap map = getHeightMap();
|
||||||
map.setSize(size);
|
map.setSize(size);
|
||||||
map.perform(editSession, mask, position, size, rotation, yscale, true, true, layers);
|
map.perform(editSession, mask, position, size, rotation, yscale, smooth, true, layers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,15 +24,17 @@ public class HeightBrush implements Brush {
|
|||||||
public final int rotation;
|
public final int rotation;
|
||||||
public final double yscale;
|
public final double yscale;
|
||||||
public final boolean layers;
|
public final boolean layers;
|
||||||
|
public final boolean smooth;
|
||||||
|
|
||||||
public HeightBrush(InputStream stream, int rotation, double yscale, boolean layers, Clipboard clipboard) {
|
public HeightBrush(InputStream stream, int rotation, double yscale, boolean layers, boolean smooth, Clipboard clipboard) {
|
||||||
this(stream, rotation, yscale, layers, clipboard, ScalableHeightMap.Shape.CONE);
|
this(stream, rotation, yscale, layers, smooth, clipboard, ScalableHeightMap.Shape.CONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public HeightBrush(InputStream stream, int rotation, double yscale, boolean layers, Clipboard clipboard, ScalableHeightMap.Shape shape) {
|
public HeightBrush(InputStream stream, int rotation, double yscale, boolean layers, boolean smooth, Clipboard clipboard, ScalableHeightMap.Shape shape) {
|
||||||
this.rotation = (rotation / 90) % 4;
|
this.rotation = (rotation / 90) % 4;
|
||||||
this.yscale = yscale;
|
this.yscale = yscale;
|
||||||
this.layers = layers;
|
this.layers = layers;
|
||||||
|
this.smooth = smooth;
|
||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
try {
|
try {
|
||||||
heightMap = ScalableHeightMap.fromPNG(stream);
|
heightMap = ScalableHeightMap.fromPNG(stream);
|
||||||
@ -70,6 +72,6 @@ public class HeightBrush implements Brush {
|
|||||||
}
|
}
|
||||||
HeightMap map = getHeightMap();
|
HeightMap map = getHeightMap();
|
||||||
map.setSize(size);
|
map.setSize(size);
|
||||||
map.perform(editSession, mask, position, size, rotation, yscale, true, false, layers);
|
map.perform(editSession, mask, position, size, rotation, yscale, smooth, false, layers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -778,13 +778,14 @@ public class BrushCommands {
|
|||||||
help =
|
help =
|
||||||
"This brush raises and lowers land.\n" +
|
"This brush raises and lowers land.\n" +
|
||||||
"The -r flag enables random off-axis rotation\n" +
|
"The -r flag enables random off-axis rotation\n" +
|
||||||
"The -l flag will work on snow layers",
|
"The -l flag will work on snow layers\n" +
|
||||||
|
"The -s flag disables smoothing",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 4
|
max = 4
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.height")
|
@CommandPermissions("worldedit.brush.height")
|
||||||
public void heightBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('r') boolean randomRotate, @Switch('l') boolean layers) throws WorldEditException {
|
public void heightBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('r') boolean randomRotate, @Switch('l') boolean layers, @Switch('s') boolean dontSmooth) throws WorldEditException {
|
||||||
terrainBrush(player, session, radius, filename, rotation, yscale, false, randomRotate, layers, ScalableHeightMap.Shape.CONE);
|
terrainBrush(player, session, radius, filename, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -795,13 +796,14 @@ public class BrushCommands {
|
|||||||
help =
|
help =
|
||||||
"This brush flattens terrain and creates cliffs.\n" +
|
"This brush flattens terrain and creates cliffs.\n" +
|
||||||
"The -r flag enables random off-axis rotation\n" +
|
"The -r flag enables random off-axis rotation\n" +
|
||||||
"The -l flag will work on snow layers",
|
"The -l flag will work on snow layers\n" +
|
||||||
|
"The -s flag disables smoothing",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 4
|
max = 4
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.height")
|
@CommandPermissions("worldedit.brush.height")
|
||||||
public void cliffBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('r') boolean randomRotate, @Switch('l') boolean layers) throws WorldEditException {
|
public void cliffBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('r') boolean randomRotate, @Switch('l') boolean layers, @Switch('s') boolean dontSmooth) throws WorldEditException {
|
||||||
terrainBrush(player, session, radius, filename, rotation, yscale, true, randomRotate, layers, ScalableHeightMap.Shape.CYLINDER);
|
terrainBrush(player, session, radius, filename, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -810,14 +812,15 @@ public class BrushCommands {
|
|||||||
flags = "h",
|
flags = "h",
|
||||||
help = "Flatten brush makes terrain flatter\n" +
|
help = "Flatten brush makes terrain flatter\n" +
|
||||||
"The -r flag enables random off-axis rotation\n" +
|
"The -r flag enables random off-axis rotation\n" +
|
||||||
"The -l flag will work on snow layers",
|
"The -l flag will work on snow layers\n" +
|
||||||
|
"The -s flag disables smoothing",
|
||||||
desc = "This brush raises and lowers land towards the clicked point\n",
|
desc = "This brush raises and lowers land towards the clicked point\n",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 4
|
max = 4
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.height")
|
@CommandPermissions("worldedit.brush.height")
|
||||||
public void flattenBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('r') boolean randomRotate, @Switch('l') boolean layers) throws WorldEditException {
|
public void flattenBrush(Player player, LocalSession session, @Optional("5") double radius, @Optional("") final String filename, @Optional("0") final int rotation, @Optional("1") final double yscale, @Switch('r') boolean randomRotate, @Switch('l') boolean layers, @Switch('s') boolean dontSmooth) throws WorldEditException {
|
||||||
terrainBrush(player, session, radius, filename, rotation, yscale, true, randomRotate, layers, ScalableHeightMap.Shape.CONE);
|
terrainBrush(player, session, radius, filename, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private InputStream getHeightmapStream(String filename) {
|
private InputStream getHeightmapStream(String filename) {
|
||||||
@ -851,7 +854,7 @@ public class BrushCommands {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void terrainBrush(Player player, LocalSession session, double radius, String filename, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, ScalableHeightMap.Shape shape) throws WorldEditException {
|
private void terrainBrush(Player player, LocalSession session, double radius, String filename, int rotation, double yscale, boolean flat, boolean randomRotate, boolean layers, boolean smooth, ScalableHeightMap.Shape shape) throws WorldEditException {
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
InputStream stream = getHeightmapStream(filename);
|
InputStream stream = getHeightmapStream(filename);
|
||||||
BrushTool tool = session.getBrushTool(player);
|
BrushTool tool = session.getBrushTool(player);
|
||||||
@ -859,15 +862,15 @@ public class BrushCommands {
|
|||||||
HeightBrush brush;
|
HeightBrush brush;
|
||||||
if (flat) {
|
if (flat) {
|
||||||
try {
|
try {
|
||||||
brush = new FlattenBrush(stream, rotation, yscale, layers, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null, shape);
|
brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null, shape);
|
||||||
} catch (EmptyClipboardException ignore) {
|
} catch (EmptyClipboardException ignore) {
|
||||||
brush = new FlattenBrush(stream, rotation, yscale, layers, null, shape);
|
brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, null, shape);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
brush = new HeightBrush(stream, rotation, yscale, layers, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null);
|
brush = new HeightBrush(stream, rotation, yscale, layers, smooth, filename.equalsIgnoreCase("#clipboard") ? session.getClipboard().getClipboard() : null);
|
||||||
} catch (EmptyClipboardException ignore) {
|
} catch (EmptyClipboardException ignore) {
|
||||||
brush = new HeightBrush(stream, rotation, yscale, layers, null);
|
brush = new HeightBrush(stream, rotation, yscale, layers, smooth, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tool.setBrush(brush, "worldedit.brush.height", player);
|
tool.setBrush(brush, "worldedit.brush.height", player);
|
||||||
|
Loading…
Reference in New Issue
Block a user