Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Update interactor style to use runtime-agnostic API to retrieve poses #143

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions VirtualReality/MRML/vtkVirtualRealityViewInteractorStyle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<vtkMatrix4x4> currentController0Pose_Physical;
rw->SetMatrixFromOpenVRPose(currentController0Pose_Physical, *tdPose);

rw->GetOpenVRPose(vtkEventDataDevice::RightController, &tdPose);
vtkNew<vtkMatrix4x4> 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<vtkMatrix4x4> combinedCurrentControllerPose;
Expand Down Expand Up @@ -563,15 +558,10 @@ void vtkVirtualRealityViewInteractorStyle::StartGesture()
vtkOpenVRRenderWindowInteractor* rwi = static_cast<vtkOpenVRRenderWindowInteractor*>(this->Interactor);
vtkOpenVRRenderWindow* rw = static_cast<vtkOpenVRRenderWindow*>(rwi->GetRenderWindow());

vr::TrackedDevicePose_t* tdPose;

rw->GetOpenVRPose(vtkEventDataDevice::LeftController, &tdPose);
vtkNew<vtkMatrix4x4> startingController0Pose_Physical;
rw->SetMatrixFromOpenVRPose(startingController0Pose_Physical, *tdPose);

rw->GetOpenVRPose(vtkEventDataDevice::RightController, &tdPose);
vtkNew<vtkMatrix4x4> 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) )
Expand Down