Skip to content

Commit fa74a77

Browse files
authored
made clonestamp brush clone blocks only above the target block (but including the target itself) (#242)
* made clonestamp brush clone blocks only above the target block (but including the target itself) * Small optimization * imports
1 parent 575f416 commit fa74a77

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

VoxelSniperCore/src/main/java/com/github/kevindagame/brush/CloneStampBrush.java

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
import com.github.kevindagame.util.Shapes;
88
import com.github.kevindagame.util.Utils;
99
import com.github.kevindagame.util.VoxelMessage;
10-
import com.github.kevindagame.voxelsniper.location.BaseLocation;
1110
import com.github.kevindagame.voxelsniper.location.VoxelLocation;
1211
import org.jetbrains.annotations.NotNull;
1312

14-
import java.util.ArrayList;
1513
import java.util.List;
1614

1715
/**
@@ -22,9 +20,6 @@
2220
*/
2321
public class CloneStampBrush extends StampBrush {
2422

25-
private BaseLocation startingPoint;
26-
27-
2823
/**
2924
* The clone method is used to grab a snapshot of the selected area dictated blockPositionY targetBlock.x y z v.brushSize v.voxelHeight and v.cCen.
3025
* <p/>
@@ -34,10 +29,9 @@ public class CloneStampBrush extends StampBrush {
3429
* @param v the caller
3530
*/
3631
private void clone(final SnipeData v) {
37-
VoxelLocation point = getTargetBlock().getLocation().makeMutable();
38-
point.add(0, v.getcCen(), 0);
39-
this.startingPoint = point.makeImmutable();
40-
var positions = Shapes.cylinder(startingPoint, RotationAxis.Y, v.getBrushSize(), v.getVoxelHeight(), 0, false);
32+
VoxelLocation startingPoint = getTargetBlock().getLocation().makeMutable();
33+
startingPoint.add(0, v.getcCen(), 0);
34+
var positions = Shapes.cylinder(startingPoint, RotationAxis.Y, v.getBrushSize(), v.getVoxelHeight(), (v.getVoxelHeight() / 2.0) - 1, false);
4135
this.clone.clear();
4236
this.toStamp.clear();
4337
this.sorted = false;

VoxelSniperCore/src/main/java/com/github/kevindagame/util/Shapes.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.github.kevindagame.util;
22

3-
import com.github.kevindagame.snipe.Undo;
43
import com.github.kevindagame.voxelsniper.block.BlockFace;
54
import com.github.kevindagame.voxelsniper.block.IBlock;
65
import com.github.kevindagame.voxelsniper.location.BaseLocation;
@@ -81,7 +80,7 @@ public static List<BaseLocation> voxelDisc(BaseLocation location, int brushSize)
8180
return positions;
8281
}
8382

84-
public static List<BaseLocation> cylinder(BaseLocation centerPoint, RotationAxis axis, int brushSize, int height, int shift, boolean smooth) {
83+
public static List<BaseLocation> cylinder(BaseLocation centerPoint, RotationAxis axis, int brushSize, int height, double shift, boolean smooth) {
8584
List<BaseLocation> positions = new ArrayList<>();
8685
for (int y = 0; y < height; y++) {
8786
var pos = axis.getLocationTranslator().invoke(centerPoint.getWorld(), 0, (int) (y - (height / 2.0) + 1 + shift), 0);
@@ -121,8 +120,6 @@ public static List<BaseLocation> dome(BaseLocation location, int brushSize, int
121120
final int absoluteHeight = Math.abs(height);
122121
final boolean negative = height < 0;
123122

124-
final Undo undo = new Undo();
125-
126123
final int brushSizeTimesVoxelHeight = brushSize * absoluteHeight;
127124
final double stepScale = ((brushSize * brushSize) + brushSizeTimesVoxelHeight + brushSizeTimesVoxelHeight) / 5.0;
128125

0 commit comments

Comments
 (0)