return m.times(1/(float)count);
}
- public HasQuadric nearest() {
- if (error_against==null) return null;
- return error_against.vertices.nearest(p, this);
- }
-
+ public HasQuadric nearest() { return error_against==null ? null : error_against.vertices.nearest(p, this); }
public void computeError() {
float nerror =
quadric_count != 0
setError(nerror);
}
- private void removeTrianglesFromRTree() {
- for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next)
- if (e.t != null) e.t.removeFromRTree();
- }
- private void addTrianglesToRTree() {
- for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next)
- if (e.t != null) e.t.addToRTree();
- }
-
/** does NOT update bound pairs! */
public boolean transform(Matrix m) {
if (immutableVertices) throw new Error();
if (vertices.get(this.p)==null) throw new Error();
vertices.remove(this);
- removeTrianglesFromRTree();
- float newx = m.a*p.x + m.b*p.y + m.c*p.z + m.d;
- float newy = m.e*p.x + m.f*p.y + m.g*p.z + m.h;
- float newz = m.i*p.x + m.j*p.y + m.k*p.z + m.l;
- this.p = new Point(newx, newy, newz);
- addTrianglesToRTree();
+ 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);
+ 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);
applyQuadricToNeighbor();
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);
-
- if (good) {
- for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
+ for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
+ if (good)
p.reComputeErrorAround();
- } else {
- for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
+ else
p.transform(Matrix.translate(v.times(-1)));
- }
return good;
}