E e; // some edge *leaving* this point
Vert bound_to = this;
- int watch_count;
- float watch_x;
- float watch_y;
- float watch_z;
- Vert watch;
+ int nearest_vert_in_other_mesh_count;
+ float nearest_vert_in_other_mesh_x;
+ float nearest_vert_in_other_mesh_y;
+ float nearest_vert_in_other_mesh_z;
+ Vert nearest_vert_in_other_mesh;
Matrix binding = new Matrix();
float oldscore = 0;
boolean inserted = false;
}
public float score() { return oldscore; }
public void unscore() {
- if (watch == null) return;
- watch.watch_x -= p.x;
- watch.watch_y -= p.y;
- watch.watch_z -= p.z;
- watch.watch_count--;
- if (watch.watch_count==0) {
- watch.watch_x = 0;
- watch.watch_y = 0;
- watch.watch_z = 0;
+ if (nearest_vert_in_other_mesh == null) return;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_x -= p.x;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_y -= p.y;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_z -= p.z;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_count--;
+ if (nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_count==0) {
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_x = 0;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_y = 0;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_z = 0;
}
- watch = null;
+ nearest_vert_in_other_mesh = null;
}
- public Vert partner() { return watch==null ? this : watch; }
- public Point watchback() { return watch_count==0 ? partner().p :
- new Point(watch_x/watch_count, watch_y/watch_count, watch_z/watch_count); }
+ public Vert partner() { return nearest_vert_in_other_mesh==null ? this : nearest_vert_in_other_mesh; }
+ public Point nearest_vert_in_other_mesh() { return nearest_vert_in_other_mesh_count==0 ? partner().p :
+ new Point(nearest_vert_in_other_mesh_x/nearest_vert_in_other_mesh_count, nearest_vert_in_other_mesh_y/nearest_vert_in_other_mesh_count, nearest_vert_in_other_mesh_z/nearest_vert_in_other_mesh_count); }
public void rescore() {
if (score_against == null) return;
score -= oldscore;
oldscore = 0;
- if (watch != null) unscore();
+ if (nearest_vert_in_other_mesh != null) unscore();
Vert po = this;
- if (watch == null) {
- watch = score_against.nearest(po.p);
+ if (nearest_vert_in_other_mesh == null) {
+ nearest_vert_in_other_mesh = score_against.nearest(po.p);
// don't attract to vertices that face the other way
- if (watch.e == null || watch.norm().dot(norm()) < 0) {
- watch = null;
+ if (nearest_vert_in_other_mesh.e == null || nearest_vert_in_other_mesh.norm().dot(norm()) < 0) {
+ nearest_vert_in_other_mesh = null;
} else {
- watch.watch_x += po.p.x;
- watch.watch_y += po.p.y;
- watch.watch_z += po.p.z;
- watch.watch_count++;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_x += po.p.x;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_y += po.p.y;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_z += po.p.z;
+ nearest_vert_in_other_mesh.nearest_vert_in_other_mesh_count++;
}
}
double s1, s2;
- if (watch_count==0) s1 = 0;
- else s1 = p.distance(watch_x/watch_count, watch_y/watch_count, watch_z/watch_count);
- s2 = watch==null ? 0 : po.p.distance(watch.p);
+ if (nearest_vert_in_other_mesh_count==0) s1 = 0;
+ else s1 = p.distance(nearest_vert_in_other_mesh_x/nearest_vert_in_other_mesh_count, nearest_vert_in_other_mesh_y/nearest_vert_in_other_mesh_count, nearest_vert_in_other_mesh_z/nearest_vert_in_other_mesh_count);
+ s2 = nearest_vert_in_other_mesh==null ? 0 : po.p.distance(nearest_vert_in_other_mesh.p);
oldscore = (float)(s1 + s2);
score += oldscore;
}
public Matrix plus(Matrix x) {
return new Matrix(a+x.a, b+x.b, c+x.c, d+x.d, e+x.e, f+x.f, g+x.g, h+x.h, i+x.i, j+x.j, k+x.k, l+x.l, m+x.m, n+x.n, o+x.o, p+x.p);
}
+ public Matrix minus(Matrix x) {
+ return new Matrix(a-x.a, b-x.b, c-x.c, d-x.d, e-x.e, f-x.f, g-x.g, h-x.h, i-x.i, j-x.j, k-x.k, l-x.l, m-x.m, n-x.n, o-x.o, p-x.p);
+ }
public Matrix times(float x) {
return new Matrix(a*x, b*x, c*x, d*x, e*x, f*x, g*x, h*x, i*x, j*x, k*x, l*x, m*x, n*x, o*x, p*x);
}