Skip to content

Commit

Permalink
Adding in some missing documentation to the MRTK3 source. (#11614)
Browse files Browse the repository at this point in the history
Adding in some missing documentation to the MRTK3 source.  

This also replaces some `ref` parameters with `in` parameters, in cases where it was obvious that only "const refs" were needed.  This also removed the `InterpolationType.Hermite` since it was never handled or used.

The following were documentated:
  - [x] `CameraSettings` class
  - [x] `LabelWidthAttribute` class
  - [x] `MathExtensions.PowerOfTwoGreate=rThanOrEqualTo`
  - [x] `MathExtensions.CubicToLinearIndex`
  - [x] `MathExtensions.LinearToCubicIndex`
  - [x] `MathExtensions.ClampComponentWise`
  - [x] `RayStep` struct and some functions
  - [x] `StatefulInteractable` class
  - [x] `SystemInterfaceType` constructors
  - [x] `SystemType` public functions
  - [x] `TimedFlag` class definition
  - [x] `UXBindingProfileTemplate` properties
  - [x] `VectorExtensions` some functions
  - [x] `TextToSpeechSubsystem.Provider` class definition
  - [x] `BezierInertia` class definition, serialized field tooltips
  - [x] `FuzzyGazeInteractor.GazeRaycastHitResult` struct definition and public members
  - [x] `HandJointInteractor` public method
  - [x] `HandshapeTypes` class definition
  - [x] `InputActionPoseSource` serialized field tooltips.
  - [x] `InteractionMode` struct definition and serialized field tooltips and properties
  - [x] `InteractionModeDefinition` serialized field tooltips and properties
  - [x] `InteractionModeManager` public method
  - [x] `InterpolationType` enum values
  - [x] `MRTKHandsAggregatorSubsystem.MRTKAggregator` class definition and public members

## Bugs
- #11596
- #1159
  • Loading branch information
AMollis committed Jun 10, 2023
1 parent a29be1d commit 875c1ad
Show file tree
Hide file tree
Showing 28 changed files with 569 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.MixedReality.Toolkit.Examples.Demos
/// look great on items that are vertically large, as items are curved at a
/// GameObject level. Their contents will remain flat.
/// </summary>
[AddComponentMenu("MRTX/Examples/Scroll Rect Curve")]
[AddComponentMenu("MRTK/Examples/Scroll Rect Curve")]
public class ScrollRectCurve : MonoBehaviour
{
[SerializeField]
Expand Down
14 changes: 12 additions & 2 deletions com.microsoft.mrtk.core/Camera/CameraSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@

namespace Microsoft.MixedReality.Toolkit
{
/// <summary>
/// Class that contains settings which are applied to <see cref="Microsoft.MixedReality.Toolkit.CameraSettingsManager">CameraSettingsManager</see>.
/// </summary>
[Serializable]
[AddComponentMenu("MRTK/Core/Camera Settings")]
public class CameraSettings
{
/// <summary>
/// Constructor.
/// Initializes a new instance of the <see cref="CameraSettings"/> class.
/// </summary>
public CameraSettings() : this(DisplayType.Transparent)
{ }

/// <summary>
/// Constructor.
/// Initializes a new instance of the <see cref="CameraSettings"/> class.
/// </summary>
/// <param name="displayType">
/// <see cref="DisplayType"/> value describing the device display.
Expand Down Expand Up @@ -46,7 +49,14 @@ public CameraSettings(DisplayType displayType)
}
}

/// <summary>
/// The default clear mode used for opaque displays.
/// </summary>
public static readonly CameraClearFlags DefaultClearModeOpaque = CameraClearFlags.Skybox;

/// <summary>
/// The default clear mode used for transparent displays.
/// </summary>
public static readonly CameraClearFlags DefaultClearModeTransparent = CameraClearFlags.SolidColor;

[SerializeField]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,30 @@ namespace Microsoft.MixedReality.Toolkit
{
/// <summary>
/// This profile combines binding profiles for all Data Consumers used in the MRTK UXComponents components and
/// is used by the BindingConfigurator that can be dropped on any prefab (or gameobject hierarchy)
/// is used by the BindingConfigurator that can be dropped on any prefab (or game object hierarchy)
/// to automatically configure all Data Consumers that will be needed to make those game objects data bindable
/// and themable.
/// and capable of theming.
/// </summary>
[CreateAssetMenu(fileName = "MRTK_UX_BindingProfile", menuName = "MRTK/Data Binding/UXBindingProfile")]
public class UXBindingProfileTemplate : ScriptableObject
{
[Tooltip("Optional type specifiers for data sources to be injected into data consumers. This will typically be one data and one theme data source. If left empty, the default 'data' and 'theme' data sources will be used.")]
[SerializeField]
private string[] dataSourceTypes;

/// <summary>
/// Optional type specifiers for data sources to be injected into data consumers. This will typically be one data and one theme data source.
/// If left empty, the default 'data' and 'theme' data sources will be used.
/// </summary>
public string[] DataSourceTypes => dataSourceTypes;

[Tooltip("An array of binding profiles for specific classes, typically data consumers.")]
[SerializeField]
private ClassDataBindingProfile[] classBindings;

/// <summary>
/// An array of binding profiles for specific classes, typically data consumers.
/// </summary>
public ClassDataBindingProfile[] ClassBindings => classBindings;
}
}
Expand Down
23 changes: 18 additions & 5 deletions com.microsoft.mrtk.core/Interactables/StatefulInteractable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
using UnityEngine.XR.Interaction.Toolkit;

namespace Microsoft.MixedReality.Toolkit
{
{
/// <summary>
/// An extended version of <see cref="Microsoft.MixedReality.Toolkit.MRTKBaseInteractable">MRTKBaseInteractable</see> that adds additional
/// functionality such as speech support, gaze support, and toggle behaviors.
/// </summary>
[AddComponentMenu("MRTK/Core/Stateful Interactable")]
public class StatefulInteractable : MRTKBaseInteractable
{
Expand All @@ -20,12 +24,21 @@ public class StatefulInteractable : MRTKBaseInteractable
/// </summary>
public enum ToggleType
{
// Interactable will not enter toggle states
// unless forced by code (ForceSetToggle)
/// <summary>
/// The interactable will not enter toggle states unless forces by code
/// using the <see cref="ForceSetToggled" /> function.
/// </summary>
Button,
// User can toggle on and off

/// <summary>
/// The user can toggle on and off the interactable.
/// </summary>
Toggle,
// User can only toggle on, not off. Useful for radio buttons.

/// <summary>
/// The User can only toggle on the interactable, but not toggle off.
/// This value is useful for radio buttons.
/// </summary>
OneWayToggle
}

Expand Down
11 changes: 11 additions & 0 deletions com.microsoft.mrtk.core/Subsystems/MRTKSubsystemProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ public virtual void LateUpdate() { }
/// </summary>
public virtual void FixedUpdate() { }

/// <summary>
/// Destroys this instance of a Unity subsystem.
/// </summary>
public override void Destroy() { }

/// <summary>
/// Starts an instance of a Unity subsystem.
/// </summary>
public override void Start() { }

/// <summary>
/// Stops an instance of a Unity subsystem.
/// </summary>
public override void Stop() { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@

namespace Microsoft.MixedReality.Toolkit
{
/// <summary>
/// Indicates that the serializable property's label should be of a particular width when rendered in the Unity inspector window.
/// </summary>
/// <remarks>
/// This attribute does not indicate a font size change, and is only applicable to applications running in the Unity Editor.
/// </remarks>
[AttributeUsage(AttributeTargets.Field)]
public class LabelWidthAttribute : PropertyAttribute
{
/// <summary>
/// Get the width to apply to the serializable property's label when the label is rendered in the Unity inspector window.
/// </summary>
public float Width { get; }

/// <summary>
/// Initializes a new instance of the <see cref="LabelWidthAttribute"/> class.
/// </summary>
/// <param "name">The width to apply to the serializable property's label when the label is rendered in the Unity inspector window.</param>
public LabelWidthAttribute(float width)
{
Width = width;
Expand Down
71 changes: 61 additions & 10 deletions com.microsoft.mrtk.core/Utilities/Extensions/MathfExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ namespace Microsoft.MixedReality.Toolkit
/// </summary>
public static class MathExtensions
{
/// <summary>
/// Get the most significant bit from the input value.
/// </summary>
/// <param name="x">The input value to examine.</param>
/// <returns>
/// Integer value that is equal to the most significant bit within the input value.
/// </returns>
public static int MostSignificantBit(this int x)
{
x |= (x >> 1);
Expand All @@ -21,32 +28,76 @@ public static int MostSignificantBit(this int x)
return x & ~(x >> 1);
}

public static int PowerOfTwoGreaterThanOrEqualTo(this int v)
/// <summary>
/// Get the value that is the next power of two at or after the input value.
/// </summary>
/// <param name="input">The value to test.</param>
/// <returns>
/// If the input value is a power of two, the input value is returned.
/// Otherwise the next power of two, after the input value, is returned.
/// </returns>
public static int PowerOfTwoGreaterThanOrEqualTo(this int input)
{
return Mathf.IsPowerOfTwo(v) ? v : Mathf.NextPowerOfTwo(v);
return Mathf.IsPowerOfTwo(input) ? input : Mathf.NextPowerOfTwo(input);
}

public static Vector3Int PowerOfTwoGreaterThanOrEqualTo(this Vector3Int v)
/// <summary>
/// For each component in a `Vector3Int`, get the component value that is the next power of two at or
/// after the input component value.
/// </summary>
/// <param name="inputVector">The vector containing the component values to test.</param>
/// <returns>
/// A Vector3Int containing components that are a power of two. If an input's component value is a power of two,
/// than that component value is in the returned in the corresponding vector position. Otherwise the next
/// power of two, after the component value, is returned in the corresponding vector position.
/// </returns>
public static Vector3Int PowerOfTwoGreaterThanOrEqualTo(this Vector3Int inputVector)
{
return new Vector3Int(PowerOfTwoGreaterThanOrEqualTo(v.x),
PowerOfTwoGreaterThanOrEqualTo(v.y),
PowerOfTwoGreaterThanOrEqualTo(v.z));
return new Vector3Int(PowerOfTwoGreaterThanOrEqualTo(inputVector.x),
PowerOfTwoGreaterThanOrEqualTo(inputVector.y),
PowerOfTwoGreaterThanOrEqualTo(inputVector.z));
}

public static int CubicToLinearIndex(Vector3Int ndx, Vector3Int size)
/// <summary>
/// Convert a 3D texture's cubic index to its linear representation.
/// </summary>
/// <param name="cubicIndex">A cubic index into a 3D texture.</param>
/// <param name="size">The 3D texture's dimensions or size.</param>
/// <returns>
/// The linear index for the given cubic index and size.
/// </returns>
public static int CubicToLinearIndex(Vector3Int cubicIndex, Vector3Int size)
{
return (ndx.x) +
(ndx.y * size.x) +
(ndx.z * size.x * size.y);
return (cubicIndex.x) +
(cubicIndex.y * size.x) +
(cubicIndex.z * size.x * size.y);
}

/// <summary>
/// Convert a 3D texture's linear index to its cubic representation.
/// </summary>
/// <param name="linearIndex">A linear index into a 3D texture.</param>
/// <param name="size">The 3D texture's dimensions or size.</param>
/// <returns>
/// The cubic index for the given linear index and size.
/// </returns>
public static Vector3Int LinearToCubicIndex(int linearIndex, Vector3Int size)
{
return new Vector3Int((linearIndex / 1) % size.x,
(linearIndex / size.x) % size.y,
(linearIndex / (size.x * size.y)) % size.z);
}

/// <summary>
/// Preform a component wise clamp on a given vector. Each input component will be clamped by its
/// corresponding minimum and maximum component as specified by the `min` and `max` input vectors.
/// </summary>
/// <param name="value">The vector whose components will be clamped by the given minimum and maximum vectors.</param>
/// <param name="min">The vector whose components define the minimum value for the corresponding input vector component.</param>
/// <param name="max">The vector whose components define the maximum value for the corresponding input vector component.</param>
/// <returns>
/// Returns a new vector whose components have been clamped by the specified minimum and maximum values.
/// </returns>
public static Vector3 ClampComponentWise(Vector3 value, Vector3 min, Vector3 max)
{
return new Vector3(Mathf.Clamp(value.x, min.x, max.x),
Expand Down
Loading

0 comments on commit 875c1ad

Please sign in to comment.