From d4a7f7b48a10d8880c1a7dc9b84f4b319c1c54d5 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 5 Aug 2013 19:46:39 +0200 Subject: [PATCH] ConvexPolyhedralRegions now preserve the order of their vertices. --- .../sk89q/worldedit/regions/ConvexPolyhedralRegion.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java b/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java index d59a4e0e6..788811ea5 100644 --- a/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/ConvexPolyhedralRegion.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.regions; import java.util.ArrayList; import java.util.Collection; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -36,7 +35,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion { /** * Vertices that are contained in the convex hull. */ - private final Set vertices = new HashSet(); + private final Set vertices = new LinkedHashSet(); /** * Triangles that form the convex hull. @@ -46,7 +45,7 @@ public class ConvexPolyhedralRegion extends AbstractRegion { /** * Vertices that are coplanar to the first 3 vertices. */ - private final Set vertexBacklog = new HashSet(); + private final Set vertexBacklog = new LinkedHashSet(); /** * Minimum point of the axis-aligned bounding box. @@ -195,11 +194,13 @@ public class ConvexPolyhedralRegion extends AbstractRegion { } if (!vertexBacklog.isEmpty()) { + vertices.remove(vertex); final List vertexBacklog2 = new ArrayList(vertexBacklog); vertexBacklog.clear(); for (Vector vertex2 : vertexBacklog2) { addVertex(vertex2); } + vertices.add(vertex); } return true;