Skip to content

Commit

Permalink
2.0.2 - 2019/03/13
Browse files Browse the repository at this point in the history
@2019.1
  • Loading branch information
ErikMoczi committed Mar 14, 2019
1 parent 987d11f commit 856ae4a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 20 deletions.
3 changes: 3 additions & 0 deletions package/CHANGELOG.md
Expand Up @@ -4,6 +4,9 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [2.0.2] - 2019-03-12
fixes compiler error on non XR platforms (thanks @zilys!)

## [2.0.1] - 2019-01-02
fixes standalone compile error / forward port of 1.3.2 fix

Expand Down
40 changes: 24 additions & 16 deletions package/Runtime/ArmModels/ArmModel.cs
Expand Up @@ -48,7 +48,7 @@ public Pose finalPose
set { m_FinalPose = value; }
}


#if ENABLE_VR
[SerializeField]
XRNode m_PoseSource = XRNode.LeftHand;
/// <summary>
Expand All @@ -70,6 +70,7 @@ public XRNode headGameObject
get { return m_HeadPoseSource; }
set { m_HeadPoseSource = value; }
}
#endif

/// Standard implementation for a mathematical model to make the virtual controller approximate the
/// physical location of the Daydream controller.
Expand Down Expand Up @@ -317,6 +318,7 @@ protected virtual void UpdateHandedness()
{
// Determine handedness multiplier.
m_HandedMultiplier.Set(0, 1, 1);
#if ENABLE_VR
if (m_PoseSource == XRNode.RightHand || m_PoseSource == XRNode.TrackingReference)
{
m_HandedMultiplier.x = 1.0f;
Expand All @@ -325,12 +327,13 @@ protected virtual void UpdateHandedness()
{
m_HandedMultiplier.x = -1.0f;
}
#endif
}

protected virtual bool UpdateTorsoDirection(bool forceImmediate)
{
// Determine the gaze direction horizontally.

#if ENABLE_VR
Vector3 gazeDirection = new Vector3();
if (TryGetForwardVector(m_HeadPoseSource, out gazeDirection))
{
Expand All @@ -357,23 +360,24 @@ protected virtual bool UpdateTorsoDirection(bool forceImmediate)
m_TorsoRotation = Quaternion.FromToRotation(Vector3.forward, m_TorsoDirection);
return true;
}
#endif
return false;
}

protected virtual bool UpdateNeckPosition()
{
#if ENABLE_VR
if (m_IsLockedToNeck && TryGetPosition(m_HeadPoseSource, out m_NeckPosition))
{
// Find the approximate neck position by Applying an inverse neck model.
// This transforms the head position to the center of the head and also accounts
// for the head's rotation so that the motion feels more natural.
return ApplyInverseNeckModel(m_NeckPosition, out m_NeckPosition);
}
else
{
m_NeckPosition = Vector3.zero;
return true;
}
#endif

m_NeckPosition = Vector3.zero;
return true;
}

protected virtual bool ApplyArmModel()
Expand Down Expand Up @@ -460,6 +464,7 @@ protected virtual void ApplyRotationToJoints()
protected virtual bool ApplyInverseNeckModel(Vector3 headPosition, out Vector3 calculatedPosition)
{
// Determine the gaze direction horizontally.
#if ENABLE_VR
Quaternion headRotation = new Quaternion();
if (TryGetRotation(m_HeadPoseSource, out headRotation))
{
Expand All @@ -469,12 +474,14 @@ protected virtual bool ApplyInverseNeckModel(Vector3 headPosition, out Vector3 c

calculatedPosition = headPosition;
return true;
}

}
#endif

calculatedPosition = Vector3.zero;
return false;
}

#if ENABLE_VR
protected bool TryGetForwardVector(XRNode node, out Vector3 forward)
{
Pose tmpPose = new Pose();
Expand Down Expand Up @@ -572,10 +579,12 @@ protected bool TryGetAngularVelocity(XRNode node, out Vector3 angVel)
angVel = Vector3.zero;
return false;
}
#endif

/// Get the controller's orientation.
protected bool GetControllerRotation(out Quaternion rotation, out Quaternion xyRotation, out float xAngle)
{
#if ENABLE_VR
// Find the controller's orientation relative to the player.
if (TryGetRotation(poseSource, out rotation))
{
Expand All @@ -589,13 +598,12 @@ protected bool GetControllerRotation(out Quaternion rotation, out Quaternion xyR
xyRotation = Quaternion.FromToRotation(Vector3.forward, controllerForward);
return true;
}
else
{
rotation = Quaternion.identity;
xyRotation = Quaternion.identity;
xAngle = 0.0f;
return false;
}
#endif

rotation = Quaternion.identity;
xyRotation = Quaternion.identity;
xAngle = 0.0f;
return false;
}

#if UNITY_EDITOR
Expand Down
3 changes: 2 additions & 1 deletion package/Runtime/ArmModels/TransitionArmModel.cs
Expand Up @@ -189,7 +189,7 @@ bool UpdateBlends()
m_TorsoRotation = m_CurrentArmModelComponent.torsoRotation;
#endif


#if ENABLE_VR
Vector3 angVel;
if (TryGetAngularVelocity(poseSource, out angVel) && armModelBlendData.Count > 0)
{
Expand Down Expand Up @@ -234,6 +234,7 @@ bool UpdateBlends()
Debug.LogErrorFormat(this.gameObject, "Unable to get angular acceleration for node");
return false;
}
#endif

finalPose = new Pose(controllerPosition, controllerRotation);
return true;
Expand Down
10 changes: 9 additions & 1 deletion package/Runtime/TrackedPoseDriver/TrackedPoseDriver.cs
Expand Up @@ -89,7 +89,8 @@ public enum PoseDataFlags
/// The PoseDataSource class acts as a container for the GetDatafromSource method call that should be used by PoseProviders wanting to query data for a particular pose.
/// </summary>
static public class PoseDataSource
{
{
#if ENABLE_VR
static internal List<XR.XRNodeState> nodeStates = new List<XR.XRNodeState>();
static internal PoseDataFlags GetNodePoseData(XR.XRNode node, out Pose resultPose)
{
Expand All @@ -113,6 +114,7 @@ static internal PoseDataFlags GetNodePoseData(XR.XRNode node, out Pose resultPos
resultPose = Pose.identity;
return retData;
}
#endif

/// <summary>
/// <signature><![CDATA[GetDataFromSource(TrackedPose,Pose)]]></signature>
Expand All @@ -122,6 +124,7 @@ static internal PoseDataFlags GetNodePoseData(XR.XRNode node, out Pose resultPos
/// <returns>Retuns a bitflag which represents which data has been retrieved from the provided pose source</returns>
static public PoseDataFlags GetDataFromSource(TrackedPoseDriver.TrackedPose poseSource, out Pose resultPose)
{
#if ENABLE_VR
switch (poseSource)
{
case TrackedPoseDriver.TrackedPose.RemotePose:
Expand Down Expand Up @@ -171,19 +174,22 @@ static public PoseDataFlags GetDataFromSource(TrackedPoseDriver.TrackedPose pose
break;
}
}
#endif
resultPose = Pose.identity;
return PoseDataFlags.NoData;
}

static PoseDataFlags TryGetTangoPose(out Pose pose)
{
#if ENABLE_VR
PoseData poseOut;
if (TangoInputTracking.TryGetPoseAtTime(out poseOut) && poseOut.statusCode == PoseStatus.Valid)
{
pose.position = poseOut.position;
pose.rotation = poseOut.rotation;
return PoseDataFlags.Position | PoseDataFlags.Rotation; ;
}
#endif
pose = Pose.identity;

return PoseDataFlags.NoData;
Expand Down Expand Up @@ -453,7 +459,9 @@ protected virtual void Awake()

if (HasStereoCamera())
{
#if ENABLE_VR
XRDevice.DisableAutoXRCameraTracking(GetComponent<Camera>(), true);
#endif
}
}

Expand Down
4 changes: 2 additions & 2 deletions package/package.json
@@ -1,7 +1,7 @@
{
"name": "com.unity.xr.legacyinputhelpers",
"displayName": "XR Legacy Input Helpers",
"version": "2.0.1",
"version": "2.0.2",
"unity": "2019.1",
"category": "XR",
"description": "This package includes the tracked pose driver for the legacy input system, the XR Bindings Seeding Tool and 3Dof Arm Model support for the Tracked Pose Driver. The Tracked Pose Driver is a monobehavior that enables GameObjects to track input devices, the XR Bindings Seeding Tool adds a menu item under the 'Assets' menu which populates the Input Asset with Unity's crossplatform Input Bindings",
Expand All @@ -15,6 +15,6 @@
"repository": {
"type": "git",
"url": "https://gitlab.cds.internal.unity3d.com/upm-packages/XR/LegacyInputHelpers.git",
"revision": "8f69dc39df4f0e1c3c3091512db28fcae9353457"
"revision": "2e7c4c4dbcced83a7e72862f069f6547f4808b42"
}
}
1 change: 1 addition & 0 deletions versions.txt
Expand Up @@ -14,3 +14,4 @@
1.3.2
2.0.0
2.0.1
2.0.2

0 comments on commit 856ae4a

Please sign in to comment.