From 68ea6124301ba5bd26bf144ac3b0924b63b398af Mon Sep 17 00:00:00 2001 From: Tiffany Chhim Date: Wed, 30 Nov 2022 15:32:00 +0100 Subject: [PATCH] vtkVRRenderer: Fix hard coded translation when resetting camera In VR, resetting the camera would place the object at floor level. For this reason, a translation was added to bring the object closer to eye level. However, this translation only worked if the view up direction (the direction of the top of the head) was +Y. This commit takes into account the current view up direction to always bring the object to eye level. --- Rendering/VR/vtkVRRenderer.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Rendering/VR/vtkVRRenderer.cxx b/Rendering/VR/vtkVRRenderer.cxx index 1b3c78d708..06a7f7e774 100644 --- a/Rendering/VR/vtkVRRenderer.cxx +++ b/Rendering/VR/vtkVRRenderer.cxx @@ -237,10 +237,11 @@ void vtkVRRenderer::ResetCamera(const double bounds[6]) // be done in the actors but then it requires every actor // to be adjusted. It cannot be done with the camera model // matrix as that is broken. - // The +distance in the Y translation is because we want - // the center of the world to be 1 meter up + // The additional distance translation in the view up direction is because we + // want the center of the world to be above the physical floor instead of at its level. vtkVRRenderWindow* win = static_cast(this->GetRenderWindow()); - win->SetPhysicalTranslation(-center[0], -center[1] + distance, -center[2]); + win->SetPhysicalTranslation( + -center[0] + vup[0] * distance, -center[1] + vup[1] * distance, -center[2] + vup[2] * distance); win->SetPhysicalScale(distance); }