- 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;
- }
- watch = null;
+
+ public void recomputeFundamentalQuadric() {
+ if (!quadricStale && fundamentalQuadric != null) return;
+ quadricStale = false;
+ unApplyQuadricToNeighbor();
+ Matrix m = Matrix.ZERO;
+ E e = this.e;
+ do {
+ T t = e.t;
+ m = m.plus(t.norm().fundamentalQuadric(t.centroid()));
+ e = e.pair.next;
+ } while(e != this.e);
+ fundamentalQuadric = m;
+ applyQuadricToNeighbor();
+ }
+
+ public void unApplyQuadricToNeighbor() {
+ if (nearest_in_other_mesh == null) return;
+ if (fundamentalQuadric == null) return;
+ nearest_in_other_mesh.unComputeError();
+ nearest_in_other_mesh.quadric = nearest_in_other_mesh.quadric.minus(fundamentalQuadric);
+ nearest_in_other_mesh.quadric_count--;
+ if (nearest_in_other_mesh.quadric_count==0)
+ nearest_in_other_mesh.quadric = Matrix.ZERO;
+ nearest_in_other_mesh.computeError();
+ nearest_in_other_mesh = null;