This commit is contained in:
Jesse Boyd 2017-01-09 14:39:55 +11:00
parent f6db2cf7d3
commit 21c77a2fc8
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 14 additions and 7 deletions

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.brush.heightmap;
import com.boydti.fawe.object.IntegerPair;
import com.boydti.fawe.object.PseudoRandom;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -145,8 +146,12 @@ public class ScalableHeightMap {
Region region = new CuboidRegion(session.getWorld(), min, max);
HeightMap heightMap = new HeightMap(session, region, true);
if (smooth) {
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1));
newData = filter.filter(newData, diameter, diameter);
try {
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
newData = filter.filter(newData, diameter, diameter);
} catch (Throwable e) {
MainUtil.handleError(e);
}
}
heightMap.apply(newData);
}

View File

@ -474,11 +474,13 @@ public class RegionCommands {
@Logging(REGION)
public void smooth(Player player, EditSession editSession, @Selection Region region, @Optional("1") int iterations, @Switch('n') boolean affectNatural) throws WorldEditException {
HeightMap heightMap = new HeightMap(editSession, region, affectNatural);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations);
BBC.VISITOR_BLOCK.send(player, affected);
try {
HeightMapFilter filter = (HeightMapFilter) HeightMapFilter.class.getConstructors()[0].newInstance(GaussianKernel.class.getConstructors()[0].newInstance(5, 1));
int affected = heightMap.applyFilter(filter, iterations);
BBC.VISITOR_BLOCK.send(player, affected);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
@Command(