mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
parent
798b4cdd4e
commit
c218743fa8
@ -4,7 +4,6 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.brush.visualization.VisualExtent;
|
||||
import com.boydti.fawe.object.mask.IdMask;
|
||||
import com.boydti.fawe.object.visitor.DFSRecursiveVisitor;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||
@ -14,7 +13,6 @@ import com.sk89q.worldedit.function.mask.MaskIntersection;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MathUtils;
|
||||
import com.sk89q.worldedit.math.MutableVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.math.interpolation.Node;
|
||||
@ -197,15 +195,15 @@ public class SplineBrush implements Brush, ResettableTool {
|
||||
if (det_max == det_x) {
|
||||
double a = (xz * yz - xy * zz) / det_x;
|
||||
double b = (xy * yz - xz * yy) / det_x;
|
||||
dir = BlockVector3.at(1.0, (int) MathUtils.roundHalfUp(a), (int) MathUtils.roundHalfUp(b));
|
||||
dir = BlockVector3.at(1.0, a, b);
|
||||
} else if (det_max == det_y) {
|
||||
double a = (yz * xz - xy * zz) / det_y;
|
||||
double b = (xy * xz - yz * xx) / det_y;
|
||||
dir = BlockVector3.at((int) MathUtils.roundHalfUp(a), 1.0, (int) MathUtils.roundHalfUp(b));
|
||||
dir = BlockVector3.at(a, 1.0, b);
|
||||
} else {
|
||||
double a = (yz * xy - xz * yy) / det_z;
|
||||
double b = (xz * xy - yz * xx) / det_z;
|
||||
dir = BlockVector3.at((int) MathUtils.roundHalfUp(a), (int) MathUtils.roundHalfUp(b), 1.0);
|
||||
dir = BlockVector3.at(a, b, 1.0);
|
||||
}
|
||||
return dir.normalize();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
mutable.mutY(pos.getY() - min.getY());
|
||||
mutable.mutZ(pos.getZ() - min.getZ());
|
||||
MutableVector3 tmp = new MutableVector3(transform.apply(mutable.toVector3()));
|
||||
return min.add(tmp.toBlockPoint());
|
||||
return min.add(tmp.roundHalfUp().toBlockPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,16 +83,31 @@ public abstract class Vector3 {
|
||||
return YzxOrderComparator.YZX_ORDER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the x coordinate rounded, accounting for negative coordinates
|
||||
*
|
||||
* @return the x coordinate
|
||||
*/
|
||||
public int getBlockX() {
|
||||
return (int) MathUtils.roundHalfUp(getX());
|
||||
return MathMan.roundInt(getX());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the y coordinate rounded, accounting for negative coordinates
|
||||
*
|
||||
* @return the y coordinate
|
||||
*/
|
||||
public int getBlockY() {
|
||||
return (int) MathUtils.roundHalfUp(getY());
|
||||
return MathMan.roundInt(getY());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the z coordinate rounded, accounting for negative coordinates
|
||||
*
|
||||
* @return the z coordinate
|
||||
*/
|
||||
public int getBlockZ() {
|
||||
return (int) MathUtils.roundHalfUp(getZ());
|
||||
return MathMan.roundInt(getZ());
|
||||
}
|
||||
|
||||
public MutableVector3 setComponents(Vector3 other) {
|
||||
@ -487,6 +502,15 @@ public abstract class Vector3 {
|
||||
return Vector3.at(Math.floor(getX() + 0.5), Math.floor(getY() + 0.5), Math.floor(getZ() + 0.5));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rounds all components using {@link MathUtils#roundHalfUp(double)}
|
||||
*
|
||||
* @return a new vector
|
||||
*/
|
||||
public Vector3 roundHalfUp() {
|
||||
return Vector3.at(MathUtils.roundHalfUp(getX()), MathUtils.roundHalfUp(getY()), MathUtils.roundHalfUp(getZ()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a vector with the absolute values of the components of
|
||||
* this vector.
|
||||
@ -595,8 +619,7 @@ public abstract class Vector3 {
|
||||
* @return a new {@code BlockVector}
|
||||
*/
|
||||
public static BlockVector3 toBlockPoint(double x, double y, double z) {
|
||||
return BlockVector3.at(MathUtils.roundHalfUp(x), MathUtils.roundHalfUp(y), MathUtils.roundHalfUp(z));
|
||||
//return BlockVector3.at(x, y, z);
|
||||
return BlockVector3.at(x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package com.sk89q.worldedit.util;
|
||||
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
|
||||
@ -80,8 +79,7 @@ public enum Direction {
|
||||
}
|
||||
|
||||
Direction(Vector3 vector, int flags, int left, int right) {
|
||||
this.blockPoint = BlockVector3.at(MathMan.roundInt(Math.signum(vector.getX())),
|
||||
MathMan.roundInt(Math.signum(vector.getY())), MathMan.roundInt(Math.signum(vector.getZ())));
|
||||
this.blockPoint = BlockVector3.at(Math.signum(vector.getX()), Math.signum(vector.getY()), Math.signum(vector.getZ()));
|
||||
this.direction = vector.normalize();
|
||||
this.flags = flags;
|
||||
this.left = left;
|
||||
|
Loading…
Reference in New Issue
Block a user