checkpoint
[anneal.git] / src / edu / berkeley / qfat / MeshViewer.java
index aea2799..73f22fb 100644 (file)
@@ -126,6 +126,24 @@ public class MeshViewer extends Viewer {
         gl.glDisable(GL.GL_LIGHTING);
         gl.glShadeModel(GL.GL_FLAT);
 
+
+        updateVisibility(gl, tile);
+
+        Matrix projection = Matrix.getProjectionMatrix(gl);
+        double dist = Double.MAX_VALUE;
+        if (clickPoint != null) return;
+        closest = null;
+        for(Mesh.Vertex v : tile.vertices()) {
+            if (!v.visible) continue;
+            Point p = projection.times(v.getPoint());
+            int x = (int)p.x;
+            int y = (int)p.y;
+            y = glcanvas.getHeight()-y;
+            if (closest==null || (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey) < dist) {
+                dist = (x-mousex)*(x-mousex)+(y-mousey)*(y-mousey);
+                closest = v;
+            }
+        }
     }