checkpoint
authoradam <adam@megacz.com>
Mon, 30 Jun 2008 00:30:38 +0000 (17:30 -0700)
committeradam <adam@megacz.com>
Mon, 30 Jun 2008 00:30:38 +0000 (17:30 -0700)
darcs-hash:20080630003038-5007d-0da5f89023a4ccf2ddbffa5cdf56a7d4e3a9f25a.gz

src/edu/berkeley/qfat/MeshViewer.java
src/edu/berkeley/qfat/Viewer.java

index 73f22fb..356fbad 100644 (file)
@@ -38,7 +38,6 @@ public class MeshViewer extends Viewer {
 
     public MeshViewer(JFrame f) { super(f); }
 
 
     public MeshViewer(JFrame f) { super(f); }
 
-
     public void _display(GLAutoDrawable drawable, GL gl) {
 
         if (transforms==null) return;
     public void _display(GLAutoDrawable drawable, GL gl) {
 
         if (transforms==null) return;
@@ -126,7 +125,6 @@ public class MeshViewer extends Viewer {
         gl.glDisable(GL.GL_LIGHTING);
         gl.glShadeModel(GL.GL_FLAT);
 
         gl.glDisable(GL.GL_LIGHTING);
         gl.glShadeModel(GL.GL_FLAT);
 
-
         updateVisibility(gl, tile);
 
         Matrix projection = Matrix.getProjectionMatrix(gl);
         updateVisibility(gl, tile);
 
         Matrix projection = Matrix.getProjectionMatrix(gl);
@@ -146,7 +144,6 @@ public class MeshViewer extends Viewer {
         }
     }
 
         }
     }
 
-
     private void draw(GL gl, boolean triangles, Iterable<Mesh.T> tris) { draw(gl, triangles, tris, Matrix.ONE); }
     private void draw(GL gl, boolean triangles, Iterable<Mesh.T> tris, Matrix m) {
         float red = 0.0f;
     private void draw(GL gl, boolean triangles, Iterable<Mesh.T> tris) { draw(gl, triangles, tris, Matrix.ONE); }
     private void draw(GL gl, boolean triangles, Iterable<Mesh.T> tris, Matrix m) {
         float red = 0.0f;
index 2ec797f..627b457 100644 (file)
@@ -80,33 +80,31 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
         projection = Matrix.getProjectionMatrix(gl);
     }
 
         projection = Matrix.getProjectionMatrix(gl);
     }
 
-    protected void updateVisibility(GL gl, Mesh mesh) {
+    protected synchronized void updateVisibility(GL gl, Mesh mesh) {
         Matrix projection = Matrix.getProjectionMatrix(gl);
         IntBuffer buf = ByteBuffer.allocateDirect(9*4*4).order(ByteOrder.nativeOrder()).asIntBuffer();
         gl.glColor3f(0,0,0);
         gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
         Matrix projection = Matrix.getProjectionMatrix(gl);
         IntBuffer buf = ByteBuffer.allocateDirect(9*4*4).order(ByteOrder.nativeOrder()).asIntBuffer();
         gl.glColor3f(0,0,0);
         gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
-        synchronized(this) {
-            for(Mesh.T t : mesh) t.glTriangle(gl, null);
-            for(Mesh.Vertex v : mesh.vertices()) {
-                Point p = v.getPoint();
-                gl.glColor3f(1,1,1);
+        for(Mesh.T t : mesh) t.glTriangle(gl, null);
+        for(Mesh.Vertex v : mesh.vertices()) {
+            Point p = v.getPoint();
+            gl.glColor3f(1,1,1);
+            gl.glBegin(gl.GL_POINTS);
+            p.glVertex(gl);
+            gl.glEnd();
+            gl.glFlush();
+            
+            Point projected = projection.times(p);
+            gl.glReadPixels((int)projected.x-1, (int)projected.y-1, 3, 3, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, buf);
+            
+            boolean vis = false;
+            for(int j=0; j<9*4; j++) vis |= buf.get(j)!=0;
+            v.visible = vis;
+            if (vis) {
+                gl.glColor3f(0,0,0);
                 gl.glBegin(gl.GL_POINTS);
                 p.glVertex(gl);
                 gl.glEnd();
                 gl.glBegin(gl.GL_POINTS);
                 p.glVertex(gl);
                 gl.glEnd();
-                gl.glFlush();
-
-                Point projected = projection.times(p);
-                gl.glReadPixels((int)projected.x-1, (int)projected.y-1, 3, 3, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, buf);
-
-                boolean vis = false;
-                for(int j=0; j<9*4; j++) vis |= buf.get(j)!=0;
-                v.visible = vis;
-                if (vis) {
-                    gl.glColor3f(0,0,0);
-                    gl.glBegin(gl.GL_POINTS);
-                    p.glVertex(gl);
-                    gl.glEnd();
-                }
             }
         }
         gl.glShadeModel(GL.GL_SMOOTH);
             }
         }
         gl.glShadeModel(GL.GL_SMOOTH);
@@ -171,7 +169,7 @@ public abstract class Viewer implements GLEventListener, MouseListener, MouseMot
                     Vec delta = d1.plus(clickClosest).minus(closest.getPoint());
                     //System.out.println(delta + " " + closest.getPoint());
                     System.out.println(getMouse().minus(clickPoint));
                     Vec delta = d1.plus(clickClosest).minus(closest.getPoint());
                     //System.out.println(delta + " " + closest.getPoint());
                     System.out.println(getMouse().minus(clickPoint));
-                    closest.move(Matrix.translate(delta), true);
+                    closest.move(Matrix.translate(delta), false);
                 }
             }
         } else {
                 }
             }
         } else {