+ synchronized(this) {
+ double ratio = (hits+misses==0) ? 1 : (hits / (hits+misses));
+ hits = 0;
+ misses = 0;
+ float gamma = 1;
+ acceptance = (ratio+acceptance)/2;
+ accepts = (int)(Math.ceil(ratio*100));
+ temps = (int)(Math.ceil(temp*1000));
+ vertss = tile.size();
+ if (breaks > 0) {
+ while (breaks>0) {
+ breaks--;
+ breakit();
+ }
+ seek_upward = true;
+ } else if (acceptance > 0.96) gamma = 0.4f;
+ else if (acceptance > 0.9) gamma = 0.5f;
+ else if (acceptance > 0.8) gamma = 0.65f;
+ else if (acceptance > 0.6) gamma = 0.7f;
+ else if (acceptance > 0.3) gamma = 0.8f;
+ else if (acceptance > 0.15) gamma = 0.9f;
+ else if (acceptance > 0.05) gamma = 0.95f;
+ else if (acceptance > 0.01) gamma = 0.98f;
+ else { /*breaks++;*/ }
+
+ if (seek_upward) {
+ if (acceptance > 0.2) seek_upward = false;
+ else gamma = 2-gamma;
+ }
+
+ temp = temp * gamma;
+
+
+ HashSet<Mesh.Vertex> hs = new HashSet<Mesh.Vertex>();
+ for(Mesh.Vertex p : tile.vertices()) hs.add(p);
+ Mesh.Vertex[] pts = (Mesh.Vertex[])hs.toArray(new Mesh.Vertex[0]);
+
+ int count = 0;
+ long then = System.currentTimeMillis();
+ for(int i=0; i<40; i++) {
+ if (anneal) {
+ count++;
+ Mesh.Vertex v = pts[Math.abs(random.nextInt()) % pts.length];
+ rand(temp,v);
+ v.recomputeFundamentalQuadricIfStale();
+ v.recomputeFundamentalQuadricIfNeighborChanged();
+ }
+ Thread.yield();
+ repaint();
+ }
+ PriorityQueue<Mesh.E> es = new PriorityQueue<Mesh.E>();
+ for(Mesh.T t : tile) {
+ float max = 5;
+ for(Mesh.E e : new Mesh.E[] { t.e1(), t.e2(), t.e3() }) {
+ if (e==null) continue;
+ if (e.stretchRatio() > max) es.add(e);
+ if (t.aspect() < 0.1 && e.length()>e.next.length() && e.length()>e.prev.length()) es.add(e);
+ }
+ }
+ /*
+ for(int i=0; i<5; i++) {
+ Mesh.E e = es.poll();
+ if (e==null) break;
+ e.shatter();
+ }
+ */
+ tile.rebindPoints();
+
+ System.out.println("temp="+temp + " ratio="+(Math.ceil(acceptance*100)) + " " +
+ "points_per_second=" +
+ (count*1000)/((double)(System.currentTimeMillis()-then)));
+
+ for(Mesh.Vertex p : goal.vertices()) p.recomputeFundamentalQuadricIfNeighborChanged();
+
+ synchronized(safeTriangles) {
+ safeTriangles.clear();
+ for(Mesh.T t : tile)
+ if (t.shouldBeDrawn())
+ safeTriangles.add(t);
+ }