Skip to content

Commit 08bfe95

Browse files
committed
Merge pull request #10316 from keveleigh/formatting
Assorted formatting and minor changes accumulated in my working dir
1 parent fb7c736 commit 08bfe95

File tree

10 files changed

+63
-73
lines changed

10 files changed

+63
-73
lines changed

Assets/MRTK/Core/Providers/Hands/HandRay/HandRay.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public bool ShouldShowRay
5555
private const float DynamicPivotBaseY = -0.1f, DynamicPivotMultiplierY = 0.65f, DynamicPivotMinY = -0.6f, DynamicPivotMaxY = -0.2f;
5656
private const float DynamicPivotBaseX = 0.03f, DynamicPivotMultiplierX = 0.65f, DynamicPivotMinX = 0.08f, DynamicPivotMaxX = 0.15f;
5757
private const float HeadToPivotOffsetZ = 0.08f;
58-
private readonly float CursorBeamBackwardTolerance = 0.5f;
59-
private readonly float CursorBeamUpTolerance = 0.8f;
58+
private const float CursorBeamBackwardTolerance = 0.5f;
59+
private const float CursorBeamUpTolerance = 0.8f;
6060

6161
// Smoothing factor for ray stabilization.
6262
private const float StabilizedRayHalfLife = 0.01f;

