checkpoint
authoradam <adam@megacz.com>
Tue, 18 Dec 2007 02:28:45 +0000 (18:28 -0800)
committeradam <adam@megacz.com>
Tue, 18 Dec 2007 02:28:45 +0000 (18:28 -0800)
darcs-hash:20071218022845-5007d-e0b46593f2f7f9518fffca20f3d778cab79bd497.gz

src/edu/berkeley/qfat/Mesh.java
src/edu/berkeley/qfat/geom/BindingGroup.java
src/edu/berkeley/qfat/geom/HasBindingGroup.java
src/edu/berkeley/qfat/geom/Matrix.java

index 951f53a..d5e0db2 100644 (file)
@@ -6,6 +6,7 @@ import javax.swing.*;
 import javax.media.opengl.*;
 import javax.media.opengl.glu.*;
 import edu.berkeley.qfat.geom.*;
+import edu.berkeley.qfat.geom.HasBindingGroup;
 import edu.wlu.cs.levy.CG.KDTree;
 import edu.berkeley.qfat.geom.Point;
 import com.infomatiq.jsi.IntProcedure;
@@ -165,7 +166,7 @@ public class Mesh implements Iterable<Mesh.T> {
 
             for(Vertex p : (Iterable<Vertex>)getBoundPeers())
                 if (good || ignoreProblems)  p.reComputeErrorAround();
-                else                              p.transform(p.oldp, true);
+                else                         p.transform(p.oldp, true);
 
             return good;
         }
@@ -305,7 +306,7 @@ public class Mesh implements Iterable<Mesh.T> {
     }
 
     /** [UNIQUE] an edge */
-    public final class E implements Comparable<E> {
+    public final class E extends HasBindingGroup implements Comparable<E> {
 
         public final Vertex p1, p2;
         T t;     // triangle to our "left"
@@ -318,6 +319,16 @@ public class Mesh implements Iterable<Mesh.T> {
 
         public boolean intersects(T t) { return t.intersects(p1.p, p2.p); }
 
+        public void bindingGroupChanged(edu.berkeley.qfat.geom.BindingGroup newBindingGroup_) {
+            edu.berkeley.qfat.geom.BindingGroup<E> newBindingGroup = (edu.berkeley.qfat.geom.BindingGroup<E>)newBindingGroup_;
+            if (newBindingGroup==null) return;
+            if (this==newBindingGroup.getMaster()) return;
+            for(E eother : (Iterable<E>)newBindingGroup) {
+                this.next.bindTo(newBindingGroup.getMatrix(eother), eother.next);
+                this.prev.bindTo(newBindingGroup.getMatrix(eother), eother.prev);
+            }
+        }
+
         public float stretchRatio() {
             Vertex nearest = error_against.nearest(midpoint());
             float nearest_distance = midpoint().distance(nearest.p);
@@ -327,8 +338,6 @@ public class Mesh implements Iterable<Mesh.T> {
             return nearest_distance/other_distance;
         }
         public float comparator() {
-            
-
             return length();
             //return t==null?0:(1/t.aspect());
         }
index 8ea271e..d1ff8b8 100644 (file)
@@ -17,6 +17,8 @@ public class BindingGroup<T extends HasBindingGroup> implements Iterable<T> {
             matrices.put((T)hbg, bg.matrices.get(hbg).times(m));
             hbg.bindingGroup = this;
         }
+        for(HasBindingGroup hbg : bg.matrices.keySet())
+            hbg.bindingGroupChanged(this);
         bg.matrices.clear();
         bg.master = null;
     }
index 1c3737a..715f763 100644 (file)
@@ -41,6 +41,7 @@ public abstract class HasBindingGroup {
         if (bindingGroup==null) return;
         bindingGroup.unbind(this);
         bindingGroup = null;
+        bindingGroupChanged(bindingGroup);
     }
 
     public boolean isBoundTo(HasBindingGroup t) {
@@ -48,4 +49,5 @@ public abstract class HasBindingGroup {
     }
 
     public Iterable getBoundPeers() { return bindingGroup; }
+    public void bindingGroupChanged(BindingGroup newBindingGroup) { }
 }
index 19e1a9a..9303233 100644 (file)
@@ -16,10 +16,13 @@ public class Matrix {
     public final float a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p;
 
     /** the zero matrix */
-    public static final Matrix ZERO = new Matrix(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
+    public static final Matrix ZERO          = new Matrix(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
 
     /** the identity matrix */
-    public static final Matrix ONE  = new Matrix(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
+    public static final Matrix ONE           = new Matrix(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);
+
+    /** the identity matrix */
+    public static final Matrix NEGATIVE_ONE  = new Matrix(-1,0,0,0,0,-1,0,0,0,0,-1,0,0,0,0,1);
 
     public Matrix(float a, float b, float c, float d, float e, float f, float g,
                   float h, float i, float j, float k, float l, float m, float n, float o, float p) {