Skip to content

Commit d428370

Browse files
committed
addressed documentation feedback, added null check to prefabs
1 parent 4b89176 commit d428370

File tree

7 files changed

+69
-39
lines changed

7 files changed

+69
-39
lines changed

Assets/MixedRealityToolkit.Extensions/HandPhysicsService/Examples/PhysicsTriggerEventReadout.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace Microsoft.MixedReality.Toolkit.Extensions.HandPhysics.Examples
1010
{
1111
/// <summary>
12-
/// Writes Collider Trigger from Articulated hands events to a TextMeshPro object
12+
/// Writes collider trigger from articulated hands events to a TextMeshPro object
1313
/// </summary>
1414
public class PhysicsTriggerEventReadout : MonoBehaviour
1515
{
@@ -74,7 +74,7 @@ private void WriteText(bool clear = false)
7474
{
7575
text.Append(joint.name + " is touching. <br>");
7676
}
77-
textField.text = text + "<br>";
77+
textField.text = text + "<br>";
7878
}
7979
}
8080
}

Assets/MixedRealityToolkit.Extensions/HandPhysicsService/HandPhysicsService.cs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public GameObject FingerTipKinematicBodyPrefab
4949
{
5050
CreateKinematicBodies();
5151
}
52+
else
53+
{
54+
DestroyKinematicBodies();
55+
}
5256
fingerTipKinematicBodyPrefab = value;
5357
}
5458
}
@@ -65,6 +69,10 @@ public GameObject PalmKinematicBodyPrefab
6569
{
6670
CreateKinematicBodies();
6771
}
72+
else
73+
{
74+
DestroyKinematicBodies();
75+
}
6876

6977
palmKinematicBodyPrefab = value;
7078
}
@@ -146,14 +154,7 @@ public override void Update()
146154
/// </summary>
147155
private void CreateKinematicBodies()
148156
{
149-
if(jointKinematicBodies.Count > 0)
150-
{
151-
//Tear down the old kinematicBodies
152-
foreach (JointKinematicBody jointKinematicBody in jointKinematicBodies)
153-
{
154-
UnityEngine.Object.Destroy(jointKinematicBody.gameObject);
155-
}
156-
}
157+
DestroyKinematicBodies();
157158

158159
// Create joint kinematic bodies.
159160
for (int i = 0; i < handednessTypes.Length; ++i)
@@ -178,16 +179,31 @@ private void CreateKinematicBodies()
178179
}
179180
}
180181

182+
/// <summary>
183+
/// Destroys the existing joints
184+
/// </summary>
185+
private void DestroyKinematicBodies()
186+
{
187+
if(jointKinematicBodies.Count > 0)
188+
{
189+
//Tear down the old kinematicBodies
190+
foreach (JointKinematicBody jointKinematicBody in jointKinematicBodies)
191+
{
192+
UnityEngine.Object.Destroy(jointKinematicBody.gameObject);
193+
}
194+
}
195+
}
196+
181197
/// <summary>
182198
/// Instantiates <see cref="FingerTipKinematicBodyPrefab"/>s for all <see cref="fingerTipTypes"/>.
183199
/// </summary>
184200
/// <remarks>
185201
/// Optionally instantiates <see cref="PalmKinematicBodyPrefab"/>.
186202
/// </remarks>
187-
/// <param name="rigidBodyPrefab">The prefab to intantiate.</param>
203+
/// <param name="rigidBodyPrefab">The prefab to instantiate.</param>
188204
/// <param name="layer">the layer to put the prefab on.</param>
189205
/// <param name="handednessType">the specified <see cref="Handedness"/> for the joint.</param>
190-
/// <param name="jointType">the specified <see cref="TrackedHandJoint"/> to intantiate against.</param>
206+
/// <param name="jointType">the specified <see cref="TrackedHandJoint"/> to instantiate against.</param>
191207
/// <param name="parent">The root <see href="https://docs.unity3d.com/ScriptReference/GameObject.html"> for the joints.</param>
192208
/// <param name="jointKinematicBody">When successful, the generated <see cref="JointKinematicBody"/>.</param>
193209
/// <returns>True when able to successfully intantiate and create a <see cref="JointKinematicBody"/>.</returns>

