/// <summary> /// Updates the state of the PCF. /// </summary> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if operation completed successfully. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to an invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if there was a lack of privileges. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to other internal error. /// MLResult.Result will be <c>MLResult.Code.PassableWorldLowMapQuality</c> if map quality is too low for content persistence. Continue building the map. /// MLResult.Result will be <c>MLResult.Code.PassableWorldNotFound</c> if the passed CFUID is not available. /// MLResult.Result will be <c>MLResult.Code.PassableWorldUnableToLocalize</c> if currently unable to localize into any map. Continue building the map. /// </returns> private MLResult UpdateState() { if (MLPersistentCoordinateFrames.IsValidInstance()) { try { NativeBindings.FrameStateNative nativeState = NativeBindings.FrameStateNative.Create(); MLResult.Code resultCode = NativeBindings.MLPersistentCoordinateFramesGetFrameState(MLPersistentCoordinateFrames._instance.nativeTracker, in this.cfuid, ref nativeState); if (!MLResult.IsOK(resultCode)) { MLPluginLog.ErrorFormat("PCF.UpdateState failed to get frame state. Reason: {0}", MLResult.CodeToString(resultCode)); return(MLResult.Create(resultCode, string.Format("PCF.UpdateState failed to get frame state. Reason: {0}", MLResult.CodeToString(resultCode)))); } this.FrameState = nativeState.Data(); return(MLResult.Create(resultCode)); } catch (EntryPointNotFoundException) { MLPluginLog.Error("PCF.UpdateState failed. Reason: API symbols not found."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "PCF.UpdateState failed. Reason: API symbols not found.")); } } else { MLPluginLog.ErrorFormat("PCF.UpdateState failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "PCF.UpdateState failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }
/// <summary> /// Updates the PCF's pose and state. /// </summary> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if operation was successful. /// MLResult.Result will be <c>MLResult.Code.SnapshotPoseNotFound</c> if the PCF could not be found in the current map. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed due to an invalid input parameter. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if there was a lack of privileges. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to other internal error. /// MLResult.Result will be <c>MLResult.Code.PassableWorldLowMapQuality</c> if map quality is too low for content persistence. Continue building the map. /// MLResult.Result will be <c>MLResult.Code.PassableWorldNotFound</c> if the passed CFUID is not available. /// MLResult.Result will be <c>MLResult.Code.PassableWorldUnableToLocalize</c> if currently unable to localize into any map. Continue building the map. /// </returns> public MLResult Update() { if (MLPersistentCoordinateFrames.IsValidInstance()) { if (!MLPersistentCoordinateFrames._instance.mapUpdatedPCFsThisFrame.ContainsKey(this.cfuid)) { MLPersistentCoordinateFrames._instance.mapUpdatedPCFsThisFrame.Add(this.cfuid, this); try { MLResult result = MLResult.Create(MLResult.Code.Ok); if (MLPersistentCoordinateFrames.IsLocalized) { if (MagicLeapNativeBindings.UnityMagicLeap_TryGetPose(this.CFUID, out Pose newPose)) { this.Pose = newPose; result = this.UpdateState(); if (!result.IsOk) { MLPluginLog.ErrorFormat("PCF.Update failed because PCF.UpdateState failed. Reason: {0}", result); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, string.Format("PCF.Update failed because PCF.UpdateState failed. Reason: {0}", result))); } this.CurrentResultCode = MLResult.Code.Ok; } else { result = MLResult.Create(MLResult.Code.UnspecifiedFailure, string.Format("PCF.Update failed. Reason: No pose could be found for the CFUID {0}", this.cfuid)); this.CurrentResultCode = MLResult.Code.SnapshotPoseNotFound; } } else { this.CurrentResultCode = MLResult.Code.SnapshotPoseNotFound; } return(result); } catch (EntryPointNotFoundException) { MLPluginLog.Error("PCF.Update failed. Reason: API symbols not found."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "PCF.Update failed. Reason: API symbols not found.")); } } else { return(MLResult.Create(MLResult.Code.Ok)); } } else { MLPluginLog.ErrorFormat("PCF.Update failed. Reason: No Instance for MLPersistentCoordinateFrames."); return(MLResult.Create(MLResult.Code.UnspecifiedFailure, "PCF.Update failed. Reason: No Instance for MLPersistentCoordinateFrames.")); } }