checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index 8243b18..0e2c1d6 100644 (file)
@@ -81,6 +81,7 @@ public class Mesh implements Iterable<Mesh.T> {
 
         Matrix binding = Matrix.ONE;
         Vertex bound_to = this;
+        private boolean good;
 
         public Point getPoint() { return p; }
         public float error() { return olderror; }
@@ -113,7 +114,6 @@ public class Mesh implements Iterable<Mesh.T> {
             return error_against.vertices.nearest(p, this);
         }
 
-
         public void computeError() {
             float nerror =
                 quadric_count != 0
@@ -170,8 +170,6 @@ public class Mesh implements Iterable<Mesh.T> {
 
             if (!ignorecollision && good) triangles.range(oldp, this.p, (Visitor<T>)this);
 
-            reComputeErrorAround();
-
             return good;
         }
 
@@ -202,16 +200,21 @@ public class Mesh implements Iterable<Mesh.T> {
                 return true;
             }
         }
-        private boolean good;
 
         public boolean move(Vec v) {
             Matrix m = Matrix.translate(v);
-            Vertex p = this;
+
             boolean good = true;
-            do {
+            for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
                 good &= p.transform(m);
-                p = p.bound_to;
-            } while (p != this);
+
+            if (good) {
+                for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
+                    p.reComputeErrorAround();
+            } else {
+                for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
+                    p.transform(Matrix.translate(v.times(-1)));
+            }
             return good;
         }