From 318e81886c0f84bd5d2ac818bc3a19435d38979c Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Fri, 28 Oct 2011 15:10:14 +0200 Subject: [PATCH] Removed -q flag from //[h]sphere and the code to back it. The speed difference between the "flexible" and the "quick" variant is so minor that it doesn't justify the aditional code complexity. --- .../java/com/sk89q/worldedit/EditSession.java | 68 ------------------- .../commands/GenerationCommands.java | 48 ------------- 2 files changed, 116 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/EditSession.java b/src/main/java/com/sk89q/worldedit/EditSession.java index f290b9b7c..190a935be 100644 --- a/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/src/main/java/com/sk89q/worldedit/EditSession.java @@ -1976,74 +1976,6 @@ public class EditSession { return affected; } - /** - * Makes a sphere or ellipsoid. - * - * @param pos Center of the sphere or ellipsoid - * @param block The block pattern to use - * @param radiusX The sphere/ellipsoid's largest north/south extent - * @param radiusY The sphere/ellipsoid's largest up/down extent - * @param radiusZ The sphere/ellipsoid's largest east/west extent - * @param filled If false, only a shell will be generated. - * @return number of blocks changed - * @throws MaxChangedBlocksException - */ - public int makeSphere(Vector pos, Pattern block, double radius, boolean filled) throws MaxChangedBlocksException { - int affected = 0; - - radius += 0.5; - final double radiusSq = radius*radius; - final double radius1Sq = (radius - 1)*(radius - 1); - - final int ceilRadius = (int) Math.ceil(radius); - for (int x = 0; x <= ceilRadius; ++x) { - for (int y = 0; y <= ceilRadius; ++y) { - for (int z = 0; z <= ceilRadius; ++z) { - double dSq = lengthSq(x, y, z); - - if (dSq > radiusSq) { - continue; - } - if (!filled) { - if (dSq < radius1Sq - || (lengthSq(x + 1, y, z) <= radiusSq - && lengthSq(x, y + 1, z) <= radiusSq - && lengthSq(x, y, z + 1) <= radiusSq)) { - continue; - } - } - - if (setBlock(pos.add(x, y, z), block)) { - ++affected; - } - if (setBlock(pos.add(-x, y, z), block)) { - ++affected; - } - if (setBlock(pos.add(x, -y, z), block)) { - ++affected; - } - if (setBlock(pos.add(x, y, -z), block)) { - ++affected; - } - if (setBlock(pos.add(-x, -y, z), block)) { - ++affected; - } - if (setBlock(pos.add(x, -y, -z), block)) { - ++affected; - } - if (setBlock(pos.add(-x, y, -z), block)) { - ++affected; - } - if (setBlock(pos.add(-x, -y, -z), block)) { - ++affected; - } - } - } - } - - return affected; - } - /** * Makes a sphere or ellipsoid. * diff --git a/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java b/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java index dae29b56c..bd3628001 100644 --- a/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java +++ b/src/main/java/com/sk89q/worldedit/commands/GenerationCommands.java @@ -85,7 +85,6 @@ public class GenerationCommands { aliases = { "/hsphere" }, usage = " [,,] [raised?]", desc = "Generate a hollow sphere.", - flags = "q", min = 2, max = 3 ) @@ -95,29 +94,6 @@ public class GenerationCommands { LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { - if (args.hasFlag('q')) { - Pattern block = we.getBlockPattern(player, args.getString(0)); - String[] radiuses = args.getString(1).split(","); - if (radiuses.length > 1) { - throw new InsufficientArgumentsException("Cannot specify q flag and multiple radiuses."); - } - double radius = Double.parseDouble(radiuses[0]); - boolean raised = args.argsLength() > 2 - ? (args.getString(2).equalsIgnoreCase("true") - || args.getString(2).equalsIgnoreCase("yes")) - : false; - - Vector pos = session.getPlacementPosition(player); - if (raised) { - pos = pos.add(0, radius, 0); - } - - int affected = editSession.makeSphere(pos, block, radius, false); - player.findFreePosition(); - player.print(affected + " block(s) have been created."); - return; - } - final Pattern block = we.getBlockPattern(player, args.getString(0)); String[] radiuses = args.getString(1).split(","); final double radiusX, radiusY, radiusZ; @@ -157,7 +133,6 @@ public class GenerationCommands { aliases = { "/sphere" }, usage = " [,,] [raised?]", desc = "Generate a filled sphere.", - flags = "q", min = 2, max = 3 ) @@ -167,29 +142,6 @@ public class GenerationCommands { LocalSession session, LocalPlayer player, EditSession editSession) throws WorldEditException { - if (args.hasFlag('q')) { - Pattern block = we.getBlockPattern(player, args.getString(0)); - String[] radiuses = args.getString(1).split(","); - if (radiuses.length > 1) { - throw new InsufficientArgumentsException("Cannot specify q flag and multiple radiuses."); - } - double radius = Double.parseDouble(radiuses[0]); - boolean raised = args.argsLength() > 2 - ? (args.getString(2).equalsIgnoreCase("true") - || args.getString(2).equalsIgnoreCase("yes")) - : false; - - Vector pos = session.getPlacementPosition(player); - if (raised) { - pos = pos.add(0, radius, 0); - } - - int affected = editSession.makeSphere(pos, block, radius, true); - player.findFreePosition(); - player.print(affected + " block(s) have been created."); - return; - } - Pattern block = we.getBlockPattern(player, args.getString(0)); String[] radiuses = args.getString(1).split(","); final double radiusX, radiusY, radiusZ;