Skip to content

Commit 854ddfd

Browse files
committed
Improve if statement
1 parent 333180b commit 854ddfd

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

Assets/MRTK/SDK/Features/UX/Scripts/PulseShader/PulseShaderHandMeshHandler.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,20 +188,14 @@ public void PulseFingerTips()
188188
// Check if the palm is facing the camera
189189
private bool IsAPalmFacingCamera()
190190
{
191-
foreach (IMixedRealityController c in CoreServices.InputSystem.DetectedControllers)
191+
foreach (IMixedRealityController controller in CoreServices.InputSystem.DetectedControllers)
192192
{
193-
if (c.ControllerHandedness.IsMatch(Handedness.Both))
193+
if (controller.ControllerHandedness.IsMatch(Handedness.Both)
194+
&& controller is IMixedRealityHand jointedHand
195+
&& jointedHand.TryGetJoint(TrackedHandJoint.Palm, out MixedRealityPose palmPose)
196+
&& Vector3.Dot(palmPose.Up, CameraCache.Main.transform.forward) > 0.0f)
194197
{
195-
MixedRealityPose palmPose;
196-
var jointedHand = c as IMixedRealityHand;
197-
198-
if ((jointedHand != null) && jointedHand.TryGetJoint(TrackedHandJoint.Palm, out palmPose))
199-
{
200-
if (Vector3.Dot(palmPose.Up, CameraCache.Main.transform.forward) > 0.0f)
201-
{
202-
return true;
203-
}
204-
}
198+
return true;
205199
}
206200
}
207201

0 commit comments

Comments
 (0)