X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMesh.java;h=0e2c1d68416114d28338da36bc115048ebcd2900;hp=8243b184b6ab89f303f144719509d07892c6cbb8;hb=d39304bb7e226d94996842f57a4d8d6987695184;hpb=6b8b94ec2b88321d9f53b759200137657445a08a 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; }