/// <summary> /// Replace the hand data with the given values. /// </summary> /// <returns>True if the hand data has been changed.</returns> /// <param name="isTrackedNew">True if the hand is currently tracked.</param> /// <param name="isPinchingNew">True if the hand is in a pinching pose that causes a "Select" action.</param> /// <param name="generator">Generator function that produces joint positions and rotations. The joint data generator is only used when the hand is tracked.</param> /// <remarks>The timestamp of the hand data will be the current time, see [DateTime.UtcNow](https://docs.microsoft.com/dotnet/api/system.datetime.utcnow?view=netframework-4.8).</remarks> public bool Update(bool isTrackedNew, bool isPinchingNew, HandJointDataGenerator generator) { bool handDataChanged = false; if (isTracked != isTrackedNew || isPinching != isPinchingNew) { isTracked = isTrackedNew; isPinching = isPinchingNew; handDataChanged = true; } if (isTracked) { generator(Joints); handDataChanged = true; } return(handDataChanged); }
public bool UpdateWithTimestamp(long timestampNew, bool isTrackedNew, bool isPinchingNew, HandJointDataGenerator generator) { bool handDataChanged = false; if (isTracked != isTrackedNew || isPinching != isPinchingNew) { isTracked = isTrackedNew; isPinching = isPinchingNew; handDataChanged = true; } if (timestamp != timestampNew) { timestamp = timestampNew; if (isTracked) { generator(Joints); handDataChanged = true; } } return(handDataChanged); }
public bool Update(bool isTrackedNew, bool isPinchingNew, HandJointDataGenerator generator) { // TODO: DateTime.UtcNow can be quite imprecise, better use Stopwatch.GetTimestamp // https://stackoverflow.com/questions/2143140/c-sharp-datetime-now-precision return(UpdateWithTimestamp(DateTime.UtcNow.Ticks, isTrackedNew, isPinchingNew, generator)); }