/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
 */

#pragma once

#include "AR/ArTrackingState.hpp"

#import <ARKit/ARCamera.h>

namespace OpenVulkano::AR::ArKit
{
	inline ArTrackingState GetArTrackingState(ARCamera* camera)
	{
		switch(camera.trackingState)
		{
			case ARTrackingStateNotAvailable: return ArTrackingState::UNAVAILABLE;
			case ARTrackingStateNormal: return ArTrackingState::NORMAL;
			case ARTrackingStateLimited:
			{
				switch(camera.trackingStateReason)
				{
					case ARTrackingStateReasonExcessiveMotion: return ArTrackingState::EXCESSIVE_MOTION;
					case ARTrackingStateReasonInitializing: return ArTrackingState::INITIALIZING;
					case ARTrackingStateReasonInsufficientFeatures: return ArTrackingState::INSUFFICIENT_FEATURES;
					case ARTrackingStateReasonRelocalizing: return ArTrackingState::RELOCALIZING;
					case ARTrackingStateReasonNone: return ArTrackingState::UNKNOWN;
				}
			}
				break;
		}
		return ArTrackingState::UNKNOWN;
	}
}
