Program: 70992
Project: 70992
Buggy source:
private void drawFacesRaw(GL2 gl,PolygonalMesh mesh,TextureProps textureProps,int flags){
  Vector3d nrm;
  Vector3d[] nrms=null;
  Vector3d vtxNrm=new Vector3d();
  int[] shadingModel=new int[1];
  gl.glGetIntegerv(GL2.GL_SHADE_MODEL,shadingModel,0);
  boolean computeVertexNormals=(flags & COMPUTE_VERTEX_NORMALS) != 0;
  boolean useRenderNormals=mesh.isRenderBuffered() && !mesh.isFixed();
  boolean useVertexColors=(flags & GLRenderer.VERTEX_COLORING) != 0;
  boolean useHSVInterpolation=(flags & GLRenderer.HSV_COLOR_INTERPOLATION) != 0;
  useHSVInterpolation=false;
  boolean useTextureCoords=(textureProps != null && textureProps.isEnabled() && !textureProps.isAutomatic() && mesh.myTextureIndices != null);
  boolean mergeQuadTriangles=(shadingModel[0] == GL2.GL_SMOOTH);
  if ((flags & IS_SELECTING) != 0) {
    useVertexColors=false;
  }
  if (computeVertexNormals) {
    nrms=new Vector3d[mesh.getNumVertices()];
    for (int v=0; v < mesh.getNumVertices(); v++) {
      nrms[v]=new Vector3d();
      if (useRenderNormals) {
        mesh.getVertices().get(v).computeRenderNormal(nrms[v]);
      }
 else {
        mesh.getVertices().get(v).computeNormal(nrms[v]);
      }
    }
  }
  if (useVertexColors && useHSVInterpolation) {
    useHSVInterpolation=setupHSVInterpolation(gl);
  }
  myLastEdgeCnt=0;
  ArrayList<Face> faceList=mesh.getFaces();
  int[] faceOrder=mesh.getFaceOrder();
  int faceIdx;
  for (int i=0; i < faceList.size(); i++) {
    if (faceOrder == null) {
      faceIdx=i;
    }
 else {
      faceIdx=faceOrder[i];
    }
    faceIdx=unpackEdges(faceList,faceIdx,mergeQuadTriangles);
    Face face=faceList.get(faceIdx);
    if (myEdgeCnt > 4) {
      gl.glBegin(GL2.GL_POLYGON);
    }
 else     if (myLastEdgeCnt != myEdgeCnt) {
      if (myLastEdgeCnt == 3 || myLastEdgeCnt == 4) {
        gl.glEnd();
      }
      if (myEdgeCnt == 3) {
        gl.glBegin(GL2.GL_TRIANGLES);
      }
 else {
        gl.glBegin(GL2.GL_QUADS);
      }
    }
    if (!computeVertexNormals) {
      Vector3d faceNrm;
      if (useRenderNormals) {
        faceNrm=face.getRenderNormal();
      }
 else {
        faceNrm=face.getNormal();
      }
      gl.glNormal3d(faceNrm.x,faceNrm.y,faceNrm.z);
    }
    for (int edgeIdx=0; edgeIdx < myEdgeCnt; edgeIdx++) {
      HalfEdge he=myEdges[edgeIdx];
      Vertex3d vtx=he.head;
      Point3d pnt=useRenderNormals ? vtx.myRenderPnt : vtx.pnt;
      if (computeVertexNormals) {
        HalfEdge lastHard=he.lastHardEdge();
        if (lastHard != null) {
          lastHard.computeVertexNormal(vtxNrm,useRenderNormals);
          gl.glNormal3d(vtxNrm.x,vtxNrm.y,vtxNrm.z);
        }
 else {
          nrm=nrms[he.head.idx];
          gl.glNormal3d(nrm.x,nrm.y,nrm.z);
        }
      }
      if (useTextureCoords) {
        int iv=mesh.myTextureIndices.get(faceIdx)[edgeIdx];
        Vector3d vtext=(Vector3d)mesh.myTextureVertexList.get(iv);
        double sss=vtext.x;
        double ttt=vtext.y;
        gl.glTexCoord2f((float)sss,(float)(1 - ttt));
      }
      if (useVertexColors) {
        setVertexColor(gl,vtx,useHSVInterpolation);
      }
      gl.glVertex3d(pnt.x,pnt.y,pnt.z);
    }
    if (myEdgeCnt > 4) {
      gl.glEnd();
    }
    myLastEdgeCnt=myEdgeCnt;
  }
  if (myLastEdgeCnt == 3 || myLastEdgeCnt == 4) {
    gl.glEnd();
  }
  if (useVertexColors && useHSVInterpolation) {
    gl.glUseProgramObjectARB(0);
  }
}