Assets/MRTK/Core/Providers/InputSimulation/SimulatedArticulatedHandPoses.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ public static class SimulatedArticulatedHandPoses
1515
{
1616
private static readonly Dictionary<GestureId, string> GesturePoseJSONMapping = new Dictionary<GestureId, string>()
1717
{
18-
{ GestureId.Flat, ArticulatedHandPose_Flat},
19-
{ GestureId.Grab, ArticulatedHandPose_Grab},
20-
{ GestureId.Open, ArticulatedHandPose_Open},
21-
{ GestureId.OpenSteadyGrabPoint, ArticulatedHandPose_OpenSteadyGrabPoint},
22-
{ GestureId.Pinch, ArticulatedHandPose_Pinch},
23-
{ GestureId.PinchSteadyWrist, ArticulatedHandPose_PinchSteadyWrist},
18+
{ GestureId.Flat, ArticulatedHandPose_Flat },
19+
{ GestureId.Grab, ArticulatedHandPose_Grab },
20+
{ GestureId.Open, ArticulatedHandPose_Open },
21+
{ GestureId.OpenSteadyGrabPoint, ArticulatedHandPose_OpenSteadyGrabPoint },
22+
{ GestureId.Pinch, ArticulatedHandPose_Pinch },
23+
{ GestureId.PinchSteadyWrist, ArticulatedHandPose_PinchSteadyWrist },
2424
{ GestureId.Poke, ArticulatedHandPose_Poke },
25-
{ GestureId.ThumbsUp, ArticulatedHandPose_ThumbsUp},
26-
{ GestureId.Victory, ArticulatedHandPose_Victory},
27-
{ GestureId.TeleportStart, ArticulatedHandPose_TeleportStart},
28-
{ GestureId.TeleportEnd, ArticulatedHandPose_TeleportEnd}
25+
{ GestureId.ThumbsUp, ArticulatedHandPose_ThumbsUp },
26+
{ GestureId.Victory, ArticulatedHandPose_Victory },
27+
{ GestureId.TeleportStart, ArticulatedHandPose_TeleportStart },
28+
{ GestureId.TeleportEnd, ArticulatedHandPose_TeleportEnd }
2929
};
3030

3131
private static Dictionary<GestureId, ArticulatedHandPose> gesturePoses;

Assets/MRTK/Core/Utilities/CameraFOVChecker.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ namespace Microsoft.MixedReality.Toolkit
1313
/// </summary>
1414
public static class CameraFOVChecker
1515
{
16-
1716
// Help to clear caches when new frame runs
18-
static private int inFOVLastCalculatedFrame = -1;
17+
private static int inFOVLastCalculatedFrame = -1;
1918
// Map from grabbable => is the grabbable in FOV for this frame. Cleared every frame
2019
private static Dictionary<Tuple<Collider, Camera>, bool> inFOVColliderCache = new Dictionary<Tuple<Collider, Camera>, bool>();
2120
// List of corners shared across all sphere pointer query instances --
@@ -39,7 +38,7 @@ public static bool IsInFOVCached(this Camera cam, Collider myCollider)
3938
}
4039

4140
Tuple<Collider, Camera> cameraColliderPair = new Tuple<Collider, Camera>(myCollider, cam);
42-
bool result = false;
41+
bool result;
4342
if (inFOVLastCalculatedFrame != Time.frameCount)
4443
{
4544
inFOVColliderCache.Clear();
@@ -53,7 +52,6 @@ public static bool IsInFOVCached(this Camera cam, Collider myCollider)
5352
inFOVBoundsCornerPoints.Clear();
5453
BoundsExtensions.GetColliderBoundsPoints(myCollider, inFOVBoundsCornerPoints, 0);
5554

56-
5755
float xMin = float.MaxValue, yMin = float.MaxValue, zMin = float.MaxValue;
5856
float xMax = float.MinValue, yMax = float.MinValue, zMax = float.MinValue;
5957
for (int i = 0; i < inFOVBoundsCornerPoints.Count; i++)

Assets/MRTK/Core/Utilities/Editor/Preferences/SerializableDictionary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, IS
2222
[SerializeField]
2323
private List<TValue> values = new List<TValue>();
2424

25-
public void OnBeforeSerialize()
25+
void ISerializationCallbackReceiver.OnBeforeSerialize()
2626
{
2727
keys.Clear();
2828
values.Clear();
@@ -34,7 +34,7 @@ public void OnBeforeSerialize()
3434
}
3535
}
3636

37-
public void OnAfterDeserialize()
37+
void ISerializationCallbackReceiver.OnAfterDeserialize()
3838
{
3939
this.Clear();
4040

Assets/MRTK/Providers/WindowsMixedReality/Shared/WindowsMixedRealityHandMeshProvider.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System;
77

88
#if WINDOWS_UWP
9-
using System.Threading.Tasks;
109
using Unity.Profiling;
1110
using UnityEngine;
1211
using Windows.Perception.People;

Assets/MRTK/SDK/Features/UX/Scripts/Cursors/FingerCursor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,10 @@ private void TranslateFromTipToPad(Transform target, Vector3 fingerPosition, Vec
227227

228228
// Lerping an angular measurement from 0 degrees (default cursor position at tip of finger) to
229229
// 90 degrees (a new position on the fingertip pad) around the fingertip's X axis.
230-
Quaternion degreesRelative = Quaternion.AngleAxis((1f - t) * 90f * (1f - fingerSurfaceDot), indexFingerRingRenderer.transform.right);
230+
Quaternion degreesRelative = Quaternion.AngleAxis((1f - t) * 90f * (1f - fingerSurfaceDot), target.right);
231231

232232
Vector3 tipToPadPosition = fingerPosition + degreesRelative * tipOffset;
233-
indexFingerRingRenderer.transform.position = tipToPadPosition;
233+
target.position = tipToPadPosition;
234234
}
235235
}
236236
}

