Search in sources :

Example 1 with SnowHeightMap

use of com.sk89q.worldedit.math.convolution.SnowHeightMap 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);
}
Also used : HeightMapFilter(com.sk89q.worldedit.math.convolution.HeightMapFilter) SnowHeightMap(com.sk89q.worldedit.math.convolution.SnowHeightMap) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) Region(com.sk89q.worldedit.regions.Region) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Vector3(com.sk89q.worldedit.math.Vector3) CuboidRegion(com.sk89q.worldedit.regions.CuboidRegion) BlockVector3(com.sk89q.worldedit.math.BlockVector3) GaussianKernel(com.sk89q.worldedit.math.convolution.GaussianKernel)

Example 2 with SnowHeightMap

use of com.sk89q.worldedit.math.convolution.SnowHeightMap 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;
}
Also used : HeightMapFilter(com.sk89q.worldedit.math.convolution.HeightMapFilter) SnowHeightMap(com.sk89q.worldedit.math.convolution.SnowHeightMap) GaussianKernel(com.sk89q.worldedit.math.convolution.GaussianKernel) Logging(com.sk89q.worldedit.command.util.Logging) Preload(com.sk89q.worldedit.command.util.annotation.Preload) Command(org.enginehub.piston.annotation.Command) Confirm(com.sk89q.worldedit.command.util.annotation.Confirm) CommandPermissions(com.sk89q.worldedit.command.util.CommandPermissions)

Aggregations

GaussianKernel (com.sk89q.worldedit.math.convolution.GaussianKernel)2 HeightMapFilter (com.sk89q.worldedit.math.convolution.HeightMapFilter)2 SnowHeightMap (com.sk89q.worldedit.math.convolution.SnowHeightMap)2 CommandPermissions (com.sk89q.worldedit.command.util.CommandPermissions)1 Logging (com.sk89q.worldedit.command.util.Logging)1 Confirm (com.sk89q.worldedit.command.util.annotation.Confirm)1 Preload (com.sk89q.worldedit.command.util.annotation.Preload)1 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)1 Vector3 (com.sk89q.worldedit.math.Vector3)1 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)1 Region (com.sk89q.worldedit.regions.Region)1 Command (org.enginehub.piston.annotation.Command)1