mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-24 10:17:39 +00:00
Added library support for non-integer radius spheres and cylinders.
This commit is contained in:
parent
a527b59770
commit
9d98ca3db8
@ -1626,36 +1626,37 @@ public class EditSession {
|
|||||||
* @param block
|
* @param block
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
private int makeHCylinderPoints(Vector center, int x, int z, int height,
|
private int makeHCylinderPoints(Vector center, int x, double z, int height,
|
||||||
Pattern block) throws MaxChangedBlocksException {
|
Pattern block) throws MaxChangedBlocksException {
|
||||||
|
int ceilZ = (int) Math.ceil(z);
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
setBlock(center.add(0, y, z), block);
|
setBlock(center.add(0, y, ceilZ), block);
|
||||||
setBlock(center.add(0, y, -z), block);
|
setBlock(center.add(0, y, -ceilZ), block);
|
||||||
setBlock(center.add(z, y, 0), block);
|
setBlock(center.add(ceilZ, y, 0), block);
|
||||||
setBlock(center.add(-z, y, 0), block);
|
setBlock(center.add(-ceilZ, y, 0), block);
|
||||||
affected += 4;
|
affected += 4;
|
||||||
}
|
}
|
||||||
} else if (x == z) {
|
} else if (x == z) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
setBlock(center.add(x, y, z), block);
|
setBlock(center.add(x, y, ceilZ), block);
|
||||||
setBlock(center.add(-x, y, z), block);
|
setBlock(center.add(-x, y, ceilZ), block);
|
||||||
setBlock(center.add(x, y, -z), block);
|
setBlock(center.add(x, y, -ceilZ), block);
|
||||||
setBlock(center.add(-x, y, -z), block);
|
setBlock(center.add(-x, y, -ceilZ), block);
|
||||||
affected += 4;
|
affected += 4;
|
||||||
}
|
}
|
||||||
} else if (x < z) {
|
} else if (x < z) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
setBlock(center.add(x, y, z), block);
|
setBlock(center.add(x, y, ceilZ), block);
|
||||||
setBlock(center.add(-x, y, z), block);
|
setBlock(center.add(-x, y, ceilZ), block);
|
||||||
setBlock(center.add(x, y, -z), block);
|
setBlock(center.add(x, y, -ceilZ), block);
|
||||||
setBlock(center.add(-x, y, -z), block);
|
setBlock(center.add(-x, y, -ceilZ), block);
|
||||||
setBlock(center.add(z, y, x), block);
|
setBlock(center.add(ceilZ, y, x), block);
|
||||||
setBlock(center.add(-z, y, x), block);
|
setBlock(center.add(-ceilZ, y, x), block);
|
||||||
setBlock(center.add(z, y, -x), block);
|
setBlock(center.add(ceilZ, y, -x), block);
|
||||||
setBlock(center.add(-z, y, -x), block);
|
setBlock(center.add(-ceilZ, y, -x), block);
|
||||||
affected += 8;
|
affected += 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1673,11 +1674,11 @@ public class EditSession {
|
|||||||
* @return number of blocks set
|
* @return number of blocks set
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int makeHollowCylinder(Vector pos, Pattern block, int radius,
|
public int makeHollowCylinder(Vector pos, Pattern block, double radius,
|
||||||
int height) throws MaxChangedBlocksException {
|
int height) throws MaxChangedBlocksException {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int z = radius;
|
double z = radius;
|
||||||
int d = (5 - radius * 4) / 4;
|
double d = (5 - radius * 4) / 4;
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
@ -1721,13 +1722,14 @@ public class EditSession {
|
|||||||
* @param block
|
* @param block
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
private int makeCylinderPoints(Vector center, int x, int z, int height,
|
private int makeCylinderPoints(Vector center, int x, double z, int height,
|
||||||
Pattern block) throws MaxChangedBlocksException {
|
Pattern block) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int ceilZ = (int) Math.ceil(z);
|
||||||
|
int affected = 0;
|
||||||
|
|
||||||
if (x == z) {
|
if (x == z) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int z2 = -z; z2 <= z; ++z2) {
|
for (int z2 = -ceilZ; z2 <= ceilZ; ++z2) {
|
||||||
setBlock(center.add(x, y, z2), block);
|
setBlock(center.add(x, y, z2), block);
|
||||||
setBlock(center.add(-x, y, z2), block);
|
setBlock(center.add(-x, y, z2), block);
|
||||||
affected += 2;
|
affected += 2;
|
||||||
@ -1736,12 +1738,12 @@ public class EditSession {
|
|||||||
} else if (x < z) {
|
} else if (x < z) {
|
||||||
for (int y = 0; y < height; ++y) {
|
for (int y = 0; y < height; ++y) {
|
||||||
for (int x2 = -x; x2 <= x; ++x2) {
|
for (int x2 = -x; x2 <= x; ++x2) {
|
||||||
for (int z2 = -z; z2 <= z; ++z2) {
|
for (int z2 = -ceilZ; z2 <= ceilZ; ++z2) {
|
||||||
setBlock(center.add(x2, y, z2), block);
|
setBlock(center.add(x2, y, z2), block);
|
||||||
++affected;
|
++affected;
|
||||||
}
|
}
|
||||||
setBlock(center.add(z, y, x2), block);
|
setBlock(center.add(ceilZ, y, x2), block);
|
||||||
setBlock(center.add(-z, y, x2), block);
|
setBlock(center.add(-ceilZ, y, x2), block);
|
||||||
affected += 2;
|
affected += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1760,11 +1762,11 @@ public class EditSession {
|
|||||||
* @return number of blocks set
|
* @return number of blocks set
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int makeCylinder(Vector pos, Pattern block, int radius, int height)
|
public int makeCylinder(Vector pos, Pattern block, double radius, int height)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int z = radius;
|
double z = radius;
|
||||||
int d = (5 - radius * 4) / 4;
|
double d = (5 - radius * 4) / 4;
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
@ -1807,13 +1809,14 @@ public class EditSession {
|
|||||||
* @return number of blocks changed
|
* @return number of blocks changed
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public int makeSphere(Vector pos, Pattern block, int radius,
|
public int makeSphere(Vector pos, Pattern block, double radius,
|
||||||
boolean filled) throws MaxChangedBlocksException {
|
boolean filled) throws MaxChangedBlocksException {
|
||||||
int affected = 0;
|
int affected = 0;
|
||||||
|
|
||||||
for (int x = 0; x <= radius; ++x) {
|
int ceilRadius = (int) Math.ceil(radius);
|
||||||
for (int y = 0; y <= radius; ++y) {
|
for (int x = 0; x <= ceilRadius; ++x) {
|
||||||
for (int z = 0; z <= radius; ++z) {
|
for (int y = 0; y <= ceilRadius; ++y) {
|
||||||
|
for (int z = 0; z <= ceilRadius; ++z) {
|
||||||
Vector vec = pos.add(x, y, z);
|
Vector vec = pos.add(x, y, z);
|
||||||
double d = vec.distance(pos);
|
double d = vec.distance(pos);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ public class BrushTool implements TraceTool {
|
|||||||
private Mask mask = null;
|
private Mask mask = null;
|
||||||
private Brush brush = new SphereBrush();
|
private Brush brush = new SphereBrush();
|
||||||
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||||
private int size = 1;
|
private double size = 1;
|
||||||
private String permission;
|
private String permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,17 +125,17 @@ public class BrushTool implements TraceTool {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getSize() {
|
public double getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the set brush size.
|
* Set the set brush size.
|
||||||
*
|
*
|
||||||
* @param size
|
* @param radius
|
||||||
*/
|
*/
|
||||||
public void setSize(int size) {
|
public void setSize(double radius) {
|
||||||
this.size = size;
|
this.size = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +39,6 @@ public interface Brush {
|
|||||||
* @param size
|
* @param size
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException;
|
throws MaxChangedBlocksException;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class ClipboardBrush implements Brush {
|
|||||||
this.noAir = noAir;
|
this.noAir = noAir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
clipboard.place(editSession,
|
clipboard.place(editSession,
|
||||||
pos.subtract(clipboard.getSize().divide(2)), noAir);
|
pos.subtract(clipboard.getSize().divide(2)), noAir);
|
||||||
|
@ -31,7 +31,7 @@ public class CylinderBrush implements Brush {
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeCylinder(pos, mat, size, height);
|
editSession.makeCylinder(pos, mat, size, height);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class HollowCylinderBrush implements Brush {
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeHollowCylinder(pos, mat, size, height);
|
editSession.makeHollowCylinder(pos, mat, size, height);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class HollowSphereBrush implements Brush {
|
|||||||
public HollowSphereBrush() {
|
public HollowSphereBrush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeSphere(pos, mat, size, false);
|
editSession.makeSphere(pos, mat, size, false);
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,9 @@ public class SmoothBrush implements Brush {
|
|||||||
this.iterations = iterations;
|
this.iterations = iterations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
int rad = size;
|
double rad = size;
|
||||||
Vector min = pos.subtract(rad, rad, rad);
|
Vector min = pos.subtract(rad, rad, rad);
|
||||||
Vector max = pos.add(rad, rad + 10, rad);
|
Vector max = pos.add(rad, rad + 10, rad);
|
||||||
Region region = new CuboidRegion(min, max);
|
Region region = new CuboidRegion(min, max);
|
||||||
|
@ -28,7 +28,7 @@ public class SphereBrush implements Brush {
|
|||||||
public SphereBrush() {
|
public SphereBrush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, int size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeSphere(pos, mat, size, true);
|
editSession.makeSphere(pos, mat, size, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user