checkpoint
authoradam <adam@megacz.com>
Sun, 16 Dec 2007 03:49:36 +0000 (19:49 -0800)
committeradam <adam@megacz.com>
Sun, 16 Dec 2007 03:49:36 +0000 (19:49 -0800)
darcs-hash:20071216034936-5007d-11ee3af4585027f345e2947bf49d68ad5a6a49e3.gz

src/edu/berkeley/qfat/Mesh.java

index c2d2988..87209a7 100644 (file)
@@ -50,7 +50,7 @@ public class Mesh implements Iterable<Mesh.T> {
     public void transform(Matrix m) {
         ArrayList<Vertex> set = new ArrayList<Vertex>();
         for(Vertex v : vertices) set.add(v);
-        for(Vertex v : set) v.transform(m);
+        for(Vertex v : set) v.transform(m.times(v.p));
     }
 
     public void rebuild() { /*vertices.rebuild();*/ }
@@ -129,7 +129,7 @@ public class Mesh implements Iterable<Mesh.T> {
         }
 
         /** does NOT update bound pairs! */
-        public boolean transform(Matrix m) {
+        public boolean transform(Point newp) {
             if (immutableVertices) throw new Error();
 
             unApplyQuadricToNeighbor();
@@ -139,7 +139,7 @@ public class Mesh implements Iterable<Mesh.T> {
             vertices.remove(this);
             for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next)
                 if (e.t != null) e.t.removeFromRTree();
-            this.p = m.times(this.p);
+            this.p = newp;
             for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next)
                 if (e.t != null) e.t.addToRTree();
             vertices.add(this);
@@ -187,16 +187,19 @@ public class Mesh implements Iterable<Mesh.T> {
             }
         }
 
+        Point oldp;
         public boolean move(Vec v) {
             Matrix m = Matrix.translate(v);
             boolean good = true;
-            for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
-                good &= p.transform(m);
+            for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to) {
+                p.oldp = p.p;
+                good &= p.transform(m.times(p.p));
+            }
             for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
                 if (good)
                     p.reComputeErrorAround();
                 else 
-                    p.transform(Matrix.translate(v.times(-1)));
+                    p.transform(p.oldp);
             return good;
         }