Assets/MRTK/Services/InputSystem/FocusProvider.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,7 @@ public bool TryGetFocusDetails(IMixedRealityPointer pointer, out FocusDetails fo
649649
{
650650
using (TryGetFocusDetailsPerfMarker.Auto())
651651
{
652-
PointerData pointerData;
653-
if (TryGetPointerData(pointer, out pointerData))
652+
if (TryGetPointerData(pointer, out PointerData pointerData))
654653
{
655654
focusDetails = pointerData.Details;
656655
return true;
@@ -766,8 +765,7 @@ private void CleanUpUiRaycastCamera()
766765
public bool IsPointerRegistered(IMixedRealityPointer pointer)
767766
{
768767
Debug.Assert(pointer.PointerId != 0, $"{pointer} does not have a valid pointer id!");
769-
PointerData pointerData;
770-
return TryGetPointerData(pointer, out pointerData);
768+
return TryGetPointerData(pointer, out _);
771769
}
772770

773771
private static readonly ProfilerMarker RegisterPointerPerfMarker = new ProfilerMarker("[MRTK] FocusProvider.RegisterPointer");
@@ -861,8 +859,7 @@ public bool UnregisterPointer(IMixedRealityPointer pointer)
861859
{
862860
Debug.Assert(pointer.PointerId != 0, $"{pointer} does not have a valid pointer id!");
863861

864-
PointerData pointerData;
865-
if (!TryGetPointerData(pointer, out pointerData)) { return false; }
862+
if (!TryGetPointerData(pointer, out PointerData pointerData)) { return false; }
866863

867864
// Raise focus events if needed.
868865
if (pointerData.CurrentPointerTarget != null)

Assets/MRTK/StandardAssets/Shaders/MixedRealityStandard.shader

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ Shader "Mixed Reality Toolkit/Standard"
277277
UNITY_VERTEX_INPUT_INSTANCE_ID
278278
};
279279

280-
struct v2f
280+
struct v2f
281281
{
282282
float4 position : SV_POSITION;
283283
#if defined(_BORDER_LIGHT)
@@ -454,7 +454,7 @@ Shader "Mixed Reality Toolkit/Standard"
454454

455455
#if defined(_ROUND_CORNERS)
456456
#if defined(_INDEPENDENT_CORNERS)
457-
float4 _RoundCornersRadius;
457+
float4 _RoundCornersRadius;
458458
#else
459459
fixed _RoundCornerRadius;
460460
#endif
@@ -666,7 +666,7 @@ Shader "Mixed Reality Toolkit/Standard"
666666

667667
#if defined(_BORDER_LIGHT) || defined(_ROUND_CORNERS)
668668
o.uv.xy = TRANSFORM_TEX(v.uv, _MainTex);
669-
669+
670670
float minScale = min(min(o.scale.x, o.scale.y), o.scale.z);
671671

672672
#if defined(_BORDER_LIGHT)
@@ -796,8 +796,8 @@ Shader "Mixed Reality Toolkit/Standard"
796796
fixed4 albedo = fixed4(1.0, 1.0, 1.0, 1.0);
797797
#else
798798
#if defined(_TRIPLANAR_MAPPING)
799-
fixed4 albedo = tex2D(_MainTex, uvX) * triplanarBlend.x +
800-
tex2D(_MainTex, uvY) * triplanarBlend.y +
799+
fixed4 albedo = tex2D(_MainTex, uvX) * triplanarBlend.x +
800+
tex2D(_MainTex, uvY) * triplanarBlend.y +
801801
tex2D(_MainTex, uvZ) * triplanarBlend.z;
802802
#else
803803
#if defined(_USE_SSAA)
@@ -1011,13 +1011,13 @@ Shader "Mixed Reality Toolkit/Standard"
10111011
#if defined(_BORDER_LIGHT)
10121012
fixed borderValue;
10131013
#if defined(_ROUND_CORNERS)
1014-
fixed borderMargin = _RoundCornerMargin + _BorderWidth * 0.5;
1014+
fixed borderMargin = _RoundCornerMargin + _BorderWidth * 0.5;
10151015

10161016
cornerCircleRadius = saturate(max(currentCornerRadius - borderMargin, 0.01)) * i.scale.z;
10171017

10181018
cornerCircleDistance = halfScale - (borderMargin * i.scale.z) - cornerCircleRadius;
10191019

1020-
borderValue = 1.0 - RoundCornersSmooth(roundCornerPosition, cornerCircleDistance, cornerCircleRadius);
1020+
borderValue = 1.0 - RoundCornersSmooth(roundCornerPosition, cornerCircleDistance, cornerCircleRadius);
10211021
#else
10221022
borderValue = max(smoothstep(i.uv.z - _EdgeSmoothingValue, i.uv.z + _EdgeSmoothingValue, distanceToEdge.x),
10231023
smoothstep(i.uv.w - _EdgeSmoothingValue, i.uv.w + _EdgeSmoothingValue, distanceToEdge.y));
@@ -1150,7 +1150,7 @@ Shader "Mixed Reality Toolkit/Standard"
11501150
// Environment coloring.
11511151
#if defined(_ENVIRONMENT_COLORING)
11521152
fixed3 environmentColor = incident.x * incident.x * _EnvironmentColorX +
1153-
incident.y * incident.y * _EnvironmentColorY +
1153+
incident.y * incident.y * _EnvironmentColorY +
11541154
incident.z * incident.z * _EnvironmentColorZ;
11551155
output.rgb += environmentColor * max(0.0, dot(incident, worldNormal) + _EnvironmentColorThreshold) * _EnvironmentColorIntensity;
11561156

@@ -1253,7 +1253,7 @@ Shader "Mixed Reality Toolkit/Standard"
12531253
ENDCG
12541254
}
12551255
}
1256-
1256+
12571257
Fallback "Hidden/InternalErrorShader"
12581258
CustomEditor "Microsoft.MixedReality.Toolkit.Editor.MixedRealityStandardShaderGUI"
12591259
}

Assets/MRTK/Tests/TestUtilities/TestUtilities.cs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Reflection;
74
using UnityEngine;
8-
using UnityEngine.SceneManagement;
95

106
#if UNITY_EDITOR
117
using Microsoft.MixedReality.Toolkit.Utilities.Editor;
128
using Microsoft.MixedReality.Toolkit.Editor;
9+
using System.Collections.Generic;
10+
using System.Linq;
11+
using System.Reflection;
1312
using UnityEditor;
1413
using UnityEditor.SceneManagement;
15-
#endif
16-
17-
#if WINDOWS_UWP
18-
using UnityEngine.Assertions;
14+
using UnityEngine.SceneManagement;
1915
#endif
2016

2117
namespace Microsoft.MixedReality.Toolkit.Tests
2218
{
2319
public static class TestUtilities
2420
{
25-
const string primaryTestSceneTemporarySavePath = "Assets/__temp_primary_test_scene.unity";
26-
const string additiveTestSceneTemporarySavePath = "Assets/__temp_additive_test_scene_#.unity";
21+
#if UNITY_EDITOR
22+
private const string PrimaryTestSceneTemporarySavePath = "Assets/__temp_primary_test_scene.unity";
23+
private const string AdditiveTestSceneTemporarySavePath = "Assets/__temp_additive_test_scene_#.unity";
24+
2725
public static Scene primaryTestScene;
2826
public static Scene[] additiveTestScenes = System.Array.Empty<Scene>();
27+
#endif // UNITY_EDITOR
2928

3029
/// <summary>
3130
/// Destroys all scene assets that were created over the course of testing.
@@ -37,15 +36,15 @@ public static void EditorTearDownScenes()
3736
if (!EditorApplication.isPlaying)
3837
{
3938
// If any of our scenes were saved, tear down the assets
40-
SceneAsset primaryTestSceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(primaryTestSceneTemporarySavePath);
39+
SceneAsset primaryTestSceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(PrimaryTestSceneTemporarySavePath);
4140
if (primaryTestSceneAsset != null)
4241
{
43-
AssetDatabase.DeleteAsset(primaryTestSceneTemporarySavePath);
42+
AssetDatabase.DeleteAsset(PrimaryTestSceneTemporarySavePath);
4443
}
4544

4645
for (int i = 0; i < additiveTestScenes.Length; i++)
4746
{
48-
string path = additiveTestSceneTemporarySavePath.Replace("#", i.ToString());
47+
string path = AdditiveTestSceneTemporarySavePath.Replace("#", i.ToString());
4948
SceneAsset additiveTestSceneAsset = AssetDatabase.LoadAssetAtPath<SceneAsset>(path);
5049
if (additiveTestSceneAsset != null)
5150
{
@@ -54,7 +53,7 @@ public static void EditorTearDownScenes()
5453
}
5554
AssetDatabase.Refresh();
5655
}
57-
#endif
56+
#endif // UNITY_EDITOR
5857
}
5958

6059
/// <summary>
@@ -72,20 +71,17 @@ public static void EditorCreateScenes(int numScenesToCreate = 1)
7271

7372
List<Scene> additiveTestScenesList = new List<Scene>();
7473

75-
if (numScenesToCreate == 1)
76-
{ // No need to save this scene, we're just creating one
77-
primaryTestScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
78-
}
79-
else
74+
// Make the first scene single so it blows away previously loaded scenes
75+
primaryTestScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
76+
77+
if (numScenesToCreate != 1)
8078
{
81-
// Make the first scene single so it blows away previously loaded scenes
82-
primaryTestScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
8379
// Save the scene (temporarily) so we can load additively on top of it
84-
EditorSceneManager.SaveScene(primaryTestScene, primaryTestSceneTemporarySavePath);
80+
EditorSceneManager.SaveScene(primaryTestScene, PrimaryTestSceneTemporarySavePath);
8581

8682
for (int i = 1; i < numScenesToCreate; i++)
8783
{
88-
string path = additiveTestSceneTemporarySavePath.Replace("#", additiveTestScenesList.Count.ToString());
84+
string path = AdditiveTestSceneTemporarySavePath.Replace("#", additiveTestScenesList.Count.ToString());
8985
// Create subsequent scenes additively
9086
Scene additiveScene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Additive);
9187
additiveTestScenesList.Add(additiveScene);
@@ -95,7 +91,7 @@ public static void EditorCreateScenes(int numScenesToCreate = 1)
9591
}
9692

9793
additiveTestScenes = additiveTestScenesList.ToArray();
98-
#endif
94+
#endif // UNITY_EDITOR
9995
}
10096

10197
/// <summary>
@@ -340,25 +336,25 @@ public static T GetDefaultMixedRealityProfile<T>() where T : BaseMixedRealityPro
340336
public static void AssertAboutEqual(Vector3 actual, Vector3 expected, string message, float tolerance = 0.01f)
341337
{
342338
var dist = (actual - expected).magnitude;
343-
Debug.Assert(dist < tolerance, $"{message}, expected {expected.ToString("0.000")}, was {actual.ToString("0.000")}");
339+
Debug.Assert(dist < tolerance, $"{message}, expected {expected:0.000}, was {actual:0.000}");
344340
}
345341

346342
public static void AssertAboutEqual(Quaternion actual, Quaternion expected, string message, float tolerance = 0.01f)
347343
{
348344
var angle = Quaternion.Angle(actual, expected);
349-
Debug.Assert(angle < tolerance, $"{message}, expected {expected.ToString("0.000")}, was {actual.ToString("0.000")}");
345+
Debug.Assert(angle < tolerance, $"{message}, expected {expected:0.000}, was {actual:0.000}");
350346
}
351347

352348
public static void AssertNotAboutEqual(Vector3 val1, Vector3 val2, string message, float tolerance = 0.01f)
353349
{
354350
var dist = (val1 - val2).magnitude;
355-
Debug.Assert(dist >= tolerance, $"{message}, val1 {val1.ToString("0.000")} almost equals val2 {val2.ToString("0.000")}");
351+
Debug.Assert(dist >= tolerance, $"{message}, val1 {val1:0.000} almost equals val2 {val2:0.000}");
356352
}
357353

358354
public static void AssertNotAboutEqual(Quaternion val1, Quaternion val2, string message, float tolerance = 0.01f)
359355
{
360356
var angle = Quaternion.Angle(val1, val2);
361-
Debug.Assert(angle >= tolerance, $"{message}, val1 {val1.ToString("0.000")} almost equals val2 {val2.ToString("0.000")}");
357+
Debug.Assert(angle >= tolerance, $"{message}, val1 {val1:0.000} almost equals val2 {val2:0.000}");
362358
}
363359

364360
/// <summary>
@@ -443,21 +439,21 @@ private static void UpdateTestScriptIcons()
443439

444440
MonoScript script = AssetDatabase.LoadAssetAtPath<MonoScript>(scriptPath);
445441

446-
Texture2D currentIcon = getIconForObject?.Invoke(null, new object[] { script }) as Texture2D;
442+
Texture2D currentIcon = GetIconForObject?.Invoke(null, new object[] { script }) as Texture2D;
447443
if (currentIcon == null || !currentIcon.Equals(icon))
448444
{
449-
setIconForObject?.Invoke(null, new object[] { script, icon });
450-
copyMonoScriptIconToImporters?.Invoke(null, new object[] { script });
445+
SetIconForObject?.Invoke(null, new object[] { script, icon });
446+
CopyMonoScriptIconToImporters?.Invoke(null, new object[] { script });
451447
}
452448
}
453449
}
454450

455451
EditorUtility.ClearProgressBar();
456452
}
457453

