Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
Release 0.1.19 (#132)
Browse files Browse the repository at this point in the history
* cleaned up the diagnostics prefab a bit to make sure it looks nice (#124)

* cleaned up the diagnostics prefab a bit to make sure it looks nice

* updated button references and colors

* Fix default data providers profile due to name change (#125)

* Fix default data providers profile due to name change

* Increase patch version due to breaking change.

* input system global listener sometimes doesn't unregister a global listener if the object is destroyed outright and disable isn't called first (#126)

* Fix DestroyImmediate being called in editor playmode causing Unity events to not fire (#127)

* Make input system global listener non abstract so it can be attached to game objects (#129)

* fix/cursor-modifier (#131)

* fixed cursor modifier not unregistering itself from the pointer when it's disabled

* updated focus lock sync target validation

* Transform Extension Collider and Bounds Calculation Performance Update (#130)

* cache all the colliders

only update transform bounds if collider is set

* moved kinematic flag set ahead of colliders being re-enabled to help with some pref

* Update XRTK.SDK/Packages/com.xrtk.sdk/Features/Input/Handlers/ManipulationHandler.cs

* updated required package version for breaking change

* updated xrtk core upm package

Co-authored-by: Stephen Hodgson <[email protected]>
Co-authored-by: Dino Fejzagic <[email protected]>
  • Loading branch information
3 people authored Feb 9, 2020
1 parent a9ea03b commit 272c093
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ MonoBehaviour:
runtimePlatform: 31
profile: {fileID: 0}
- dataProviderType:
reference: XRTK.WindowsMixedReality.Controllers.WindowsMixedRealityDataProvider,
reference: XRTK.WindowsMixedReality.Controllers.WindowsMixedRealityControllerDataProvider,
XRTK.WindowsMixedReality
dataProviderName: Windows Mixed Reality Controller Data Provider
priority: 1
Expand Down
34 changes: 17 additions & 17 deletions Features/Diagnostics/Prefabs/DefaultDiagnosticsWindow.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 2591092903606399280}
m_HandleRect: {fileID: 9221785712172736509}
m_Direction: 0
m_Value: 0
m_Size: 1
m_Value: 1
m_Size: 0.9999999
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
Expand Down Expand Up @@ -1087,7 +1087,7 @@ Transform:
m_GameObject: {fileID: 2161880003638299081}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_Children:
- {fileID: 7059610919956172988}
m_Father: {fileID: 0}
Expand Down Expand Up @@ -1124,16 +1124,16 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
updateLinkedTransform: 0
moveLerpTime: 0.1
rotateLerpTime: 0.1
moveLerpTime: 0.5
rotateLerpTime: 0.5
scaleLerpTime: 0
maintainScale: 1
smoothing: 1
lifetime: 0
snapToGoalOnEnable: 1
SolverHandler: {fileID: 5630857977071535010}
orientationType: 5
localOffset: {x: 0, y: 0, z: 1.5}
orientationType: 2
localOffset: {x: 0, y: 0, z: 2}
worldOffset: {x: 0, y: 0, z: 0}
useAngleSteppingForWorldOffset: 0
tetherAngleSteps: 6
Expand Down Expand Up @@ -1167,8 +1167,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
logEntryTextColor: {r: 0, g: 0, b: 0, a: 1}
warningEntryTextColor: {r: 0.9607844, g: 0.7490196, b: 0, a: 1}
errorEntryTextColor: {r: 1, g: 0, b: 0, a: 1}
warningEntryTextColor: {r: 0.6, g: 0.46406245, b: 0, a: 1}
errorEntryTextColor: {r: 0.6, g: 0, b: 0, a: 1}
maxEntries: 10
logTextPrefab: {fileID: 720216609463083442, guid: d8c00e493400052458e2ec1b257fc827,
type: 3}
Expand Down Expand Up @@ -1500,10 +1500,10 @@ MonoBehaviour:
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
m_PressedColor: {r: 0.16, g: 0.16, b: 0.16, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_NormalColor: {r: 0.4, g: 0.4, b: 0.4, a: 1}
m_HighlightedColor: {r: 0.6, g: 0.6, b: 0.6, a: 1}
m_PressedColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}
m_SelectedColor: {r: 0.6, g: 0.6, b: 0.6, a: 1}
m_DisabledColor: {r: 1, g: 1, b: 1, a: 0}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
Expand All @@ -1519,7 +1519,7 @@ MonoBehaviour:
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1163695198814191956}
m_TargetGraphic: {fileID: 5298575195987240790}
m_OnClick:
m_PersistentCalls:
m_Calls:
Expand Down Expand Up @@ -1549,7 +1549,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.48, g: 0.48, b: 0.48, a: 1}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
Expand Down Expand Up @@ -1600,7 +1600,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: -0.000061035156, y: -0.000091552734}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 1}
--- !u!222 &4780391842861944988
Expand Down Expand Up @@ -3199,7 +3199,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 1278912945569988977}
m_HandleRect: {fileID: 6647377600167767017}
m_Direction: 2
m_Value: 0
m_Value: 1
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down
2 changes: 1 addition & 1 deletion Features/Input/Handlers/ControllerPoseSynchronizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public virtual void OnSourceLost(SourceStateEventData eventData)

if (destroyOnSourceLost)
{
if (Application.isEditor)
if (Application.isEditor && !Application.isPlaying)
{
DestroyImmediate(gameObject);
}
Expand Down
20 changes: 14 additions & 6 deletions Features/Input/Handlers/ManipulationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,23 +482,31 @@ public Collider Collider
{
get
{
var isSet = false;

if (BoundingBox != null &&
BoundingBox.BoundingBoxCollider != null)
{
return BoundingBox.BoundingBoxCollider;
thisCollider = BoundingBox.BoundingBoxCollider;
isSet = true;
}

if (thisCollider == null)
{
thisCollider = gameObject.GetComponent<Collider>();
isSet = true;
}

if (thisCollider == null)
{
thisCollider = gameObject.EnsureComponent<BoxCollider>();
isSet = true;
}

transform.GetColliderBounds();
if (isSet)
{
transform.GetColliderBounds(ref cachedColliders);
}

return thisCollider;
}
Expand Down Expand Up @@ -556,6 +564,7 @@ public Collider Collider
private float snappedVerticalPosition;

private Transform snapTarget;
private Collider[] cachedColliders;

#region Monobehaviour Implementation

Expand Down Expand Up @@ -896,8 +905,7 @@ public virtual void BeginHold(MixedRealityPointerEventData eventData, Vector3? g
}

PrimaryPointer.OverrideGrabPoint = grabOffset;

transform.SetCollidersActive(false);
transform.SetCollidersActive(false, ref cachedColliders);
Collider.enabled = true;
body.isKinematic = false;

Expand Down Expand Up @@ -935,10 +943,10 @@ public virtual void EndHold(bool isCanceled = false)

MixedRealityToolkit.InputSystem?.PopModalInputHandler();

transform.SetCollidersActive(true);

body.isKinematic = true;

transform.SetCollidersActive(true, ref cachedColliders);

PrimaryPointer.SyncedTarget = null;
PrimaryPointer.OverrideGrabPoint = null;
PrimaryPointer.IsFocusLocked = false;
Expand Down
7 changes: 6 additions & 1 deletion Features/Input/InputSystemGlobalListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace XRTK.SDK.Input
/// <summary>
/// This component ensures that all input events are forwarded to this <see cref="GameObject"/> when focus or gaze is not required.
/// </summary>
public abstract class InputSystemGlobalListener : MonoBehaviour
public class InputSystemGlobalListener : MonoBehaviour
{
private bool lateInitialize = true;

Expand Down Expand Up @@ -44,6 +44,11 @@ protected virtual void OnDisable()
MixedRealityToolkit.InputSystem?.Unregister(gameObject);
}

protected virtual void OnDestroy()
{
MixedRealityToolkit.InputSystem?.Unregister(gameObject);
}

protected async Task<bool> ValidateInputSystemAsync()
{
try
Expand Down
15 changes: 10 additions & 5 deletions Features/UX/Scripts/BoundingBox/BoundingBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public BoundingBox BoundingBoxParent

private int cachedTargetPrevLayer;

private Collider[] colliderCache;
private Collider[] parentColliderCache;

/// <inheritdoc />
void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData eventData)
{
Expand Down Expand Up @@ -81,8 +84,8 @@ void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData even
cachedTargetPrevLayer = BoundingBoxParent.BoundingBoxCollider.gameObject.layer;
BoundingBoxParent.BoundingBoxCollider.transform.SetLayerRecursively(IgnoreRaycastLayer);
BoundingBoxParent.BoundingBoxCollider.enabled = false;
BoundingBoxParent.transform.SetCollidersActive(false);
transform.SetCollidersActive(false);
BoundingBoxParent.transform.SetCollidersActive(false, ref parentColliderCache);
transform.SetCollidersActive(false, ref colliderCache);
BoundingBoxParent.BoundingBoxCollider.enabled = true;
BoundingBoxParent.isManipulationEnabled = true;
eventData.Use();
Expand All @@ -103,8 +106,8 @@ void IMixedRealityPointerHandler.OnPointerUp(MixedRealityPointerEventData eventD
BoundingBoxParent.ResetHandleVisibility();
MixedRealityToolkit.InputSystem.PopModalInputHandler();
BoundingBoxParent.BoundingBoxCollider.transform.SetLayerRecursively(cachedTargetPrevLayer);
BoundingBoxParent.transform.SetCollidersActive(true);
transform.SetCollidersActive(true);
BoundingBoxParent.transform.SetCollidersActive(true, ref parentColliderCache);
transform.SetCollidersActive(true, ref colliderCache);
eventData.Use();
}
}
Expand Down Expand Up @@ -552,6 +555,8 @@ public bool IsVisible

private Vector3[] boundsCorners = new Vector3[8];

private Collider[] colliderCache;

/// <summary>
/// The current bounds corner positions.
/// </summary>
Expand Down Expand Up @@ -994,7 +999,7 @@ public void ResetBoundingBoxBounds()
transform.rotation = Quaternion.identity;
Physics.SyncTransforms(); // Update collider bounds

var bounds = transform.GetColliderBounds(false);
var bounds = transform.GetColliderBounds(ref colliderCache, false);

BoundingBoxCollider = gameObject.AddComponent<BoxCollider>();

Expand Down
3 changes: 2 additions & 1 deletion Features/UX/Scripts/Cursors/BaseCursor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ protected override void OnDisable()
OnCursorStateChange(CursorStateEnum.Contextual);
}

private void OnDestroy()
protected override void OnDestroy()
{
base.OnDestroy();
UnregisterManagers();
}

Expand Down
30 changes: 26 additions & 4 deletions Features/UX/Scripts/Cursors/CursorModifier.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using XRTK.Definitions.Physics;
using UnityEngine;
using XRTK.Definitions.Utilities;
using XRTK.EventDatum.Input;
using XRTK.Interfaces.InputSystem;
using XRTK.Interfaces.InputSystem.Handlers;
using XRTK.Services;
using UnityEngine;

namespace XRTK.SDK.UX.Cursors
{
Expand Down Expand Up @@ -116,6 +115,8 @@ public bool HideCursorOnFocus
/// <inheritdoc />
public Vector3 GetModifiedPosition(IMixedRealityCursor cursor)
{
Debug.Assert(gameObject.activeInHierarchy);

if (SnapCursorPosition)
{
// Snap if the targeted object has a cursor modifier that supports snapping
Expand All @@ -140,8 +141,9 @@ public Vector3 GetModifiedPosition(IMixedRealityCursor cursor)
/// <inheritdoc />
public Quaternion GetModifiedRotation(IMixedRealityCursor cursor)
{
RayStep lastStep = cursor.Pointer.Rays[cursor.Pointer.Rays.Length - 1];
Vector3 forward = UseGazeBasedNormal ? -lastStep.Direction : HostTransform.rotation * CursorNormalOffset;
Debug.Assert(gameObject.activeInHierarchy);
var lastStep = cursor.Pointer.Rays[cursor.Pointer.Rays.Length - 1];
var forward = UseGazeBasedNormal ? -lastStep.Direction : HostTransform.rotation * CursorNormalOffset;

// Determine the cursor forward rotation
return forward.magnitude > 0
Expand All @@ -152,12 +154,14 @@ public Quaternion GetModifiedRotation(IMixedRealityCursor cursor)
/// <inheritdoc />
public Vector3 GetModifiedScale(IMixedRealityCursor cursor)
{
Debug.Assert(gameObject.activeInHierarchy);
return CursorScaleOffset;
}

/// <inheritdoc />
public void GetModifiedTransform(IMixedRealityCursor cursor, out Vector3 position, out Quaternion rotation, out Vector3 scale)
{
Debug.Assert(gameObject.activeInHierarchy);
position = GetModifiedPosition(cursor);
rotation = GetModifiedRotation(cursor);
scale = GetModifiedScale(cursor);
Expand Down Expand Up @@ -193,6 +197,24 @@ private void OnValidate()
Debug.Assert(HostTransform.GetComponent<Collider>() != null, $"A collider component is required on {hostTransform.gameObject.name} for the cursor modifier component on {gameObject.name} to function properly.");
}

private void OnDisable()
{
if (MixedRealityToolkit.InputSystem != null)
{
foreach (var inputSource in MixedRealityToolkit.InputSystem.DetectedInputSources)
{
foreach (var pointer in inputSource.Pointers)
{
if (pointer.CursorModifier != null &&
pointer.CursorModifier.HostTransform == HostTransform)
{
pointer.CursorModifier = null;
}
}
}
}
}

#endregion MonoBehaviour Implementaiton
}
}
Loading

0 comments on commit 272c093

Please sign in to comment.