checkpoint
authoradam <adam@megacz.com>
Sun, 16 Dec 2007 03:45:22 +0000 (19:45 -0800)
committeradam <adam@megacz.com>
Sun, 16 Dec 2007 03:45:22 +0000 (19:45 -0800)
darcs-hash:20071216034522-5007d-7469d6d37572506bbb37390e9eab05dd7ca55f41.gz

src/edu/berkeley/qfat/Main.java
src/edu/berkeley/qfat/Mesh.java

index 9d5c4fc..8c38913 100644 (file)
@@ -308,6 +308,7 @@ public class Main extends MeshViewer {
         v = v2.norm().times(1/(float)300);
 
         boolean good = p.move(v);
+        if (!good) { misses++; return; }
 
         p.reComputeErrorAround();
 
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;
         }