Skip to content

Commit

Permalink
made clonestamp brush clone blocks only above the target block (but i…
Browse files Browse the repository at this point in the history
…ncluding the target itself) (#242)

* made clonestamp brush clone blocks only above the target block (but including the target itself)

* Small optimization

* imports
  • Loading branch information
Lennart99 authored Sep 18, 2024
1 parent 575f416 commit fa74a77
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
import com.github.kevindagame.util.Shapes;
import com.github.kevindagame.util.Utils;
import com.github.kevindagame.util.VoxelMessage;
import com.github.kevindagame.voxelsniper.location.BaseLocation;
import com.github.kevindagame.voxelsniper.location.VoxelLocation;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
Expand All @@ -22,9 +20,6 @@
*/
public class CloneStampBrush extends StampBrush {

private BaseLocation startingPoint;


/**
* 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.
* <p/>
Expand All @@ -34,10 +29,9 @@ public class CloneStampBrush extends StampBrush {
* @param v the caller
*/
private void clone(final SnipeData v) {
VoxelLocation point = getTargetBlock().getLocation().makeMutable();
point.add(0, v.getcCen(), 0);
this.startingPoint = point.makeImmutable();
var positions = Shapes.cylinder(startingPoint, RotationAxis.Y, v.getBrushSize(), v.getVoxelHeight(), 0, false);
VoxelLocation startingPoint = getTargetBlock().getLocation().makeMutable();
startingPoint.add(0, v.getcCen(), 0);
var positions = Shapes.cylinder(startingPoint, RotationAxis.Y, v.getBrushSize(), v.getVoxelHeight(), (v.getVoxelHeight() / 2.0) - 1, false);
this.clone.clear();
this.toStamp.clear();
this.sorted = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.github.kevindagame.util;

import com.github.kevindagame.snipe.Undo;
import com.github.kevindagame.voxelsniper.block.BlockFace;
import com.github.kevindagame.voxelsniper.block.IBlock;
import com.github.kevindagame.voxelsniper.location.BaseLocation;
Expand Down Expand Up @@ -81,7 +80,7 @@ public static List<BaseLocation> voxelDisc(BaseLocation location, int brushSize)
return positions;
}

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

final Undo undo = new Undo();

final int brushSizeTimesVoxelHeight = brushSize * absoluteHeight;
final double stepScale = ((brushSize * brushSize) + brushSizeTimesVoxelHeight + brushSizeTimesVoxelHeight) / 5.0;

Expand Down

0 comments on commit fa74a77

Please sign in to comment.