Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Packages/Tracking/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated Copyright year to 2025
- Split tracking preview examples into different groups - common assets, main examples and examples that need the old input manager to work (e.g. UI input)
- (Service Provider) Expose service IP and port as user settable variables
- Functions for InterpolateFrame / InterpolateFrameFromTime / GetInterpolatedFrameSize will no longer call LeapC unless a valid device is passed/set
- LeapServiceProvider Update will no longer request an interpolated frame without a valid device being set
- LeapServiceProvider FixedUpdate will no longer request an interpolated frame without a valid device and connection, bringing it into line with Update

### Fixed
- Fixed some warnings around runtime variables that were only used in editor mode
Expand Down
29 changes: 22 additions & 7 deletions Packages/Tracking/Core/Runtime/Plugins/LeapCSharp/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public event EventHandler<ConnectionEventArgs> LeapConnection

private bool _disposed = false;

private bool _loggedNullDeviceWarningForGetInterpolatedFrame = false;
private bool _loggedNullDeviceWarningForGetInterpolatedFrameSize = false;

public void Dispose()
{
Dispose(true);
Expand Down Expand Up @@ -428,7 +431,6 @@ private void handleTrackingMessage(ref LEAP_TRACKING_EVENT trackingMsg, UInt32 d
}
}


public UInt64 GetInterpolatedFrameSize(Int64 time, Device device = null)
{
UInt64 size = 0;
Expand All @@ -440,15 +442,18 @@ public UInt64 GetInterpolatedFrameSize(Int64 time, Device device = null)
}
else
{
result = LeapC.GetFrameSize(_leapConnection, time, out size);
if (!_loggedNullDeviceWarningForGetInterpolatedFrameSize)
{
UnityEngine.Debug.LogWarning($"Device is null, requesting the frame size without a valid device (handle) is no longer supported and should be considered obsolete");
_loggedNullDeviceWarningForGetInterpolatedFrameSize = true;
}
result = eLeapRS.eLeapRS_Unsupported;
}

reportAbnormalResults("LeapC get interpolated frame call was ", result);
return size;
}



public void GetInterpolatedFrame(Frame toFill, Int64 time, Device device = null)
{
UInt64 size = GetInterpolatedFrameSize(time, device);
Expand All @@ -461,7 +466,12 @@ public void GetInterpolatedFrame(Frame toFill, Int64 time, Device device = null)
}
else
{
result = LeapC.InterpolateFrame(_leapConnection, time, trackingBuffer, size);
if (!_loggedNullDeviceWarningForGetInterpolatedFrame)
{
UnityEngine.Debug.LogWarning($"Device is null, requesting an interpolated frame without a valid device (handle) is no longer supported and should be considered obsolete");
_loggedNullDeviceWarningForGetInterpolatedFrame= true;
}
result = eLeapRS.eLeapRS_Unsupported;
}

reportAbnormalResults("LeapC get interpolated frame call was ", result);
Expand All @@ -482,12 +492,17 @@ public void GetInterpolatedFrameFromTime(Frame toFill, Int64 time, Int64 sourceT

if (device != null)
{

result = LeapC.InterpolateFrameFromTimeEx(_leapConnection, device.Handle, time, sourceTime, trackingBuffer, size);
}
else
{
result = LeapC.InterpolateFrameFromTime(_leapConnection, time, sourceTime, trackingBuffer, size);
if (!_loggedNullDeviceWarningForGetInterpolatedFrame)
{
UnityEngine.Debug.LogWarning($"Device is null, requesting an interpolated frame (from time) without a valid device (handle) is no longer supported and should be considered obsolete");
_loggedNullDeviceWarningForGetInterpolatedFrame = true;
}

result = eLeapRS.eLeapRS_Unsupported;
}

reportAbnormalResults("LeapC get interpolated frame from time call was ", result);
Expand Down
9 changes: 7 additions & 2 deletions Packages/Tracking/Core/Runtime/Scripts/LeapServiceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ protected virtual void Update()

protected virtual void FixedUpdate()
{
if (!checkConnectionIntegrity()) { return; }

if (_useInterpolation)
{
long timestamp;
Expand All @@ -691,7 +693,10 @@ protected virtual void FixedUpdate()
"Unexpected frame optimization mode: " + _frameOptimization);
}

_leapController.GetInterpolatedFrame(_untransformedFixedFrame, timestamp, _currentDevice);
if (_currentDevice != null)
{
_leapController.GetInterpolatedFrame(_untransformedFixedFrame, timestamp, _currentDevice);
}
}
else
{
Expand Down Expand Up @@ -767,7 +772,7 @@ void HandleUpdateFrameInterpolationAndTransformation()
return;
}

if (_useInterpolation)
if (_useInterpolation && _currentDevice != null)
{
#if !UNITY_ANDROID || UNITY_EDITOR
_smoothedTrackingLatency.value = Mathf.Min(_smoothedTrackingLatency.value, 30000f);
Expand Down