use of com.sk89q.worldedit.math.convolution.GaussianKernel in project FastAsyncWorldEdit by IntellectualSites.
the class SnowSmoothBrush method build.
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
Vector3 posDouble = position.toVector3();
BlockVector3 min = posDouble.subtract(size, size, size).toBlockPoint();
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
Region region = new CuboidRegion(editSession.getWorld(), min, max);
SnowHeightMap heightMap = new SnowHeightMap(editSession, region, mask);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(10, 1.0));
float[] data = heightMap.applyFilter(filter, iterations);
heightMap.applyChanges(data, snowBlockLayer);
}
use of com.sk89q.worldedit.math.convolution.GaussianKernel in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method snowSmooth.
@Command(name = "/snowsmooth", desc = "Smooth the elevation in the selection with snow layers", descFooter = "Example: '//snowsmooth 1 -m snow_block,snow' would only smooth snow terrain.")
@CommandPermissions("worldedit.region.snowsmooth")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int snowSmooth(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "# of iterations to perform", def = "1") int iterations, @ArgFlag(name = 'l', desc = "Set the amount of snow blocks under the snow", def = "1") int snowBlockCount, @ArgFlag(name = 'm', desc = "The mask of blocks to use as the height map") Mask mask) throws WorldEditException {
SnowHeightMap heightMap = new SnowHeightMap(editSession, region, mask);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
float[] changed = heightMap.applyFilter(filter, iterations);
int affected = heightMap.applyChanges(changed, snowBlockCount);
actor.print(Caption.of("worldedit.snowsmooth.changed", TextComponent.of(affected)));
return affected;
}
use of com.sk89q.worldedit.math.convolution.GaussianKernel in project FastAsyncWorldEdit by IntellectualSites.
the class SmoothBrush method build.
@Override
public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws MaxChangedBlocksException {
Vector3 posDouble = position.toVector3();
Location min = new Location(editSession.getWorld(), posDouble.subtract(size, size, size));
BlockVector3 max = posDouble.add(size, size + 10, size).toBlockPoint();
Region region = new CuboidRegion(editSession.getWorld(), min.toVector().toBlockPoint(), max);
HeightMap heightMap = new HeightMap(editSession, region, mask);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
heightMap.applyFilter(filter, iterations);
}
use of com.sk89q.worldedit.math.convolution.GaussianKernel in project FastAsyncWorldEdit by IntellectualSites.
the class RegionCommands method smooth.
@Command(name = "/smooth", desc = "Smooth the elevation in the selection", descFooter = "Example: '//smooth 1 grass_block,dirt,stone' would only smooth natural surface terrain.")
@CommandPermissions("worldedit.region.smooth")
@Logging(REGION)
@Preload(Preload.PreloadCheck.PRELOAD)
@Confirm(Confirm.Processor.REGION)
public int smooth(Actor actor, EditSession editSession, @Selection Region region, @Arg(desc = "# of iterations to perform", def = "1") int iterations, @Arg(desc = "The mask of blocks to use as the height map", def = "") Mask mask) throws WorldEditException {
// FAWE start > the mask will have been initialised with a WorldWrapper extent (very bad/slow)
new MaskTraverser(mask).setNewExtent(editSession);
// FAWE end
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1));
FaweLimit limit = actor.getLimit();
if (volume >= limit.MAX_CHECKS) {
throw FaweCache.MAX_CHECKS;
}
int affected;
try {
HeightMap heightMap = new HeightMap(editSession, region, mask);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
affected = heightMap.applyFilter(filter, iterations);
actor.print(Caption.of("worldedit.smooth.changed", TextComponent.of(affected)));
} catch (Throwable e) {
throw new RuntimeException(e);
}
return affected;
}
Aggregations