From: adam Date: Sun, 16 Dec 2007 03:45:22 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=d39304bb7e226d94996842f57a4d8d6987695184 checkpoint darcs-hash:20071216034522-5007d-7469d6d37572506bbb37390e9eab05dd7ca55f41.gz --- diff --git a/src/edu/berkeley/qfat/Main.java b/src/edu/berkeley/qfat/Main.java index 9d5c4fc..8c38913 100644 --- a/src/edu/berkeley/qfat/Main.java +++ b/src/edu/berkeley/qfat/Main.java @@ -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(); diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 8243b18..0e2c1d6 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -81,6 +81,7 @@ public class Mesh implements Iterable { 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 { return error_against.vertices.nearest(p, this); } - public void computeError() { float nerror = quadric_count != 0 @@ -170,8 +170,6 @@ public class Mesh implements Iterable { if (!ignorecollision && good) triangles.range(oldp, this.p, (Visitor)this); - reComputeErrorAround(); - return good; } @@ -202,16 +200,21 @@ public class Mesh implements Iterable { 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; }