458-
private static readonly MethodInfo getIconForObject = typeof(EditorGUIUtility).GetMethod("GetIconForObject", BindingFlags.Static | BindingFlags.NonPublic);
459-
private static readonly MethodInfo setIconForObject = typeof(EditorGUIUtility).GetMethod("SetIconForObject", BindingFlags.Static | BindingFlags.NonPublic);
460-
private static readonly MethodInfo copyMonoScriptIconToImporters = typeof(MonoImporter).GetMethod("CopyMonoScriptIconToImporters", BindingFlags.Static | BindingFlags.NonPublic);
454+
private static readonly MethodInfo GetIconForObject = typeof(EditorGUIUtility).GetMethod("GetIconForObject", BindingFlags.Static | BindingFlags.NonPublic);
455+
private static readonly MethodInfo SetIconForObject = typeof(EditorGUIUtility).GetMethod("SetIconForObject", BindingFlags.Static | BindingFlags.NonPublic);
456+
private static readonly MethodInfo CopyMonoScriptIconToImporters = typeof(MonoImporter).GetMethod("CopyMonoScriptIconToImporters", BindingFlags.Static | BindingFlags.NonPublic);
461457
#endif
462458
}
463459
}

Assets/MRTK/Tools/OptimizeWindow/MixedRealityOptimizeWindow.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ private long TotalPolyCount
4545

4646
private string TotalPolyCountStr
4747
{
48-
get => $"Total Scene PolyCount: {TotalPolyCount.ToString("N0")} ";
48+
get => $"Total Scene PolyCount: {TotalPolyCount:N0} ";
4949
}
5050

5151
private string TotalActivePolyCountStr
5252
{
53-
get => $"Total PolyCount (Active): {totalActivePolyCount.ToString("N0")} ";
53+
get => $"Total PolyCount (Active): {totalActivePolyCount:N0} ";
5454
}
5555

5656
private string TotalInactivePolyCountStr
5757
{
58-
get => $"Total PolyCount (Inactive): {totalInActivePolyCount.ToString("N0")} ";
58+
get => $"Total PolyCount (Inactive): {totalInActivePolyCount:N0} ";
5959
}
6060

6161
private MeshFilter[] MeshesOrderedByPolyCountDesc;

0 commit comments

Comments
 (0)