Skip to content

Commit

Permalink
fix(Controller): prevent error on cache controller tracked object
Browse files Browse the repository at this point in the history
If the controller isn't ready then SteamVR sets the id to be
the max uint value and if this happens then the cached controller
attempts to add the controller to the array even though it will
already exist. The best solution is to just ignore operations on
caching until the controller is ready (i.e. when the index is a
reasonable number).
  • Loading branch information
thestonefox committed Sep 10, 2016
1 parent 989231e commit 5cdd307
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Assets/VRTK/Scripts/VRTK_ControllerEvents.cs
Expand Up @@ -776,7 +776,7 @@ private void CacheControllerIndex()
{
uint tmpControllerIndex = 0;
var trackedObject = VRTK_DeviceFinder.TrackedObjectOfGameObject(gameObject, out tmpControllerIndex);
if (tmpControllerIndex > 0 && tmpControllerIndex != controllerIndex)
if (tmpControllerIndex > 0 && tmpControllerIndex < uint.MaxValue && tmpControllerIndex != controllerIndex)
{
RemoveControllerIndexFromCache();
VRTK_ObjectCache.trackedControllers.Add(tmpControllerIndex, trackedObject);
Expand Down

0 comments on commit 5cdd307

Please sign in to comment.