Perf: Visualizations

This commit is contained in:
ryanhamshire 2015-03-28 13:46:23 -07:00
parent e91924eb94
commit 29264350c4

View File

@ -174,64 +174,54 @@ public class Visualization
//that will be added later for only the visualization elements within visualization range //that will be added later for only the visualization elements within visualization range
//locality //locality
int minx = locality.getBlockX() - 100; int minx = locality.getBlockX() - 75;
int minz = locality.getBlockZ() - 100; int minz = locality.getBlockZ() - 75;
int maxx = locality.getBlockX() + 100; int maxx = locality.getBlockX() + 75;
int maxz = locality.getBlockZ() + 100; int maxz = locality.getBlockZ() + 75;
final int STEP = 10; final int STEP = 10;
//top line //top line
newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz), cornerMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0));
for(int x = smallx + STEP; x < bigx - STEP / 2; x += STEP) for(int x = smallx + STEP; x < bigx - STEP / 2; x += STEP)
{ {
if(x > minx && x < maxx) if(x > minx && x < maxx)
newElements.add(new VisualizationElement(new Location(world, x, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, x, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0));
} }
newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0));
//bottom line //bottom line
for(int x = smallx + STEP; x < bigx - STEP / 2; x += STEP) newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0));
for(int x = smallx + STEP; x < bigx - STEP / 2; x += STEP)
{ {
if(x > minx && x < maxx) if(x > minx && x < maxx)
newElements.add(new VisualizationElement(new Location(world, x, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, x, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0));
} }
newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0));
//left line //left line
newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0));
for(int z = smallz + STEP; z < bigz - STEP / 2; z += STEP) for(int z = smallz + STEP; z < bigz - STEP / 2; z += STEP)
{ {
if(z > minz && z < maxz) if(z > minz && z < maxz)
newElements.add(new VisualizationElement(new Location(world, smallx, 0, z), accentMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, smallx, 0, z), accentMaterial, (byte)0, Material.AIR, (byte)0));
} }
newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz - 1), accentMaterial, (byte)0, Material.AIR, (byte)0));
//right line //right line
newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0));
for(int z = smallz + STEP; z < bigz - STEP / 2; z += STEP) for(int z = smallz + STEP; z < bigz - STEP / 2; z += STEP)
{ {
if(z > minz && z < maxz) if(z > minz && z < maxz)
newElements.add(new VisualizationElement(new Location(world, bigx, 0, z), accentMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, bigx, 0, z), accentMaterial, (byte)0, Material.AIR, (byte)0));
} }
//bottom left corner leaves
newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0));
//bottom right corner leaves
newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, smallz), accentMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz + 1), accentMaterial, (byte)0, Material.AIR, (byte)0));
//top right corner leaves
newElements.add(new VisualizationElement(new Location(world, bigx - 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, bigx, 0, bigz - 1), accentMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, bigx, 0, bigz - 1), accentMaterial, (byte)0, Material.AIR, (byte)0));
//top left corner leaves
newElements.add(new VisualizationElement(new Location(world, smallx + 1, 0, bigz), accentMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz - 1), accentMaterial, (byte)0, Material.AIR, (byte)0));
//corners
newElements.add(new VisualizationElement(new Location(world, smallx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, bigx, 0, smallz), cornerMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, bigx, 0, bigz), cornerMaterial, (byte)0, Material.AIR, (byte)0)); newElements.add(new VisualizationElement(new Location(world, bigx, 0, bigz), cornerMaterial, (byte)0, Material.AIR, (byte)0));
newElements.add(new VisualizationElement(new Location(world, smallx, 0, bigz), cornerMaterial, (byte)0, Material.AIR, (byte)0));
//remove any out of range elements (the corners may be out of range) //remove any out of range elements
this.removeElementsOutOfRange(newElements, minx, minz, maxx, maxz); this.removeElementsOutOfRange(newElements, minx, minz, maxx, maxz);
//remove any elements outside the claim //remove any elements outside the claim
@ -249,6 +239,7 @@ public class Visualization
{ {
Location tempLocation = element.location; Location tempLocation = element.location;
element.location = getVisibleLocation(tempLocation.getWorld(), tempLocation.getBlockX(), height, tempLocation.getBlockZ(), waterIsTransparent); element.location = getVisibleLocation(tempLocation.getWorld(), tempLocation.getBlockX(), height, tempLocation.getBlockZ(), waterIsTransparent);
height = element.location.getBlockY();
element.realMaterial = element.location.getBlock().getType(); element.realMaterial = element.location.getBlock().getType();
element.realData = element.location.getBlock().getData(); element.realData = element.location.getBlock().getData();
} }