- HashSet<Mesh.Vert> hs = new HashSet<Mesh.Vert>();
- for(Mesh.Vert p : tile.vertices()) hs.add(p);
- for(int i=0; i<10; i++) {
- repaint();
- for(Mesh.Vert v : hs) rand(temp,v);
+ 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) es.add(e);
+ }
+ }
+
+ for(int i=0; i<1; 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);
+ }