mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
commanding-pipeline diff
This commit is contained in:
@ -331,4 +331,9 @@ public class ConvexPolyhedralRegion extends AbstractRegion {
|
||||
public AbstractRegion clone() {
|
||||
return new ConvexPolyhedralRegion(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -22,22 +22,28 @@ package com.sk89q.worldedit.regions;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.beta.IBatchProcessor;
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.boydti.fawe.config.Settings;
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector2;
|
||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -631,14 +637,15 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
int z = chunk.getZ();
|
||||
block = block.init(x, z, get);
|
||||
|
||||
|
||||
if ((minX + 15) >> 4 <= x && (maxX - 15) >> 4 >= x && (minZ + 15) >> 4 <= z && (maxZ - 15) >> 4 >= z) {
|
||||
filter(chunk, filter, block, get, set, minY, maxY);
|
||||
return;
|
||||
}
|
||||
int localMinX = Math.max(minX, x << 4) & 15;
|
||||
int localMaxX = Math.min(maxX, 15 + x << 4) & 15;
|
||||
int localMaxX = Math.min(maxX, 15 + (x << 4)) & 15;
|
||||
int localMinZ = Math.max(minZ, z << 4) & 15;
|
||||
int localMaxZ = Math.min(maxZ, 15 + z << 4) & 15;
|
||||
int localMaxZ = Math.min(maxZ, 15 + (z << 4)) & 15;
|
||||
|
||||
int yStart = (minY & 15);
|
||||
int yEnd = (maxY & 15);
|
||||
@ -657,8 +664,87 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
filter(chunk, filter, block, get, set, minSection, localMinX, 0, localMinZ, localMaxX, 15, localMaxZ);
|
||||
maxSection--;
|
||||
}
|
||||
for (int layer = minSection; layer < maxSection; layer++) {
|
||||
for (int layer = minSection; layer <= maxSection; layer++) {
|
||||
filter(chunk, filter, block, get, set, layer, localMinX, yStart, localMinZ, localMaxX, yEnd, localMaxZ);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
int bx = chunk.getX() << 4;
|
||||
int bz = chunk.getZ() << 4;
|
||||
int tx = bx + 15;
|
||||
int tz = bz + 15;
|
||||
if (bx >= minX && tx <= maxX && bz >= minZ && tz <= maxZ) {
|
||||
// contains all X/Z
|
||||
if (minY <= 0 && maxY >= 255) {
|
||||
return set;
|
||||
}
|
||||
trimY(set, minY, maxY);
|
||||
trimNBT(set, this::contains);
|
||||
return set;
|
||||
}
|
||||
else if (tx >= minX && bx <= maxX && tz >= minZ && bz <= maxZ) {
|
||||
trimY(set, minY, maxY);
|
||||
final int lowerX = Math.max(0, minX - bx);
|
||||
final int upperX = Math.min(15, 15 + maxX - tx);
|
||||
|
||||
final int lowerZ = Math.max(0, minZ - bz);
|
||||
final int upperZ = Math.min(15, 15 + maxZ - tz);
|
||||
|
||||
final int upperZi = ((upperZ + 1) << 4);
|
||||
final int lowerZi = (lowerZ << 4);
|
||||
|
||||
boolean trimX = lowerX != 0 || upperX != 15;
|
||||
boolean trimZ = lowerZ != 0 || upperZ != 15;
|
||||
|
||||
int indexY, index;
|
||||
for (int layer = 0; layer < FaweCache.IMP.CHUNK_LAYERS; layer++) {
|
||||
if (set.hasSection(layer)) {
|
||||
char[] arr = set.getArray(layer);
|
||||
if (trimX || trimZ) {
|
||||
indexY = 0;
|
||||
for (int y = 0; y < 16; y++, indexY += 256) {
|
||||
if (trimZ) {
|
||||
index = indexY;
|
||||
for (int z = 0; z < lowerZ; z++) {
|
||||
// null the z values
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
arr[index] = 0;
|
||||
}
|
||||
}
|
||||
index = indexY + upperZi;
|
||||
for (int z = upperZ + 1; z < 16; z++) {
|
||||
// null the z values
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
arr[index] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (trimX) {
|
||||
index = indexY + lowerZi;
|
||||
for (int z = lowerZ; z <= upperZ; z++, index += 16) {
|
||||
for (int x = 0; x < lowerX; x++) {
|
||||
// null the x values
|
||||
arr[index + x] = 0;
|
||||
}
|
||||
for (int x = upperX + 1; x < 16; x++) {
|
||||
// null the x values
|
||||
arr[index + x] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
set.setBlocks(layer, arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
trimNBT(set, this::contains);
|
||||
return set;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -246,10 +246,18 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
return cxd + cyd + czd <= 1;
|
||||
}
|
||||
|
||||
/*
|
||||
/* Slow and unnecessary
|
||||
@Override
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return position.subtract(center).toVector3().divide(radius).lengthSq() <= 1;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean contains(BlockVector3 position) {
|
||||
return contains(position.getX(), position.getY(), position.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int x, int z) {
|
||||
|
@ -473,4 +473,20 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
return points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
||||
for (int x = bx; x <= tx; x++) {
|
||||
if (!contains(x, 0, bz)) return false;
|
||||
}
|
||||
for (int x = bx; x <= tx; x++) {
|
||||
if (!contains(x, 0, tz)) return false;
|
||||
}
|
||||
for (int z = bz; z <= tz; z++) {
|
||||
if (!contains(bx, 0, z)) return false;
|
||||
}
|
||||
for (int z = bz; z <= tz; z++) {
|
||||
if (!contains(tx, 0, z)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,23 +19,32 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.beta.IBatchProcessor;
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.extent.SingleRegionExtent;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents a physical shape.
|
||||
*/
|
||||
public interface Region extends Iterable<BlockVector3>, Cloneable {
|
||||
public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcessor {
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
@ -221,7 +230,7 @@ public interface Region extends Iterable<BlockVector3>, Cloneable {
|
||||
filter(chunk, filter, block, get, set, minSection, 0, yEnd);
|
||||
maxSection--;
|
||||
}
|
||||
for (int layer = minSection; layer < maxSection; layer++) {
|
||||
for (int layer = minSection; layer <= maxSection; layer++) {
|
||||
filter(chunk, filter, block, get, set, layer);
|
||||
}
|
||||
return;
|
||||
@ -244,4 +253,66 @@ public interface Region extends Iterable<BlockVector3>, Cloneable {
|
||||
block = block.init(get, set, layer);
|
||||
block.filter(filter, yStart, yEnd);
|
||||
}
|
||||
|
||||
default boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
||||
return contains(bx, by, bz) &&
|
||||
contains(bx, by, tz) &&
|
||||
contains(tx, by, bz) &&
|
||||
contains(tx, by, tz) &&
|
||||
contains(bx, ty, bz) &&
|
||||
contains(bx, ty, tz) &&
|
||||
contains(tx, ty, bz) &&
|
||||
contains(tx, ty, tz);
|
||||
}
|
||||
|
||||
default IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
int bx = chunk.getX() << 4;
|
||||
int bz = chunk.getZ() << 4;
|
||||
int tx = bx + 15;
|
||||
int tz = bz + 15;
|
||||
|
||||
BlockVector3 min = getMinimumPoint();
|
||||
BlockVector3 max = getMaximumPoint();
|
||||
boolean processExtra = false;
|
||||
if (tx >= min.getX() && bx <= max.getX() && tz >= min.getZ() && bz <= max.getZ()) {
|
||||
// contains some
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
int by = layer << 4;
|
||||
int ty = by + 15;
|
||||
if (containsEntireCuboid(bx, tx, by, ty, bz, tz)) {
|
||||
continue;
|
||||
} else {
|
||||
boolean changed = true;
|
||||
processExtra = true;
|
||||
char[] arr = set.getArray(layer);
|
||||
for (int y = 0, index = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int x = 0; x < 16; x++, index++) {
|
||||
if (arr[index] != 0 && !contains(x, y, z)) {
|
||||
changed = true;
|
||||
arr[index] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
set.setBlocks(layer, arr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (processExtra) {
|
||||
trimNBT(set, this::contains);
|
||||
}
|
||||
return set;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
default Extent construct(Extent child) {
|
||||
if (isGlobal()) {
|
||||
return child;
|
||||
}
|
||||
return new SingleRegionExtent(child, FaweLimit.MAX, this);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -141,4 +144,29 @@ public class RegionIntersection extends AbstractRegion {
|
||||
return Iterators.concat(iterators);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsEntireCuboid(int bx, int tx, int by, int ty, int bz, int tz) {
|
||||
for (Region region : regions) {
|
||||
if (region.containsEntireCuboid(bx, tx, by, ty, bz, tz)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processBatch(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
int bx = chunk.getX() << 4;
|
||||
int bz = chunk.getZ() << 4;
|
||||
int tx = bx + 15;
|
||||
int tz = bz + 15;
|
||||
for (Region region : regions) {
|
||||
BlockVector3 regMin = region.getMinimumPoint();
|
||||
BlockVector3 regMax = region.getMaximumPoint();
|
||||
if (tx >= regMin.getX() && bx <= regMax.getX() && tz >= regMin.getZ() && bz <= regMax.getZ()) {
|
||||
return region.processBatch(chunk, get, set);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user