From fe4a7d14f10408f8633bd1faf48f55b4505b9ba3 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Fillion-Robin Date: Sat, 23 Dec 2023 14:40:49 -0500 Subject: [PATCH] ENH: Update interactor style to use runtime-agnostic API to retrieve poses --- .../vtkVirtualRealityViewInteractorStyle.cxx | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/VirtualReality/MRML/vtkVirtualRealityViewInteractorStyle.cxx b/VirtualReality/MRML/vtkVirtualRealityViewInteractorStyle.cxx index 725e8a2..ee0388b 100644 --- a/VirtualReality/MRML/vtkVirtualRealityViewInteractorStyle.cxx +++ b/VirtualReality/MRML/vtkVirtualRealityViewInteractorStyle.cxx @@ -497,15 +497,10 @@ void vtkVirtualRealityViewInteractorStyle::OnPinch3D() this->Interactor->GetEventPositions(pointer)[0], this->Interactor->GetEventPositions(pointer)[1]); // Get current controller poses - vr::TrackedDevicePose_t* tdPose; - - rw->GetOpenVRPose(vtkEventDataDevice::LeftController, &tdPose); - vtkNew currentController0Pose_Physical; - rw->SetMatrixFromOpenVRPose(currentController0Pose_Physical, *tdPose); - - rw->GetOpenVRPose(vtkEventDataDevice::RightController, &tdPose); - vtkNew currentController1Pose_Physical; - rw->SetMatrixFromOpenVRPose(currentController1Pose_Physical, *tdPose); + vtkMatrix4x4* currentController0Pose_Physical = + rw->GetDeviceToPhysicalMatrixForDevice(vtkEventDataDevice::LeftController); + vtkMatrix4x4* currentController1Pose_Physical = + rw->GetDeviceToPhysicalMatrixForDevice(vtkEventDataDevice::RightController); // Get combined current controller pose vtkNew combinedCurrentControllerPose; @@ -563,15 +558,10 @@ void vtkVirtualRealityViewInteractorStyle::StartGesture() vtkOpenVRRenderWindowInteractor* rwi = static_cast(this->Interactor); vtkOpenVRRenderWindow* rw = static_cast(rwi->GetRenderWindow()); - vr::TrackedDevicePose_t* tdPose; - - rw->GetOpenVRPose(vtkEventDataDevice::LeftController, &tdPose); - vtkNew startingController0Pose_Physical; - rw->SetMatrixFromOpenVRPose(startingController0Pose_Physical, *tdPose); - - rw->GetOpenVRPose(vtkEventDataDevice::RightController, &tdPose); - vtkNew startingController1Pose_Physical; - rw->SetMatrixFromOpenVRPose(startingController1Pose_Physical, *tdPose); + vtkMatrix4x4* startingController0Pose_Physical = + rw->GetDeviceToPhysicalMatrixForDevice(vtkEventDataDevice::LeftController); + vtkMatrix4x4* startingController1Pose_Physical = + rw->GetDeviceToPhysicalMatrixForDevice(vtkEventDataDevice::RightController); if ( this->Internal->CalculateCombinedControllerPose( startingController0Pose_Physical, startingController1Pose_Physical, this->Internal->CombinedStartingControllerPose) )