Assets/MixedRealityToolkit.Extensions/HandPhysicsService/HandPhysicsServiceProfile.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,46 @@
66
namespace Microsoft.MixedReality.Toolkit.Extensions.HandPhysics
77
{
88
/// <summary>
9-
/// Configuration profile for <see cref="HandPhysicsService"/> Extension service.
9+
/// Configuration profile for <see cref="HandPhysicsService"/> extension service.
1010
/// </summary>
1111
[MixedRealityServiceProfile(typeof(IHandPhysicsService))]
1212
[CreateAssetMenu(fileName = "HandPhysicsServiceProfile", menuName = "MixedRealityToolkit/Hand Physics Service Configuration Profile")]
1313
public class HandPhysicsServiceProfile : BaseMixedRealityProfile
1414
{
15+
/// <summary>
16+
/// Whether make the Palm a physics joint
17+
/// </summary>
1518
public bool UsePalmKinematicBody => usePalmKinematicBody;
19+
20+
/// <summary>
21+
/// The prefab to represent each physics joint
22+
/// </summary>
1623
public GameObject FingerTipKinematicBodyPrefab => fingerTipKinematicBodyPrefab;
24+
25+
/// <summary>
26+
/// The prefab to represent the palm physics joint
27+
/// </summary>
1728
public GameObject PalmKinematicBodyPrefab => palmKinematicBodyPrefab;
1829

30+
/// <summary>
31+
/// The Layer the physics joints will be on
32+
/// </summary>
1933
public int HandPhysicsLayer => handPhysicsLayer;
2034

2135
[SerializeField]
22-
[Tooltip("The Layer the PhysicsJoints will be on")]
36+
[Tooltip("The Layer the physics joints will be on")]
2337
private int handPhysicsLayer = 0;
2438

2539
[SerializeField]
26-
[Tooltip("The prefab to represent each PhysicsJoint")]
40+
[Tooltip("The prefab to represent each physics joint")]
2741
private GameObject fingerTipKinematicBodyPrefab = null;
2842

2943
[SerializeField]
30-
[Tooltip("Whether make the Palm a PhysicsJoint")]
44+
[Tooltip("Whether make the Palm a physics joint")]
3145
private bool usePalmKinematicBody = false;
3246

3347
[SerializeField]
34-
[Tooltip("The prefab to represent the Palm PhysicsJoint")]
48+
[Tooltip("The prefab to represent the palm physics joint")]
3549
private GameObject palmKinematicBodyPrefab = null;
3650
}
3751
}

