OpenXR: Fix near plane clipping with camera inside volume
Adding a clipping plane to vtkOpenGLGPUVolumeRaycastMapper in order to handle camera near plane clipping is currently broken in XR and users can see through the volume when placing the head inside it.
- The
vtkOpenGLGPUVolumeRaycastMapper::IsCameraInside
check fails because the frustum planes returned by a VRCamera are wrong (physical vs world) - If not overridden in VRCamera,
GetFrustumPlanes
callsGetCompositeProjectionTransformMatrix
which ignores the stereo matrices and computes regular camera projection. - Overriding ComputeProjectionTransform as follow fixes the clipping issue, but computing a regular projection matrix is still required for hardware picking. TODO: Find a better approach that using "LastRenderer", or confirm LastRenderer is a good candidate to check the TrackHMD flag.
if (!this->LastRenderer || !this->LastRenderer->GetRenderWindow() ||
vtkVRRenderWindow::SafeDownCast(this->LastRenderer->GetRenderWindow())->GetTrackHMD())
{
this->ProjectionTransform->Identity();
if (this->LeftEye)
this->ProjectionTransform->Concatenate(this->LeftEyeToProjectionMatrix);
else
this->ProjectionTransform->Concatenate(this->RightEyeToProjectionMatrix);
}
else
{
this->Superclass::ComputeProjectionTransform(aspect, nearz, farz);
}
Edited by Lucas Gandel