OVR: Fixed right-hand tracking
authorAndreas Eversberg <jolly@eversberg.eu>
Sat, 25 May 2019 08:07:29 +0000 (10:07 +0200)
committerAndreas Eversberg <jolly@eversberg.eu>
Sat, 25 May 2019 08:07:29 +0000 (10:07 +0200)
src/libovr/ovr.c
src/mercenary/main.c

index 880dad1..c5f75b0 100755 (executable)
@@ -101,7 +101,7 @@ static int mirror_height;
 static ovrEyeRenderDesc eyeRenderDesc[2];
 static ovrPosef hmdToEyeViewPose[2];
 static ovrPosef headPose;
 static ovrEyeRenderDesc eyeRenderDesc[2];
 static ovrPosef hmdToEyeViewPose[2];
 static ovrPosef headPose;
-static ovrPosef handPoses[2];
+static ovrPosef handPose;
 static ovrInputState inputState;
 static ovrLayerEyeFov layer;
 static int multisampling;
 static ovrInputState inputState;
 static ovrLayerEyeFov layer;
 static int multisampling;
@@ -245,6 +245,8 @@ void get_poses_ovr(int *button_a, int *button_b, int *button_x, int *button_y, i
        ovrResult result;
        float yaw, pitch, roll;
        double x, y, z;
        ovrResult result;
        float yaw, pitch, roll;
        double x, y, z;
+       unsigned int hand_mask = (ovrStatus_OrientationTracked | ovrStatus_PositionTracked);
+       unsigned int hand_flags = (ovrStatus_OrientationTracked | ovrStatus_PositionTracked);
 
        /* Get both eye poses simultaneously, with IPD offset already included. */
        double displayMidpointSeconds = ovr_GetPredictedDisplayTime(session, frameIndex);
 
        /* Get both eye poses simultaneously, with IPD offset already included. */
        double displayMidpointSeconds = ovr_GetPredictedDisplayTime(session, frameIndex);
@@ -252,17 +254,14 @@ void get_poses_ovr(int *button_a, int *button_b, int *button_x, int *button_y, i
        ovr_CalcEyePoses(hmdState.HeadPose.ThePose, hmdToEyeViewPose, layer.RenderPose);
        /* Grab hand poses useful for rendering head/hand or controller representation */
        headPose = hmdState.HeadPose.ThePose;
        ovr_CalcEyePoses(hmdState.HeadPose.ThePose, hmdToEyeViewPose, layer.RenderPose);
        /* Grab hand poses useful for rendering head/hand or controller representation */
        headPose = hmdState.HeadPose.ThePose;
-       if (hmdState.HandStatusFlags[ovrHand_Left] == (ovrStatus_OrientationTracked | ovrStatus_PositionTracked))
-               handPoses[ovrHand_Left]  = hmdState.HandPoses[ovrHand_Left].ThePose;
-       else
-               handPoses[ovrHand_Left] = headPose;
-       if (hmdState.HandStatusFlags[ovrHand_Right] == (ovrStatus_OrientationTracked | ovrStatus_PositionTracked))
-               handPoses[ovrHand_Right] = hmdState.HandPoses[ovrHand_Right].ThePose;
-       else
-               handPoses[ovrHand_Right] = headPose;
-       x = handPoses[ovrHand_Right].Position.x;
-       y = handPoses[ovrHand_Right].Position.y;
-       z = handPoses[ovrHand_Right].Position.z;
+       handPose = headPose;
+//     if ((hmdState.HandStatusFlags[ovrHand_Left] & hand_mask) == hand_flags)
+//             handPose = hmdState.HandPoses[ovrHand_Left].ThePose;
+       if ((hmdState.HandStatusFlags[ovrHand_Right] & hand_mask) == hand_flags)
+               handPose = hmdState.HandPoses[ovrHand_Right].ThePose;
+       x = handPose.Position.x;
+       y = handPose.Position.y;
+       z = handPose.Position.z;
        x += hand_x_reset;
        y += hand_y_reset;
        z += hand_z_reset;
        x += hand_x_reset;
        y += hand_y_reset;
        z += hand_z_reset;
@@ -273,7 +272,7 @@ void get_poses_ovr(int *button_a, int *button_b, int *button_x, int *button_y, i
        *head_yaw = yaw;
        *head_pitch = pitch;
        *head_roll = roll;
        *head_yaw = yaw;
        *head_pitch = pitch;
        *head_roll = roll;
-       ovrOrientation2yawpitchroll(handPoses[ovrHand_Right].Orientation, &yaw, &pitch, &roll);
+       ovrOrientation2yawpitchroll(handPose.Orientation, &yaw, &pitch, &roll);
        *hand_right_yaw = yaw;
        *hand_right_pitch = pitch;
        *hand_right_roll = roll;
        *hand_right_yaw = yaw;
        *hand_right_pitch = pitch;
        *hand_right_roll = roll;
index d4ac4ee..1ba1f44 100644 (file)
@@ -1496,7 +1496,7 @@ int main(int argc, char *argv[])
        window_width = (config_debug_opengl) ? SCREEN_WIDTH / 3 * 2 : SCREEN_WIDTH;
        window_height = (config_debug_opengl) ? SCREEN_HEIGHT / 3 * 4 : SCREEN_HEIGHT;
 #endif
        window_width = (config_debug_opengl) ? SCREEN_WIDTH / 3 * 2 : SCREEN_WIDTH;
        window_height = (config_debug_opengl) ? SCREEN_HEIGHT / 3 * 4 : SCREEN_HEIGHT;
 #endif
-       rc = init_sdl(argv[0], window_width, window_height, SOUND_SAMPLERATE, sdl_sound_chunk, keyboard_sdl, config_joystick, config_joystick_x, config_joystick_y, config_joystick_fire, joystick_sdl, audio_sdl, resize_window, multisampling, vbl_sync, vr);
+       rc = init_sdl(mercenary_name, window_width, window_height, SOUND_SAMPLERATE, sdl_sound_chunk, keyboard_sdl, config_joystick, config_joystick_x, config_joystick_y, config_joystick_fire, joystick_sdl, audio_sdl, resize_window, multisampling, vbl_sync, vr);
        if (rc < 0)
                goto done;
 #ifdef HAVE_OVR
        if (rc < 0)
                goto done;
 #ifdef HAVE_OVR