mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-12 03:24:14 +00:00
Reduced object scaling allocations
- Enlarged objects write expanded cells through one reusable coordinate - Scaling removes temporary voxel lists and unused bound reads - Expanded tiles retain independent copies and existing write order
This commit is contained in:
@@ -22,15 +22,12 @@ import art.arcane.iris.spi.IrisLogging;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.common.data.VectorMap;
|
||||
import art.arcane.iris.util.common.math.IrisBlockVector;
|
||||
import art.arcane.iris.util.common.math.IrisVector;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.iris.util.common.parallel.BurstExecutor;
|
||||
import art.arcane.iris.util.common.parallel.MultiBurst;
|
||||
import art.arcane.volmlib.util.format.Form;
|
||||
import art.arcane.volmlib.util.scheduling.PrecisionStopwatch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
@@ -289,23 +286,4 @@ final class IrisObjectShaping {
|
||||
static String materialKey(PlatformBlockState state) {
|
||||
return IrisProceduralBlocks.materialKey(state);
|
||||
}
|
||||
|
||||
static List<IrisBlockVector> blocksBetweenTwoPoints(IrisVector loc1, IrisVector loc2) {
|
||||
List<IrisBlockVector> locations = new ArrayList<>();
|
||||
int topBlockX = Math.max(loc1.getBlockX(), loc2.getBlockX());
|
||||
int bottomBlockX = Math.min(loc1.getBlockX(), loc2.getBlockX());
|
||||
int topBlockY = Math.max(loc1.getBlockY(), loc2.getBlockY());
|
||||
int bottomBlockY = Math.min(loc1.getBlockY(), loc2.getBlockY());
|
||||
int topBlockZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
|
||||
int bottomBlockZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
|
||||
|
||||
for (int x = bottomBlockX; x <= topBlockX; x++) {
|
||||
for (int z = bottomBlockZ; z <= topBlockZ; z++) {
|
||||
for (int y = bottomBlockY; y <= topBlockY; y++) {
|
||||
locations.add(new IrisBlockVector(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
return locations;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +96,6 @@ final class IrisObjectTransforms {
|
||||
scale = scale - 0.0001;
|
||||
}
|
||||
|
||||
IrisPosition l1 = self.getAABB().max();
|
||||
IrisPosition l2 = self.getAABB().min();
|
||||
VectorMap<PlatformBlockState> placeBlock = new VectorMap<>();
|
||||
VectorMap<TileData> placeTile = new VectorMap<>();
|
||||
VectorMap<IrisBlockVector> placeMax = savedOrigin && scale > 1 ? new VectorMap<>() : null;
|
||||
@@ -153,13 +151,27 @@ final class IrisObjectTransforms {
|
||||
if (scale > 1) {
|
||||
IrisVector minimum = savedOrigin ? v : v.clone().add(center);
|
||||
IrisVector maximum = savedOrigin ? placeMax.get(v) : v.clone().add(center).add(sm1);
|
||||
for (IrisBlockVector vec : IrisObjectShaping.blocksBetweenTwoPoints(minimum, maximum)) {
|
||||
oo.blocks.put(vec, entry.getValue());
|
||||
if (hasTiles) {
|
||||
if (tile == null) {
|
||||
oo.states.remove(vec);
|
||||
} else {
|
||||
oo.states.put(vec, tile.clone());
|
||||
int minX = Math.min(minimum.getBlockX(), maximum.getBlockX());
|
||||
int maxX = Math.max(minimum.getBlockX(), maximum.getBlockX());
|
||||
int minY = Math.min(minimum.getBlockY(), maximum.getBlockY());
|
||||
int maxY = Math.max(minimum.getBlockY(), maximum.getBlockY());
|
||||
int minZ = Math.min(minimum.getBlockZ(), maximum.getBlockZ());
|
||||
int maxZ = Math.max(minimum.getBlockZ(), maximum.getBlockZ());
|
||||
IrisBlockVector position = new IrisBlockVector(minX, minY, minZ);
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
position.setX(x);
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
position.setZ(z);
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
position.setY(y);
|
||||
oo.blocks.put(position, entry.getValue());
|
||||
if (hasTiles) {
|
||||
if (tile == null) {
|
||||
oo.states.remove(position);
|
||||
} else {
|
||||
oo.states.put(position, tile.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user