mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 04:46:40 +00:00
Move vectors to static creators, for caching
This commit is contained in:
committed by
IronApollo
parent
a9919d130c
commit
4d6045813c
@ -88,10 +88,10 @@ public abstract class AbstractRegion implements Region {
|
||||
|
||||
final List<BlockVector2> points = new ArrayList<>(4);
|
||||
|
||||
points.add(new BlockVector2(min.getX(), min.getZ()));
|
||||
points.add(new BlockVector2(min.getX(), max.getZ()));
|
||||
points.add(new BlockVector2(max.getX(), max.getZ()));
|
||||
points.add(new BlockVector2(max.getX(), min.getZ()));
|
||||
points.add(BlockVector2.at(min.getX(), min.getZ()));
|
||||
points.add(BlockVector2.at(min.getX(), max.getZ()));
|
||||
points.add(BlockVector2.at(max.getX(), max.getZ()));
|
||||
points.add(BlockVector2.at(max.getX(), min.getZ()));
|
||||
|
||||
return points;
|
||||
}
|
||||
@ -166,11 +166,11 @@ public abstract class AbstractRegion implements Region {
|
||||
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||
if (!contains(new BlockVector3(x, minY, z))) {
|
||||
if (!contains(BlockVector3.at(x, minY, z))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chunks.add(new BlockVector2(
|
||||
chunks.add(BlockVector2.at(
|
||||
x >> ChunkStore.CHUNK_SHIFTS,
|
||||
z >> ChunkStore.CHUNK_SHIFTS
|
||||
));
|
||||
@ -190,11 +190,11 @@ public abstract class AbstractRegion implements Region {
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||
for (int y = min.getBlockY(); y <= max.getBlockY(); ++y) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||
if (!contains(new BlockVector3(x, y, z))) {
|
||||
if (!contains(BlockVector3.at(x, y, z))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chunks.add(new BlockVector3(
|
||||
chunks.add(BlockVector3.at(
|
||||
x >> ChunkStore.CHUNK_SHIFTS,
|
||||
y >> ChunkStore.CHUNK_SHIFTS,
|
||||
z >> ChunkStore.CHUNK_SHIFTS
|
||||
|
@ -349,10 +349,17 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
};
|
||||
}
|
||||
|
||||
//<<<<<<< HEAD
|
||||
@Override
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
//=======
|
||||
// for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) {
|
||||
// for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) {
|
||||
// chunks.add(BlockVector2.at(x, z));
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
@ -381,7 +388,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
for (int x = min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x <= max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; ++x) {
|
||||
for (int z = min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z <= max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; ++z) {
|
||||
for (int y = min.getBlockY() >> ChunkStore.CHUNK_SHIFTS; y <= max.getBlockY() >> ChunkStore.CHUNK_SHIFTS; ++y) {
|
||||
chunks.add(new BlockVector3(x, y, z));
|
||||
chunks.add(BlockVector3.at(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -463,6 +470,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
@Override
|
||||
public BlockVector3 next() {
|
||||
//<<<<<<< HEAD
|
||||
mutable.mutX(x);
|
||||
mutable.mutY(y);
|
||||
mutable.mutZ(z);
|
||||
@ -498,6 +506,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
} else {
|
||||
x = cbx;
|
||||
z = cbz;
|
||||
//=======
|
||||
// if (!hasNext()) throw new NoSuchElementException();
|
||||
// BlockVector3 answer = BlockVector3.at(nextX, nextY, nextZ);
|
||||
// if (++nextX > max.getBlockX()) {
|
||||
// nextX = min.getBlockX();
|
||||
// if (++nextY > max.getBlockY()) {
|
||||
// nextY = min.getBlockY();
|
||||
// if (++nextZ > max.getBlockZ()) {
|
||||
// nextX = Integer.MIN_VALUE;
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
}
|
||||
} else {
|
||||
x = cbx;
|
||||
@ -525,10 +543,16 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
}
|
||||
|
||||
@Override
|
||||
//<<<<<<< HEAD
|
||||
public BlockVector3 next() {
|
||||
mutable.mutX(nextX);
|
||||
mutable.mutY(nextY);
|
||||
mutable.mutZ(nextZ);
|
||||
//=======
|
||||
// public BlockVector2 next() {
|
||||
// if (!hasNext()) throw new NoSuchElementException();
|
||||
// BlockVector2 answer = BlockVector2.at(nextX, nextZ);
|
||||
//>>>>>>> 2c8b2fe0... Move vectors to static creators, for caching
|
||||
if (++nextX > max.getBlockX()) {
|
||||
nextX = min.getBlockX();
|
||||
if (++nextZ > max.getBlockZ()) {
|
||||
@ -575,7 +599,7 @@ public class CuboidRegion extends AbstractRegion implements FlatRegion {
|
||||
public BlockVector2 next() {
|
||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||
// BlockVector2 answer = mutable.setComponents(nextX, nextZ);
|
||||
BlockVector2 answer = new BlockVector2(nextX, nextZ);
|
||||
BlockVector2 answer = BlockVector2.at(nextX, nextZ);
|
||||
if (++nextX > max.getBlockX()) {
|
||||
nextX = min.getBlockX();
|
||||
if (++nextZ > max.getBlockZ()) {
|
||||
|
@ -268,7 +268,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
center = center.subtract(calculateDiff2D(changes));
|
||||
Vector2 newRadius = radius.subtract(calculateChanges2D(changes).toVector2());
|
||||
radius = new Vector2(1.5, 1.5).getMaximum(newRadius);
|
||||
radius = Vector2.at(1.5, 1.5).getMaximum(newRadius);
|
||||
this.radiusInverse = Vector2.ONE.divide(radius);
|
||||
for (BlockVector3 change : changes) {
|
||||
int height = maxY - minY;
|
||||
@ -377,7 +377,7 @@ public class CylinderRegion extends AbstractRegion implements FlatRegion {
|
||||
public static CylinderRegion createRadius(Extent extent, BlockVector3 center, double radius) {
|
||||
checkNotNull(extent);
|
||||
checkNotNull(center);
|
||||
Vector2 radiusVec = new Vector2(radius, radius);
|
||||
Vector2 radiusVec = Vector2.at(radius, radius);
|
||||
int minY = extent.getMinimumPoint().getBlockY();
|
||||
int maxY = extent.getMaximumPoint().getBlockY();
|
||||
return new CylinderRegion(center, radiusVec, minY, maxY);
|
||||
|
@ -136,7 +136,7 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
public void contract(BlockVector3... changes) throws RegionOperationException {
|
||||
center = center.subtract(calculateDiff(changes));
|
||||
Vector3 newRadius = radius.subtract(calculateChanges(changes).toVector3());
|
||||
setRadius(new Vector3(1.5, 1.5, 1.5).getMaximum(newRadius));
|
||||
setRadius(Vector3.at(1.5, 1.5, 1.5).getMaximum(newRadius));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -199,11 +199,11 @@ public class EllipsoidRegion extends AbstractRegion {
|
||||
|
||||
for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) {
|
||||
for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) {
|
||||
if (!contains(new BlockVector3(x, centerY, z))) {
|
||||
if (!contains(BlockVector3.at(x, centerY, z))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
chunks.add(new BlockVector2(
|
||||
chunks.add(BlockVector2.at(
|
||||
x >> ChunkStore.CHUNK_SHIFTS,
|
||||
z >> ChunkStore.CHUNK_SHIFTS
|
||||
));
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.regions;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector2;
|
||||
import com.sk89q.worldedit.regions.iterator.FlatRegion3DIterator;
|
||||
import com.sk89q.worldedit.regions.iterator.FlatRegionIterator;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
@ -131,8 +130,8 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
minY = Math.min(Math.max(0, minY), world == null ? 255 : world.getMaxY());
|
||||
maxY = Math.min(Math.max(0, maxY), world == null ? 255 : world.getMaxY());
|
||||
|
||||
min = new BlockVector2(minX, minZ);
|
||||
max = new BlockVector2(maxX, maxZ);
|
||||
min = BlockVector2.at(minX, minZ);
|
||||
max = BlockVector2.at(maxX, maxZ);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,7 +150,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
* @param position the position
|
||||
*/
|
||||
public void addPoint(BlockVector3 position) {
|
||||
points.add(new BlockVector2(position.getBlockX(), position.getBlockZ()));
|
||||
points.add(BlockVector2.at(position.getBlockX(), position.getBlockZ()));
|
||||
recalculate();
|
||||
}
|
||||
|
||||
@ -267,7 +266,7 @@ public class Polygonal2DRegion extends AbstractRegion implements FlatRegion {
|
||||
|
||||
for (int i = 0; i < points.size(); ++i) {
|
||||
BlockVector2 point = points.get(i);
|
||||
points.set(i, new BlockVector2(point.getX() + changeX, point.getZ() + changeZ));
|
||||
points.set(i, BlockVector2.at(point.getX() + changeX, point.getZ() + changeZ));
|
||||
}
|
||||
|
||||
minY += changeY;
|
||||
|
@ -34,7 +34,7 @@ public class CylinderRegionFactory implements RegionFactory {
|
||||
|
||||
@Override
|
||||
public Region createCenteredAt(BlockVector3 position, double size) {
|
||||
return new CylinderRegion(position, new Vector2(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2));
|
||||
return new CylinderRegion(position, Vector2.at(size, size), position.getBlockY() - (int) (height / 2), position.getBlockY() + (int) (height / 2));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class SphereRegionFactory implements RegionFactory {
|
||||
|
||||
@Override
|
||||
public Region createCenteredAt(BlockVector3 position, double size) {
|
||||
return new EllipsoidRegion(position, new Vector3(size, size, size));
|
||||
return new EllipsoidRegion(position, Vector3.at(size, size, size));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public class FlatRegion3DIterator implements Iterator<BlockVector3> {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
BlockVector3 current = new BlockVector3(next2D.getBlockX(), nextY, next2D.getBlockZ());
|
||||
BlockVector3 current = BlockVector3.at(next2D.getBlockX(), nextY, next2D.getBlockZ());
|
||||
if (nextY < maxY) {
|
||||
nextY++;
|
||||
} else if (flatIterator.hasNext()) {
|
||||
|
@ -67,7 +67,7 @@ public class FlatRegionIterator implements Iterator<BlockVector2> {
|
||||
}
|
||||
|
||||
private void forward() {
|
||||
while (hasNext() && !region.contains(nextX, y, nextZ)) {
|
||||
while (hasNext() && !region.contains(BlockVector3.at(nextX, y, nextZ))) {
|
||||
forwardOne();
|
||||
}
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class FlatRegionIterator implements Iterator<BlockVector2> {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
|
||||
BlockVector2 answer = new BlockVector2(nextX, nextZ);
|
||||
BlockVector2 answer = BlockVector2.at(nextX, nextZ);
|
||||
|
||||
forwardOne();
|
||||
forward();
|
||||
|
@ -63,7 +63,7 @@ public class RegionIterator implements Iterator<BlockVector3> {
|
||||
}
|
||||
|
||||
private void forward() {
|
||||
while (hasNext() && !region.contains(new BlockVector3(nextX, nextY, nextZ))) {
|
||||
while (hasNext() && !region.contains(BlockVector3.at(nextX, nextY, nextZ))) {
|
||||
forwardOne();
|
||||
}
|
||||
}
|
||||
@ -72,7 +72,7 @@ public class RegionIterator implements Iterator<BlockVector3> {
|
||||
public BlockVector3 next() {
|
||||
if (!hasNext()) throw new java.util.NoSuchElementException();
|
||||
|
||||
BlockVector3 answer = new BlockVector3(nextX, nextY, nextZ);
|
||||
BlockVector3 answer = BlockVector3.at(nextX, nextY, nextZ);
|
||||
|
||||
forwardOne();
|
||||
forward();
|
||||
|
@ -115,8 +115,8 @@ public class ExtendingCuboidRegionSelector extends CuboidRegionSelector {
|
||||
|
||||
final BlockVector3 o1 = position1;
|
||||
final BlockVector3 o2 = position2;
|
||||
position1 = new BlockVector3(x1, y1, z1);
|
||||
position2 = new BlockVector3(x2, y2, z2);
|
||||
position1 = BlockVector3.at(x1, y1, z1);
|
||||
position2 = BlockVector3.at(x2, y2, z2);
|
||||
region.setPos1(position1);
|
||||
region.setPos2(position2);
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
checkNotNull(points);
|
||||
|
||||
final BlockVector2 pos2D = points.get(0);
|
||||
pos1 = new BlockVector3(pos2D.getX(), minY, pos2D.getZ());
|
||||
pos1 = BlockVector3.at(pos2D.getX(), minY, pos2D.getZ());
|
||||
region = new Polygonal2DRegion(world, points, minY, maxY);
|
||||
}
|
||||
|
||||
@ -222,7 +222,7 @@ public class Polygonal2DRegionSelector implements RegionSelector, CUIRegion {
|
||||
@Override
|
||||
public void learnChanges() {
|
||||
BlockVector2 pt = region.getPoints().get(0);
|
||||
pos1 = new BlockVector3(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
|
||||
pos1 = BlockVector3.at(pt.getBlockX(), region.getMinimumPoint().getBlockY(), pt.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -59,7 +59,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
super(oldSelector);
|
||||
final Vector3 radius = region.getRadius();
|
||||
final double radiusScalar = Math.max(Math.max(radius.getX(), radius.getY()), radius.getZ());
|
||||
region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar));
|
||||
region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
* @param radius the radius
|
||||
*/
|
||||
public SphereRegionSelector(@Nullable World world, BlockVector3 center, int radius) {
|
||||
super(world, center, new Vector3(radius, radius, radius));
|
||||
super(world, center, Vector3.at(radius, radius, radius));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,7 +80,7 @@ public class SphereRegionSelector extends EllipsoidRegionSelector {
|
||||
}
|
||||
|
||||
final double radiusScalar = Math.ceil(position.toVector3().distance(region.getCenter()));
|
||||
region.setRadius(new Vector3(radiusScalar, radiusScalar, radiusScalar));
|
||||
region.setRadius(Vector3.at(radiusScalar, radiusScalar, radiusScalar));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class RegionShape extends ArbitraryShape {
|
||||
|
||||
@Override
|
||||
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
|
||||
if (!this.extent.contains(new BlockVector3(x, y, z))) {
|
||||
if (!this.extent.contains(BlockVector3.at(x, y, z))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment {
|
||||
|
||||
public BlockVector3 toWorld(double x, double y, double z) {
|
||||
// unscale, unoffset, round-nearest
|
||||
return new Vector3(x, y, z).multiply(unit).add(zero2).toBlockPoint();
|
||||
return Vector3.at(x, y, z).multiply(unit).add(zero2).toBlockPoint();
|
||||
}
|
||||
|
||||
public Vector3 toWorldRel(double x, double y, double z) {
|
||||
|
Reference in New Issue
Block a user