/**
   * Transforming the modelview matrix with the Rift's head rotation causes the {@link
   * OrbitView#focusOnViewportCenter()} method to focus on the center of the viewport, which means
   * the view jumps around depending on the head rotation. This method calls the focus method using
   * an untransformed modelview matrix, keeping the center rotation point more consistent.
   *
   * @param dc
   */
  protected void fixViewportCenterPosition(DrawContext dc, DrawableSceneController sc) {
    dc.setViewportCenterPosition(null);
    Point vpc = dc.getViewportCenterScreenPoint();
    if (vpc == null) {
      return;
    }

    try {
      disableHeadTransform = true;
      sc.applyView(dc);
      dc.enablePickingMode();

      List<Point> points = Arrays.asList(new Point[] {vpc});
      List<PickedObject> pickedObjects = dc.getSurfaceGeometry().pick(dc, points);

      if (pickedObjects == null || pickedObjects.size() == 0) {
        return;
      }

      dc.setViewportCenterPosition((Position) pickedObjects.get(0).getObject());
    } finally {
      disableHeadTransform = false;
      sc.applyView(dc);
      dc.disablePickingMode();
    }
  }