Did some minor Vector optimization.

This commit is contained in:
sk89q
2011-01-08 10:59:06 -08:00
parent 2f71a32f64
commit da4480ab49
2 changed files with 14 additions and 1 deletions

View File

@@ -1579,6 +1579,7 @@ public class EditSession {
public int simulateSnow(Vector pos, int radius)
throws MaxChangedBlocksException {
int affected = 0;
int radiusSq = (int)Math.pow(radius, 2);
int ox = pos.getBlockX();
int oy = pos.getBlockY();
@@ -1589,7 +1590,7 @@ public class EditSession {
for (int x = ox - radius; x <= ox + radius; x++) {
for (int z = oz - radius; z <= oz + radius; z++) {
if ((new Vector(x, oy, z)).distance(pos) > radius) {
if ((new Vector(x, oy, z)).distanceSq(pos) > radiusSq) {
continue;
}