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;
+ }
+ }
}