mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
OpenXR - Camera side adjust added
This commit is contained in:
parent
b7da6f7e45
commit
92422160a0
@ -344,15 +344,20 @@ bool StartVRRender() {
|
||||
|
||||
// Camera control
|
||||
if (VR_GetConfig(VR_CONFIG_CAMERA_CONTROL)) {
|
||||
//light joystick controls height
|
||||
//light joystick controls height and side
|
||||
float height = g_Config.fCameraHeight;
|
||||
float side = g_Config.fCameraSide;
|
||||
int status = IN_VRGetButtonState(0);
|
||||
if (status & ovrButton_Left) side -= 0.05f;
|
||||
if (status & ovrButton_Right) side += 0.05f;
|
||||
if (status & ovrButton_Down) height -= 0.05f;
|
||||
if (status & ovrButton_Up) height += 0.05f;
|
||||
if (status & ovrButton_LThumb) {
|
||||
height = 0;
|
||||
side = 0;
|
||||
}
|
||||
g_Config.fCameraHeight = std::clamp(height, -10.0f, 10.0f);
|
||||
g_Config.fCameraSide = std::clamp(side, -10.0f, 10.0f);
|
||||
|
||||
//right joystick controls distance and fov
|
||||
float dst = g_Config.fCameraDistance;
|
||||
@ -374,6 +379,7 @@ bool StartVRRender() {
|
||||
VR_SetConfig(VR_CONFIG_6DOF_ENABLED, g_Config.bEnable6DoF);
|
||||
VR_SetConfig(VR_CONFIG_CAMERA_DISTANCE, g_Config.fCameraDistance * 1000);
|
||||
VR_SetConfig(VR_CONFIG_CAMERA_HEIGHT, g_Config.fCameraHeight * 1000);
|
||||
VR_SetConfig(VR_CONFIG_CAMERA_SIDE, g_Config.fCameraSide * 1000);
|
||||
VR_SetConfig(VR_CONFIG_CANVAS_DISTANCE, g_Config.fCanvasDistance);
|
||||
VR_SetConfig(VR_CONFIG_FOV_SCALE, g_Config.fFieldOfViewPercentage);
|
||||
VR_SetConfig(VR_CONFIG_MIRROR_UPDATED, false);
|
||||
|
@ -354,6 +354,14 @@ bool VR_InitFrame( engine_t* engine ) {
|
||||
vrMatrix[matrix].M[1][3] += up.y;
|
||||
vrMatrix[matrix].M[2][3] += up.z;
|
||||
}
|
||||
if (abs(vrConfig[VR_CONFIG_CAMERA_SIDE]) > 0) {
|
||||
XrVector3f side = {-(float)vrConfig[VR_CONFIG_CAMERA_SIDE] * 0.001f * scale, 0.0f, 0.0f};
|
||||
side = XrQuaternionf_Rotate(invView.orientation, side);
|
||||
side = XrVector3f_ScalarMultiply(side, vrConfig[VR_CONFIG_MIRROR_AXIS_X] ? -1.0f : 1.0f);
|
||||
vrMatrix[matrix].M[0][3] += side.x;
|
||||
vrMatrix[matrix].M[1][3] += side.y;
|
||||
vrMatrix[matrix].M[2][3] += side.z;
|
||||
}
|
||||
if (vrConfig[VR_CONFIG_6DOF_PRECISE] && (matrix == VR_VIEW_MATRIX_RIGHT_EYE)) {
|
||||
float dx = fabs(invViewTransform[1].position.x - invViewTransform[0].position.x);
|
||||
float dy = fabs(invViewTransform[1].position.y - invViewTransform[0].position.y);
|
||||
|
@ -8,7 +8,7 @@ enum VRConfig {
|
||||
VR_CONFIG_MODE, VR_CONFIG_3D_GEOMETRY_COUNT, VR_CONFIG_FORCE_2D,
|
||||
//camera setup
|
||||
VR_CONFIG_FOV_SCALE, VR_CONFIG_CAMERA_CONTROL, VR_CONFIG_CAMERA_DISTANCE,
|
||||
VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CANVAS_DISTANCE,
|
||||
VR_CONFIG_CAMERA_HEIGHT, VR_CONFIG_CAMERA_SIDE, VR_CONFIG_CANVAS_DISTANCE,
|
||||
//6DoF
|
||||
VR_CONFIG_6DOF_ENABLED, VR_CONFIG_6DOF_SCALE, VR_CONFIG_6DOF_PRECISE, VR_CONFIG_MIRROR_UPDATED,
|
||||
VR_CONFIG_MIRROR_AXIS_X, VR_CONFIG_MIRROR_AXIS_Y, VR_CONFIG_MIRROR_AXIS_Z,
|
||||
|
@ -1210,6 +1210,7 @@ static ConfigSetting vrSettings[] = {
|
||||
ConfigSetting("VREnableStereo", &g_Config.bEnableStereo, false),
|
||||
ConfigSetting("VRCameraDistance", &g_Config.fCameraDistance, 0.0f),
|
||||
ConfigSetting("VRCameraHeight", &g_Config.fCameraHeight, 0.0f),
|
||||
ConfigSetting("VRCameraSide", &g_Config.fCameraSide, 0.0f),
|
||||
ConfigSetting("VRCanvasDistance", &g_Config.fCanvasDistance, 6.0f),
|
||||
ConfigSetting("VRFieldOfView", &g_Config.fFieldOfViewPercentage, 100.0f),
|
||||
|
||||
|
@ -465,6 +465,7 @@ public:
|
||||
bool bEnableStereo;
|
||||
float fCameraDistance;
|
||||
float fCameraHeight;
|
||||
float fCameraSide;
|
||||
float fCanvasDistance;
|
||||
float fFieldOfViewPercentage;
|
||||
|
||||
|
@ -1167,6 +1167,7 @@ void GameSettingsScreen::CreateViews() {
|
||||
vrSettings->Add(new ItemHeader(vr->T("VR camera")));
|
||||
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraDistance, -10.0f, 10.0f, vr->T("Camera distance adjust", "Camera distance adjust"), 1.0f, screenManager(), ""));
|
||||
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraHeight, -10.0f, 10.0f, vr->T("Camera height adjust", "Camera height adjust"), 1.0f, screenManager(), ""));
|
||||
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCameraSide, -10.0f, 10.0f, vr->T("Camera side adjust", "Camera side adjust"), 1.0f, screenManager(), ""));
|
||||
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fCanvasDistance, 1.0f, 10.0f, vr->T("Distance to 2D menus and scenes", "Distance to 2D menus and scenes"), 1.0f, screenManager(), ""));
|
||||
vrSettings->Add(new PopupSliderChoiceFloat(&g_Config.fFieldOfViewPercentage, 100.0f, 200.0f, vr->T("Field of view scale", "Headset's field of view scale"), 10.0f, screenManager(), vr->T("% of native FoV")));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user