Skip to content

Commit

Permalink
Merge pull request #16 from provencher/V13Integration
Browse files Browse the repository at this point in the history
Fixes for changes made in V13
  • Loading branch information
provencher authored Feb 7, 2020
2 parents 94fb335 + 982b396 commit 91fd59a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,32 +81,30 @@ public override void SetupDefaultInteractions(Handedness controllerHandedness)
/// Update the controller data from the provided platform state
/// </summary>
/// <param name="interactionSourceState">The InteractionSourceState retrieved from the platform</param>
public void UpdateController(OVRCameraRig ovrRigRoot, OVRInput.Controller ovrController)
public void UpdateController(OVRInput.Controller ovrController, Transform trackingRoot)
{
if (!Enabled || ovrRigRoot == null)
if (!Enabled || trackingRoot == null)
{
return;
}

IsPositionAvailable = OVRInput.GetControllerPositionValid(ovrController);
IsRotationAvailable = OVRInput.GetControllerOrientationValid(ovrController);

Transform playSpaceTransform = ovrRigRoot.transform;

// Update transform
Vector3 localPosition = OVRInput.GetLocalControllerPosition(ovrController);
Vector3 worldPosition = playSpaceTransform.TransformPoint(localPosition);
Vector3 worldPosition = trackingRoot.TransformPoint(localPosition);
// Debug.Log("Controller " + Handedness + " - local: " + localPosition + " - world: " + worldPosition);

Quaternion localRotation = OVRInput.GetLocalControllerRotation(ovrController);
Quaternion worldRotation = playSpaceTransform.rotation * localRotation;
Quaternion worldRotation = trackingRoot.rotation * localRotation;

// Update velocity
Vector3 localVelocity = OVRInput.GetLocalControllerVelocity(ovrController);
Velocity = playSpaceTransform.TransformDirection(localVelocity);
Velocity = trackingRoot.TransformDirection(localVelocity);

Vector3 localAngularVelocity = OVRInput.GetLocalControllerAngularVelocity(ovrController);
AngularVelocity = playSpaceTransform.TransformDirection(localAngularVelocity);
AngularVelocity = trackingRoot.TransformDirection(localAngularVelocity);

UpdateJointPoses();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public override bool IsInPointingPose
/// Update the controller data from the provided platform state
/// </summary>
/// <param name="interactionSourceState">The InteractionSourceState retrieved from the platform</param>
public void UpdateController(OVRHand hand, OVRSkeleton ovrSkeleton)
public void UpdateController(OVRHand hand, OVRSkeleton ovrSkeleton, Transform trackingOrigin)
{
if (!Enabled || hand == null || ovrSkeleton == null)
{
Expand All @@ -101,8 +101,12 @@ public void UpdateController(OVRHand hand, OVRSkeleton ovrSkeleton)
if (isTracked)
{
// Leverage Oculus Platform Hand Ray - instead of simulating it in a crummy way
currentPointerPose.Position = hand.PointerPose.position;
currentPointerPose.Rotation = hand.PointerPose.rotation;
currentPointerPose.Position = trackingOrigin.TransformPoint(hand.PointerPose.position);

Vector3 pointerForward = trackingOrigin.TransformDirection(hand.PointerPose.forward);
Vector3 pointerUp = trackingOrigin.TransformDirection(hand.PointerPose.up);

currentPointerPose.Rotation = Quaternion.LookRotation(pointerForward, pointerUp);

currentGripPose = jointPoses[TrackedHandJoint.Palm];

Expand Down Expand Up @@ -237,14 +241,14 @@ protected void UpdateBone(OVRBone bone)
boneRotation *= Quaternion.Euler(180f, 0f, 0f);

// Rotate palm 90 degrees on y to align x with right
boneRotation *= Quaternion.Euler(0f, 90f, 0f);
boneRotation *= Quaternion.Euler(0f, -90, 0f);
}
else
{
// Right Up direction is correct

// Rotate palm 90 degrees on y to align x with right
boneRotation *= Quaternion.Euler(0f, -90f, 0f);
boneRotation *= Quaternion.Euler(0f, 90f, 0f);
}

UpdateJointPose(joint, boneTransform.position, boneRotation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ protected void UpdateController(OVRInput.Controller controller, Handedness hande
if (OVRInput.IsControllerConnected(controller) && OVRInput.GetControllerPositionTracked(controller))
{
var touchController = GetOrAddController(handedness);
touchController.UpdateController(cameraRig, controller);
touchController.UpdateController(controller, cameraRig.trackingSpace);
}
else
{
Expand Down Expand Up @@ -239,7 +239,7 @@ protected void UpdateHand(OVRHand ovrHand, OVRSkeleton ovrSkeleton, Handedness h
if (ovrHand.IsTracked)
{
var hand = GetOrAddHand(handedness);
hand.UpdateController(ovrHand, ovrSkeleton);
hand.UpdateController(ovrHand, ovrSkeleton, cameraRig.trackingSpace);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Assets/Resources/OVRBuildConfig.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 20553fac56ec59645857c0732b787431, type: 3}
m_Name: OVRBuildConfig
m_EditorClassIdentifier:
androidSDKPath: C:\Users\eprov\AppData\Local\Android\sdk
androidSDKPath:
gradlePath:
jdkPath:
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 0.4
bundleVersion: 0.4.4
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit 91fd59a

Please sign in to comment.