Skip to content

Commit 87ddac5

Browse files
Added suggestions from Lars about directly getting the pointer extent instead of searching though our index of pointers.
1 parent 92fa3bd commit 87ddac5

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Assets/HoloToolkit/Input/Scripts/Focus/FocusManager.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,11 @@ public void UnregisterPointer(IPointingSource pointingSource)
292292

293293
int pointerIndex;
294294
TryGetPointerIndex(pointingSource, out pointerIndex);
295+
Debug.Assert(pointerIndex > 0, "Invalid pointer index!");
295296

296297
PointerData pointer;
297-
GetPointer(pointingSource, out pointer);
298+
GetPointerData(pointingSource, out pointer);
299+
Debug.Assert(pointer != null, "Attempting to unregister a pointer that was never registered!");
298300

299301
// Should we be protecting against unregistering the GazeManager?
300302

@@ -378,7 +380,7 @@ public FocusDetails GetFocusDetails(IPointingSource pointingSource)
378380
PointerData pointerData;
379381
FocusDetails details = default(FocusDetails);
380382

381-
if (GetPointer(pointingSource, out pointerData))
383+
if (GetPointerData(pointingSource, out pointerData))
382384
{
383385
details = pointerData.End;
384386
}
@@ -391,7 +393,7 @@ public GameObject GetFocusedObject(IPointingSource pointingSource)
391393
PointerData pointerData;
392394
GameObject focusedObject = null;
393395

394-
if (GetPointer(pointingSource, out pointerData))
396+
if (GetPointerData(pointingSource, out pointerData))
395397
{
396398
focusedObject = pointerData.End.Object;
397399
}
@@ -438,18 +440,12 @@ public PointerInputEventData GetGazePointerEventData()
438440
public PointerInputEventData GetSpecificPointerEventData(IPointingSource pointer)
439441
{
440442
PointerData pointerEventData;
441-
return GetPointer(pointer, out pointerEventData) ? pointerEventData.UnityUIPointerData : null;
443+
return GetPointerData(pointer, out pointerEventData) ? pointerEventData.UnityUIPointerData : null;
442444
}
443445

444446
public float GetPointingExtent(IPointingSource pointingSource)
445447
{
446-
PointerData pointerData;
447-
return GetPointer(pointingSource, out pointerData) ? GetPointingExtent(pointerData) : pointingExtent;
448-
}
449-
450-
private float GetPointingExtent(PointerData pointer)
451-
{
452-
return pointer.PointingSource.ExtentOverride ?? pointingExtent;
448+
return pointingSource.ExtentOverride ?? pointingExtent;
453449
}
454450

455451
#endregion
@@ -543,10 +539,10 @@ private void UpdatePointer(PointerData pointer)
543539
/// </summary>
544540
private void RaycastPhysics(PointerData pointer, LayerMask[] prioritizedLayerMasks)
545541
{
546-
RaycastHit physicsHit = default(RaycastHit);
547-
RayStep rayStep = default(RayStep);
548542
bool isHit = false;
549543
int rayStepIndex = 0;
544+
RayStep rayStep = default(RayStep);
545+
RaycastHit physicsHit = default(RaycastHit);
550546

551547
Debug.Assert(pointer.PointingSource.Rays != null, "No valid rays for " + pointer.GetType());
552548
Debug.Assert(pointer.PointingSource.Rays.Length > 0, "No valid rays for " + pointer.GetType());
@@ -571,7 +567,7 @@ private void RaycastPhysics(PointerData pointer, LayerMask[] prioritizedLayerMas
571567
}
572568
else
573569
{
574-
pointer.UpdateHit(GetPointingExtent(pointer));
570+
pointer.UpdateHit(GetPointingExtent(pointer.PointingSource));
575571
}
576572
}
577573

@@ -795,7 +791,7 @@ private void RaisePointerSpecificFocusChangedEvents(IPointingSource pointer, Gam
795791
}
796792
}
797793

798-
private bool GetPointer(IPointingSource pointingSource, out PointerData pointerData)
794+
private bool GetPointerData(IPointingSource pointingSource, out PointerData pointerData)
799795
{
800796
int pointerIndex;
801797

0 commit comments

Comments
 (0)