mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
OpenXR - Estimate world unit scale
This commit is contained in:
parent
4a3f809588
commit
2103874c0f
@ -221,7 +221,7 @@ bool GLRenderManager::ThreadFrame() {
|
||||
VR_SetConfig(VR_CONFIG_3D_GEOMETRY_COUNT, VR_GetConfig(VR_CONFIG_3D_GEOMETRY_COUNT) / 2);
|
||||
|
||||
// Set customizations
|
||||
VR_SetConfig(VR_CONFIG_6DOF, g_Config.bEnable6DoF);
|
||||
VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF);
|
||||
VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.iFieldOfViewPercentage);
|
||||
|
||||
// hack to quick enable 2D mode in game
|
||||
|
@ -477,10 +477,11 @@ ovrMatrix4f VR_GetMatrix( VRMatrix matrix ) {
|
||||
}
|
||||
|
||||
output = ovrMatrix4f_CreateFromQuaternion(&invView.orientation);
|
||||
if (vrConfig[VR_CONFIG_6DOF]) {
|
||||
output.M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f);
|
||||
output.M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f);
|
||||
output.M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f);
|
||||
if (vrConfig[VR_CONFIG_6DOF_ENABLED]) {
|
||||
float scale = (float)VR_GetConfig(VR_CONFIG_6DOF_SCALE) * 0.001f;
|
||||
output.M[0][3] -= hmdposition.x * (vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f) * scale;
|
||||
output.M[1][3] -= hmdposition.y * (vrConfig[VR_CONFIG_MIRROR_AXIS_Y] ? -1.0f : 1.0f) * scale;
|
||||
output.M[2][3] -= hmdposition.z * (vrConfig[VR_CONFIG_MIRROR_AXIS_Z] ? -1.0f : 1.0f) * scale;
|
||||
}
|
||||
} else {
|
||||
assert(false);
|
||||
|
@ -5,7 +5,8 @@
|
||||
|
||||
enum VRConfig {
|
||||
VR_CONFIG_MODE,
|
||||
VR_CONFIG_6DOF,
|
||||
VR_CONFIG_6DOF_ENABLED,
|
||||
VR_CONFIG_6DOF_SCALE,
|
||||
VR_CONFIG_MIRROR_AXIS_X,
|
||||
VR_CONFIG_MIRROR_AXIS_Y,
|
||||
VR_CONFIG_MIRROR_AXIS_Z,
|
||||
|
@ -538,6 +538,10 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid, bool useBu
|
||||
ConvertMatrix4x3To4x4Transposed(m4x4, gstate.viewMatrix);
|
||||
memcpy(gameView.M, m4x4, 16 * sizeof(float));
|
||||
|
||||
// Set 6DoF scale
|
||||
float scale = pow(fabs(gstate.projMatrix[14]), 1.15f);
|
||||
VR_SetConfig(VR_CONFIG_6DOF_SCALE, (int)(scale * 1000));
|
||||
|
||||
// Get view matrix from the headset
|
||||
ovrMatrix4f hmdView = VR_GetMatrix(VR_VIEW_MATRIX_LEFT_EYE);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user