Assets/MixedRealityToolkit.Extensions/HandPhysicsService/Interfaces/IHandPhysicsService.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@
66
namespace Microsoft.MixedReality.Toolkit.Extensions.HandPhysics
77
{
88
/// <summary>
9-
/// Generic interface for applying rigidbodies to handJoints
9+
/// Generic interface for applying rigidbodies to hand joints
1010
/// </summary>
1111
public interface IHandPhysicsService : IMixedRealityExtensionService
1212
{
1313
/// <summary>
14-
/// The Parent GameObject that contains all the PhysicsJoints
14+
/// The parent GameObject that contains all the physics joints
1515
/// </summary>
1616
GameObject HandPhysicsServiceRoot { get; }
1717

1818
/// <summary>
19-
/// The LayerMask the PhysicsJoints will be on
19+
/// The LayerMask the physics joints will be on
2020
/// </summary>
2121
int HandPhysicsLayer { get; set; }
2222

2323
/// <summary>
24-
/// Whether to make the Palm a PhysicsJoint
24+
/// Whether to make the palm a physics joint
2525
/// </summary>
2626
bool UsePalmKinematicBody { get; set; }
2727

2828
/// <summary>
29-
/// The prefab to represent each PhysicsJoint
29+
/// The prefab to represent each physics joints
3030
/// </summary>
3131
GameObject FingerTipKinematicBodyPrefab { get; set; }
3232

3333
/// <summary>
34-
/// The prefab to represent the Palm PhysicsJoint
34+
/// The prefab to represent the Palm physics joints
3535
/// </summary>
3636
GameObject PalmKinematicBodyPrefab { get; set; }
3737
}

Assets/MixedRealityToolkit.Extensions/HandPhysicsService/JointKinematicBody.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Microsoft.MixedReality.Toolkit.Extensions.HandPhysics
99
{
1010
/// <summary>
11-
/// Updates a Rigidbody Transform against another Transform.
11+
/// Updates a rigidbody transform against another transform.
1212
/// </summary>
1313
public class JointKinematicBody : MonoBehaviour
1414
{
@@ -18,7 +18,7 @@ public class JointKinematicBody : MonoBehaviour
1818
public Transform Joint { get; set; }
1919

2020
/// <summary>
21-
/// What hand this component lives one.
21+
/// What hand this component lives on.
2222
/// </summary>
2323
public Handedness HandednessType { get; set; }
2424

Assets/MixedRealityToolkit.Extensions/HandPhysicsService/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Hand Physics Extension Service
1+
# Hand physics extension service
22

3-
The Hand Physics service enables rigid body collision events and interactions with articulated hands.
3+
The hand physics service enables rigid body collision events and interactions with articulated hands.
44

5-
## Getting started with Hand Physics Extension Service
6-
Add the Hand Physics service to the list of extension services and use the default profile.
5+
## Getting started with hand physics extension service
6+
Add the hand physics service to the list of extension services and use the default profile.
77

88
Once enabled, use any collider's IsTrigger property to receive collision events from all 10 digits (and palms if they're enabled).
99

Documentation/Extensions/HandPhysicsService/HandPhysicsServiceOverview.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# Hand Physics Extension Service
2-
The Hand Physics service enables rigid body collision events and interactions with articulated hands.
1+
# Hand physics extension service
2+
The hand physics service enables rigid body collision events and interactions with articulated hands.
33

44
## Enabling the extension
5-
To enable the extension, open your RegisteredServiceProvider profile. Click Register a new Service Provider to add a new configuration. In the Component Type field, select HandPhysicsService. In the Configuration Profile field, select the default hand physics profile included with the extension.
5+
To enable the extension, open your RegisteredServiceProvider profile. Click `Register a new Service Provider` to add a new configuration. In the component type field, select HandPhysicsService. In the configuration Profile field, select the default hand physics profile included with the extension.
66

7-
## Profile Options
8-
### Hand Physics Layer
7+
## Profile options
8+
### Hand physics layer
99
Controls the layer the instantiated hand joints will go to.
1010

11-
While the service defaults to the "default" layer (0), it is recommended to use a separate layer for Hand Physics objects. Otherwise there may be unwanted collisions and/or inaccurate raycasts.
11+
While the service defaults to the "default" layer (0), it is recommended to use a separate layer for hand physics objects. Otherwise there may be unwanted collisions and/or inaccurate raycasts.
1212

13-
### Finger Tip Kinematic Body Prefab
13+
### Finger tip kinematic body prefab
1414
Controls which prefab is instantiated on fingertips. In order for the service to work as expected, the prefab requires:
1515
- A rigidbody component, with isKinematic enabled
1616
- A collider
1717
- `JointKinematicBody` component
1818

19-
### Use Palm Kinematic Body
19+
### Use palm kinematic body
2020
Controls whether the service will attempt to instantiate a prefab on the palm joint.
2121

22-
### Palm Kinematic Body Prefab
23-
When UsePalmKinematicBody is enabled, this is the prefab it will instantiate. Just like `FingerTipKinematicBodyPrefab`, this prefab requires:
22+
### Palm kinematic body prefab
23+
When `UsePalmKinematicBody` is enabled, this is the prefab it will instantiate. Just like `FingerTipKinematicBodyPrefab`, this prefab requires:
2424
- A rigidbody component, with isKinematic enabled
2525
- A collider
2626
- `JointKinematicBody` component

0 commit comments

Comments
 (0)