/// <summary> /// Raise a Tango pose event if there is new data. /// </summary> internal void SendPoseIfAvailable() { #if UNITY_EDITOR if (TangoApplication.m_mouseEmulationViaPoseUpdates) { PoseProvider.UpdateTangoEmulation(); lock (m_lockObject) { if (m_onTangoPoseAvailable != null) { FillEmulatedPoseData(ref m_motionTrackingData, TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE, TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE); FillEmulatedPoseData(ref m_areaLearningData, TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION, TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE); m_isDirty = true; } } } #endif if (m_isDirty) { if (m_onTangoPoseAvailable != null) { // NOTE: If this becomes a performance issue, this could be changed to use // Interlocked.CompareExchange to "consume" the motion tracking data. lock (m_lockObject) { if (m_motionTrackingData != null) { m_onTangoPoseAvailable(m_motionTrackingData); m_poseDataPool.Push(m_motionTrackingData); m_motionTrackingData = null; } if (m_areaLearningData != null) { m_onTangoPoseAvailable(m_areaLearningData); m_poseDataPool.Push(m_areaLearningData); m_areaLearningData = null; } if (m_relocalizationData != null) { m_onTangoPoseAvailable(m_relocalizationData); m_poseDataPool.Push(m_relocalizationData); m_relocalizationData = null; } } } m_isDirty = false; } }
/// <summary> /// Raise a Tango pose event if there is new data. /// </summary> /// <param name="emulateAreaDescriptions">If set, Area description poses are emulated.</param> internal void SendPoseIfAvailable(bool emulateAreaDescriptions) { #if UNITY_EDITOR PoseProvider.UpdateTangoEmulation(); lock (m_lockObject) { if (m_onTangoPoseAvailable != null) { TangoCoordinateFramePair framePair; framePair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_START_OF_SERVICE; framePair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE; PoseProvider.GetPoseAtTime(m_motionTrackingData, 0, framePair); m_isMotionTrackingPoseAvailable = true; if (emulateAreaDescriptions) { framePair.baseFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION; framePair.targetFrame = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_DEVICE; PoseProvider.GetPoseAtTime(m_areaLearningData, 0, framePair); m_isAreaLearningPoseAvailable = true; } } } #endif if (m_onTangoPoseAvailable != null) { // NOTE: If this becomes a performance issue, this could be changed to use // Interlocked.CompareExchange to "consume" the motion tracking data. lock (m_lockObject) { if (m_isMotionTrackingPoseAvailable) { m_onTangoPoseAvailable(m_motionTrackingData); m_isMotionTrackingPoseAvailable = false; } if (m_isAreaLearningPoseAvailable) { m_onTangoPoseAvailable(m_areaLearningData); m_isAreaLearningPoseAvailable = false; } if (m_isRelocalizaitonPoseAvailable) { m_onTangoPoseAvailable(m_relocalizationData); m_isRelocalizaitonPoseAvailable = false; } } } }