Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AMollis committed Jul 15, 2023
1 parent 5570024 commit 522c056
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public struct AccessibilitySubsystemCinfo :
/// Tests for equality.
/// </summary>
/// <param name="other">The other <see cref="AccessibilitySubsystemCinfo"/> to compare against.</param>
/// <returns>`True` if every field in <paramref name="other"/> is equal to this <see cref="AccessibilitySubsystemCinfo"/>, otherwise false.</returns>
/// <returns><see langword="true"/> if every field in <paramref name="other"/> is equal to this <see cref="AccessibilitySubsystemCinfo"/>, otherwise false.</returns>
public bool Equals(AccessibilitySubsystemCinfo other)
{
return
Expand All @@ -53,8 +53,8 @@ public bool Equals(AccessibilitySubsystemCinfo other)
/// Tests for equality.
/// </summary>
/// <param name="obj">The `object` to compare against.</param>
/// <returns>`True` if <paramref name="obj"/> is of type <see cref=AccessibilitySubsystemCinfo"/> and
/// <see cref="Equals(AccessibilitySubsystemCinfo)"/> also returns `true`; otherwise `false`.</returns>
/// <returns><see langword="true"/> if <paramref name="obj"/> is of type <see cref=AccessibilitySubsystemCinfo"/> and
/// <see cref="Equals(AccessibilitySubsystemCinfo)"/> also returns <see langword="true"/>; otherwise <see langword="false"/>.</returns>
public override bool Equals(System.Object obj)
{
return (obj is AccessibilitySubsystemCinfo cinfo) && Equals(cinfo);
Expand All @@ -65,7 +65,7 @@ public override bool Equals(System.Object obj)
/// </summary>
/// <param name="lhs">The left-hand side of the comparison.</param>
/// <param name="rhs">The right-hand side of the comparison.</param>
/// <returns>`True` if <paramref name="lhs"/> is equal to <paramref name="rhs"/>, otherwise `false`.</returns>
/// <returns><see langword="true"/> if <paramref name="lhs"/> is equal to <paramref name="rhs"/>, otherwise <see langword="false"/>.</returns>
public static bool operator ==(AccessibilitySubsystemCinfo lhs, AccessibilitySubsystemCinfo rhs)
{
return lhs.Equals(rhs);
Expand All @@ -76,12 +76,21 @@ public override bool Equals(System.Object obj)
/// </summary>
/// <param name="lhs">The left-hand side of the comparison.</param>
/// <param name="rhs">The right-hand side of the comparison.</param>
/// <returns>`True` if <paramref name="lhs"/> is not equal to <paramref name="rhs"/>, otherwise `false`.</returns>
/// <returns><see langword="true"/> if <paramref name="lhs"/> is not equal to <paramref name="rhs"/>, otherwise <see langword="false"/>.</returns>
public static bool operator !=(AccessibilitySubsystemCinfo lhs, AccessibilitySubsystemCinfo rhs)
{
return !(lhs == rhs);
}

/// <summary>
/// Overridden to disable hash lookups of <see cref="AccessibilitySubsystemCinfo"/> types.
/// </summary>
/// <remarks>
/// This will throw a <see cref="ApplicationException"/> if called.
/// </remarks>
/// <exception cref="ApplicationException">
/// Thrown if this function is called.
/// </exception>
public override int GetHashCode()
{
throw new ApplicationException("Do not hash subsystem descriptors as keys.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class HandsSubsystemCinfo : MRTKSubsystemCinfo
/// Tests for equality.
/// </summary>
/// <param name="other">The other <see cref="HandsSubsystem"/> to compare against.</param>
/// <returns>`True` if every field in <paramref name="other"/> is equal to this <see cref="HandsSubsystem"/>, otherwise false.</returns>
/// <returns><see langword="true"/> if every field in <paramref name="other"/> is equal to this <see cref="HandsSubsystem"/>, otherwise false.</returns>
public override bool Equals(MRTKSubsystemCinfo other)
{
return base.Equals(other) && IsPhysicalData == (other as HandsSubsystemCinfo)?.IsPhysicalData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,49 @@
namespace Microsoft.MixedReality.Toolkit.Subsystems
{
/// <summary>
/// Specification for what a HandsAggregatorSubsystem needs to be able to provide.
/// Both the HandsAggregatorSubsystem implementation and the associated provider
/// MUST implement this interface, preferably with a direct 1:1 mapping
/// between the provider surface and the subsystem surface.
/// Specification for what a subsystem needs to be able to provide to aggregator multiple
/// <see cref="IHandsSubsystem"/> subsystems.
/// </summary>
/// <remarks>
/// HandsAggregators aggregate skeletal hand joint data from all available sources.
/// Implementations can aggregate hand joint data from multiple APIs, or from multiple
/// HandsSubsystems, or from any other source they choose.
/// <para>
/// Both the <see cref="IHandsAggregatorSubsystem"/> implementations and the associated provider
/// must implement this interface, preferably with a direct one to one mapping
/// between the provider surface and the subsystem surface.
/// </para>
/// <para>
/// Implementations of <see cref="IHandsAggregatorSubsystem"/> aggregate skeletal hand joint
/// data from all available sources. Implementations can aggregate hand joint data from multiple
/// APIs, or from multiple subsystems, or from any other source they choose.
/// Recommended use is for aggregating from all loaded HandsSubsystems.
/// See <see cref="MRTKHandsAggregatorSubsystem"/> for the MRTK implementation.
/// See the <c>MRTKHandsAggregatorSubsystem</c> class for the MRTK implementation.
/// </para>
/// </remarks>
public interface IHandsAggregatorSubsystem : ISubsystem
{
/// <summary>
/// The play space local pose of the near interaction point.
/// </summary>
/// <remarks>
/// This will be the index finger tip of a fully tracked articulated hand,
/// or a best estimate of the equivalent location when less information is
/// available on the platform.
/// </summary>
/// </remarks>
/// <returns><see langword="true"/> if the joint pose was found, and <see langword="false"/> otherwise.</returns>
bool TryGetNearInteractionPoint(XRNode hand, out HandJointPose jointPose);

/// <summary>
/// The play space local pose of the grab/pinch location. This is typically
/// halfway between the thumb tip and the index tip.
/// The play space local pose of the grab/pinch location.
/// </summary>
/// <remarks>
/// This is typically halfway between the thumb tip and the index tip.
/// </remarks>
/// <returns><see langword="true"/> if the joint pose was found, and <see langword="false"/> otherwise.</returns>
bool TryGetPinchingPoint(XRNode hand, out HandJointPose jointPose);

/// <summary>
/// How pinched the specific hand is.
/// </summary>
/// <param name="hand">The hand node being queried.</param>
/// <param name="isReadyToPinch">Represents whether the hand is in a pinch ready pose or not, within the camera's FOV and palm facing away from the user.</param>
/// <param name="isPinching">If hand is not pinching at all, this will be false.</param>
/// <param name="pinchAmount">This value will be <c>0</c> for no pinch, <c>1</c> for fully pinched, or any floating point value if in between.</param>
Expand All @@ -48,19 +60,29 @@ public interface IHandsAggregatorSubsystem : ISubsystem
/// <summary>
/// Whether the palm of the given handedness is facing away from the user
/// </summary>
/// <param name="palmFacingAway">returns true if the palm is facing away from the other, false otherwise. </param>
/// <param name="hand">The hand node being queried.</param>
/// <param name="palmFacingAway">Will be <see langword="true"/> if the palm is facing away from the other, <see langword="false"/> otherwise.</param>
/// <returns><see langword="true"/> if the hand was found, and <see langword="false"/> otherwise.</returns>
bool TryGetPalmFacingAway(XRNode hand, out bool palmFacingAway);

/// <summary>
/// Queries a specific hand joint, specified by <paramref name="joint"/>.
/// </summary>
/// <param name="joint">Identifier of the requested joint.</param>
/// <param name="hand">The hand node being queried.</param>
/// <param name="jointPose">The resulting joint pose that was found.</param>
/// <returns><see langword="true"/> if the joint pose was found, and <see langword="false"/> otherwise.</returns>
bool TryGetJoint(TrackedHandJoint joint, XRNode hand, out HandJointPose jointPose);

/// <summary>
/// Get a read-only reference to the entire hand.
/// Joint poses are returned in an order consistent where each index matches up with the <see cref="Microsoft.MixedReality.Toolkit.TrackedHandJoint"/> enum
/// </summary>
/// <remarks>
/// Joint poses are returned in an order consistent where each index matches up with the <see cref="Microsoft.MixedReality.Toolkit.TrackedHandJoint"/> enumeration.
/// </remarks>
/// <param name="hand">The hand node being queried.</param>
/// <param name="jointPoses">The resulting joint poses that were found.</param>
/// <returns><see langword="true"/> if the hand was found, and <see langword="false"/> otherwise.</returns>
bool TryGetEntireHand(XRNode hand, out IReadOnlyList<HandJointPose> jointPoses);
}
}
11 changes: 10 additions & 1 deletion com.microsoft.mrtk.core/Subsystems/MRTKLifecycleManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@ public class MRTKLifecycleManager :
MonoBehaviour,
IDisposable
{
protected List<IMRTKManagedSubsystem> managedSubsystems = new List<IMRTKManagedSubsystem>();
private List<IMRTKManagedSubsystem> managedSubsystems = new List<IMRTKManagedSubsystem>();

/// <summary>
/// The list of <see cref="IMRTKManagedSubsystem"/> objects being managed by this class.
/// </summary>
protected List<IMRTKManagedSubsystem> ManagedSubsystems
{
get => managedSubsystems;
set => managedSubsystems = value;
}

#region MonoBehaviour

Expand Down
12 changes: 12 additions & 0 deletions com.microsoft.mrtk.core/Subsystems/MRTKSubsystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,28 @@ void IMRTKManagedSubsystem.FixedUpdate()
}
}

/// <summary>
/// Called in response to the lifecycle manager
/// update event function being called, if this subsystem is running.
/// </summary>
protected virtual void OnUpdate()
{
provider.Update();
}

/// <summary>
/// Called in response to the lifecycle manager
/// late update event function being called, if this subsystem is running.
/// </summary>
protected virtual void OnLateUpdate()
{
provider.LateUpdate();
}

/// <summary>
/// Called in response to the lifecycle manager
/// fix update event function being called, if this subsystem is running.
/// </summary>
protected virtual void OnFixedUpdate()
{
provider.FixedUpdate();
Expand Down
35 changes: 24 additions & 11 deletions com.microsoft.mrtk.core/Subsystems/MRTKSubsystemDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Microsoft.MixedReality.Toolkit.Subsystems
{
/// <summary>
/// Encapsulates the parameters for creating a new <see cref="MRTKSubsystemDescriptor"/>.
/// Encapsulates the parameters for creating a new <see cref="MRTKSubsystemDescriptor{T, U}"/>.
/// </summary>
public class MRTKSubsystemCinfo :
IEquatable<MRTKSubsystemCinfo>, IMRTKSubsystemDescriptor
Expand Down Expand Up @@ -38,7 +38,7 @@ public class MRTKSubsystemCinfo :
/// Tests for equality.
/// </summary>
/// <param name="other">The other <see cref="MRTKSubsystemCinfo"/> to compare against.</param>
/// <returns>`True` if every field in <paramref name="other"/> is equal to this <see cref="MRTKSubsystemCinfo"/>, otherwise false.</returns>
/// <returns><see langword="true"/> if every field in <paramref name="other"/> is equal to this <see cref="MRTKSubsystemCinfo"/>, otherwise false.</returns>
public virtual bool Equals(MRTKSubsystemCinfo other)
{
return
Expand All @@ -50,32 +50,43 @@ public virtual bool Equals(MRTKSubsystemCinfo other)
/// <summary>
/// Tests for equality.
/// </summary>
/// <param name="obj">The `object` to compare against.</param>
/// <returns>`True` if <paramref name="obj"/> is of type <see cref="MRTKSubsystemCinfo"/> and
/// <see cref="Equals(MRTKSubsystemCinfo)"/> also returns `true`; otherwise `false`.</returns>
/// <param name="obj">The object to compare against.</param>
/// <returns><see langword="true"/> if <paramref name="obj"/> is of type <see cref="MRTKSubsystemCinfo"/> and
/// <see cref="Equals(MRTKSubsystemCinfo)"/> also returns <see langword="true"/>; otherwise <see langword="false"/>.</returns>
public override bool Equals(System.Object obj)
{
return (obj is MRTKSubsystemCinfo cinfo) && Equals(cinfo);
}

/// <summary>
/// Overridden to disable hash lookups of <see cref="MRTKSubsystemCinfo"/> types.
/// </summary>
/// <remarks>
/// This will throw a <see cref="ApplicationException"/> if called.
/// </remarks>
/// <exception cref="ApplicationException">
/// Thrown if this function is called.
/// </exception>
public override int GetHashCode()
{
throw new ApplicationException("Do not hash subsystem descriptors as keys.");
}
}

/// <summary>
/// Specifies a functionality description that implements the IMRTKSubsystemDescriptor interface.
/// Generic, and useful for basic subsystems that don't require more advanced properties/metadata.
/// Specifies a functionality description that implements the <see cref="IMRTKSubsystemDescriptor"/> interface.
/// </summary>
/// <remarks>
/// Generic, and useful for basic subsystems that don't require more advanced properties or metadata.
/// </remarks>
public class MRTKSubsystemDescriptor<TSubsystem, TProvider> :
SubsystemDescriptorWithProvider<TSubsystem, TProvider>,
IMRTKSubsystemDescriptor
where TSubsystem : SubsystemWithProvider, new()
where TProvider : SubsystemProvider<TSubsystem>
{
/// <summary>
/// Initializes a new instance of the <see cref="MRTKSubsystemDescriptor"/> class.
/// Initializes a new instance of the <see cref="MRTKSubsystemDescriptor{T, U}"/> class.
/// </summary>
/// <param name='MRTKSubsystemCinfo'>The parameters required to initialize the descriptor.</param>
public MRTKSubsystemDescriptor(MRTKSubsystemCinfo MRTKSubsystemCinfo)
Expand Down Expand Up @@ -111,12 +122,14 @@ public MRTKSubsystemDescriptor(MRTKSubsystemCinfo MRTKSubsystemCinfo)
#endregion IMRTKDescriptor implementation

/// <summary>
/// Creates a <c>MRTKSubsystemDescriptor</c> based on the given parameters validating that the
/// <c>id</c> and <c>implentationType</c> properties are specified.
/// Creates a <see cref="MRTKSubsystemDescriptor{T, U}"/> based on the given parameters.
/// </summary>
/// <remarks>
/// This validated that the <see cref="MRTKSubsystemCinfo"/> properties are specified.
/// </remarks>
/// <param name='cinfo'>The parameters required to initialize the descriptor.</param>
/// <returns>
/// The created <c>MRTKSubsystemDescriptor</c>.
/// The newly created instances of the <see cref="MRTKSubsystemDescriptor{T, U}"/> class.
/// </returns>
internal static MRTKSubsystemDescriptor<TSubsystem, TProvider> Create(MRTKSubsystemCinfo cinfo)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class DictationSubsystemCinfo : MRTKSubsystemCinfo
/// Tests for equality.
/// </summary>
/// <param name="other">The other <see cref="DictationSubsystemCinfo"/> to compare against.</param>
/// <returns>`True` if every field in <paramref name="other"/> is equal to this <see cref="DictationSubsystemCinfo"/>, otherwise false.</returns>
/// <returns><see langword="true"/> if every field in <paramref name="other"/> is equal to this <see cref="DictationSubsystemCinfo"/>, otherwise false.</returns>
public override bool Equals(MRTKSubsystemCinfo other)
{
return base.Equals(other) && IsCloudBased == (other as DictationSubsystemCinfo)?.IsCloudBased;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class KeywordRecognitionSubsystemCinfo : MRTKSubsystemCinfo
/// Tests for equality.
/// </summary>
/// <param name="other">The other <see cref="KeywordRecognitionSubsystemCinfo"/> to compare against.</param>
/// <returns>`True` if every field in <paramref name="other"/> is equal to this <see cref="KeywordRecognitionSubsystemCinfo"/>, otherwise false.</returns>
/// <returns><see langword="true"/> if every field in <paramref name="other"/> is equal to this <see cref="KeywordRecognitionSubsystemCinfo"/>, otherwise false.</returns>
public override bool Equals(MRTKSubsystemCinfo other)
{
return base.Equals(other) && IsCloudBased == (other as KeywordRecognitionSubsystemCinfo)?.IsCloudBased;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class TextToSpeechSubsystemCinfo : MRTKSubsystemCinfo
/// Tests for equality.
/// </summary>
/// <param name="other">The other <see cref="MicrosoftTextToSpeechSubsystem"/> to compare against.</param>
/// <returns>`True` if every field in <paramref name="other"/> is equal to this <see cref="TextToSpeechSubsystem"/>, otherwise false.</returns>
/// <returns><see langword="true"/> if every field in <paramref name="other"/> is equal to this <see cref="TextToSpeechSubsystem"/>, otherwise false.</returns>
public override bool Equals(MRTKSubsystemCinfo other)
{
// TODO: Add comparison of subsystem specific property values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public static Vector3 Median(this ICollection<Vector3> vectors)
/// </summary>
/// <param name="vector">The 3D vector whose components will be tested.</param>
/// <returns>
/// `true` is all 3D vector components are a numbers and are not infinite, otherwise `false`.
/// <see langword="true"/> is all 3D vector components are a numbers and are not infinite, otherwise <see langword="false"/>.
/// </returns>
public static bool IsValidVector(this Vector3 vector)
{
Expand All @@ -303,7 +303,7 @@ public static bool IsValidVector(this Vector3 vector)
/// </summary>
/// <param name="vector">The 2D vector whose components will be tested.</param>
/// <returns>
/// `true` is all 2D vector components are a numbers and are not infinite, otherwise `false`.
/// <see langword="true"/> is all 2D vector components are a numbers and are not infinite, otherwise <see langword="false"/>.
/// </returns>
public static bool IsValidVector(this Vector2 vector)
{
Expand Down
Loading

0 comments on commit 522c056

Please sign in to comment.