Fixed version (ground truth):
private void drawFacesRaw(GL2 gl,PolygonalMesh mesh,TextureProps textureProps,int flags){
  Vector3d nrm;
  Vector3d[] nrms=null;
  Vector3d vtxNrm=new Vector3d();
  int[] shadingModel=new int[1];
  gl.glGetIntegerv(GL2.GL_SHADE_MODEL,shadingModel,0);
  boolean computeVertexNormals=(flags & COMPUTE_VERTEX_NORMALS) != 0;
  boolean useRenderNormals=mesh.isRenderBuffered() && !mesh.isFixed();
  boolean useVertexColors=(flags & GLRenderer.VERTEX_COLORING) != 0;
  boolean useHSVInterpolation=(flags & GLRenderer.HSV_COLOR_INTERPOLATION) != 0;
  System.out.println(useHSVInterpolation);
  boolean useTextureCoords=(textureProps != null && textureProps.isEnabled() && !textureProps.isAutomatic() && mesh.myTextureIndices != null);
  boolean mergeQuadTriangles=(shadingModel[0] == GL2.GL_SMOOTH);
  if ((flags & IS_SELECTING) != 0) {
    useVertexColors=false;
  }
  if (computeVertexNormals) {
    nrms=new Vector3d[mesh.getNumVertices()];
    for (int v=0; v < mesh.getNumVertices(); v++) {
      nrms[v]=new Vector3d();
      if (useRenderNormals) {
        mesh.getVertices().get(v).computeRenderNormal(nrms[v]);
      }
 else {
        mesh.getVertices().get(v).computeNormal(nrms[v]);
      }
    }
  }
  if (useVertexColors && useHSVInterpolation) {
    useHSVInterpolation=setupHSVInterpolation(gl);
  }
  myLastEdgeCnt=0;
  ArrayList<Face> faceList=mesh.getFaces();
  int[] faceOrder=mesh.getFaceOrder();
  int faceIdx;
  for (int i=0; i < faceList.size(); i++) {
    if (faceOrder == null) {
      faceIdx=i;
    }
 else {
      faceIdx=faceOrder[i];
    }
    faceIdx=unpackEdges(faceList,faceIdx,mergeQuadTriangles);
    Face face=faceList.get(faceIdx);
    if (myEdgeCnt > 4) {
      gl.glBegin(GL2.GL_POLYGON);
    }
 else     if (myLastEdgeCnt != myEdgeCnt) {
      if (myLastEdgeCnt == 3 || myLastEdgeCnt == 4) {
        gl.glEnd();
      }
      if (myEdgeCnt == 3) {
        gl.glBegin(GL2.GL_TRIANGLES);
      }
 else {
        gl.glBegin(GL2.GL_QUADS);
      }
    }
    if (!computeVertexNormals) {
      Vector3d faceNrm;
      if (useRenderNormals) {
        faceNrm=face.getRenderNormal();
      }
 else {
        faceNrm=face.getNormal();
      }
      gl.glNormal3d(faceNrm.x,faceNrm.y,faceNrm.z);
    }
    for (int edgeIdx=0; edgeIdx < myEdgeCnt; edgeIdx++) {
      HalfEdge he=myEdges[edgeIdx];
      Vertex3d vtx=he.head;
      Point3d pnt=useRenderNormals ? vtx.myRenderPnt : vtx.pnt;
      if (computeVertexNormals) {
        HalfEdge lastHard=he.lastHardEdge();
        if (lastHard != null) {
          lastHard.computeVertexNormal(vtxNrm,useRenderNormals);
          gl.glNormal3d(vtxNrm.x,vtxNrm.y,vtxNrm.z);
        }
 else {
          nrm=nrms[he.head.idx];
          gl.glNormal3d(nrm.x,nrm.y,nrm.z);
        }
      }
      if (useTextureCoords) {
        int iv=mesh.myTextureIndices.get(faceIdx)[edgeIdx];
        Vector3d vtext=(Vector3d)mesh.myTextureVertexList.get(iv);
        double sss=vtext.x;
        double ttt=vtext.y;
        gl.glTexCoord2f((float)sss,(float)(1 - ttt));
      }
      if (useVertexColors) {
        setVertexColor(gl,vtx,useHSVInterpolation);
      }
      gl.glVertex3d(pnt.x,pnt.y,pnt.z);
    }
    if (myEdgeCnt > 4) {
      gl.glEnd();
    }
    myLastEdgeCnt=myEdgeCnt;
  }
  if (myLastEdgeCnt == 3 || myLastEdgeCnt == 4) {
    gl.glEnd();
  }
  if (useVertexColors && useHSVInterpolation) {
    gl.glUseProgramObjectARB(0);
  }
}