From eb7456300253668862a71f9d07fb558400e6ace6 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Thu, 5 Mar 2020 12:49:50 +0200 Subject: [PATCH] Fix camera focus method to handle special case of vertical direction. gitlab #99 Change-Id: I61deefb45e8e4be993a6e4699042a550dda89707 --- .../g3d/vtk/swt/vtkCameraAndSelectorAction.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java index 7a0cc031..7a6f0d89 100644 --- a/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java +++ b/org.simantics.g3d.vtk/src/org/simantics/g3d/vtk/swt/vtkCameraAndSelectorAction.java @@ -401,8 +401,15 @@ public class vtkCameraAndSelectorAction extends vtkSwtAction implements ISelecti public void focus(double x, double y, double z) { Lock(); cam.SetFocalPoint(x, y, z); - if (doNotRotate) - cam.SetViewUp(upDirection); + if (doNotRotate) { + double[] proj = cam.GetDirectionOfProjection(); + if (Math.abs(proj[1] * upDirection[2] - proj[2] * upDirection[1]) < 1e-6 && + Math.abs(proj[2] * upDirection[0] - proj[0] * upDirection[2]) < 1e-6 && + Math.abs(proj[0] * upDirection[1] - proj[1] * upDirection[0]) < 1e-6) + cam.SetViewUp(upDirection[1], upDirection[2], upDirection[0]); + else + cam.SetViewUp(upDirection); + } cam.OrthogonalizeViewUp(); resetCameraClippingRange(); // panel.UpdateLight(); -- 2.47.1