/*
 * 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/.
 */

#include "ArKitDelegate.h"

@implementation ArKitDelegate
{
	OpenVulkano::AR::ArKit::ArSessionArKitInternal* m_arSession;
}

- (id)initWithFrameHandler:(OpenVulkano::AR::ArKit::ArSessionArKitInternal*)session
{
	m_arSession = session;
	return self;
}

- (void)session:(ARSession *)session didUpdateFrame:(ARFrame *)frame
{
	m_arSession->OnArNewFrame(session, frame);
}

- (void)sessionWasInterrupted:(ARSession *)session
{
	m_arSession->OnArSessionInterruptedChanged(session, true);
}

- (void)sessionInterruptionEnded:(ARSession *)session
{
	m_arSession->OnArSessionInterruptedChanged(session, false);
}

- (void)session:(ARSession *)session didFailWithError:(NSError *)error
{
	m_arSession->OnArSessionFailed(session, error);
}

- (BOOL)sessionShouldAttemptRelocalization:(ARSession *)session
{
	return m_arSession->ArShouldAttemptRelocalization();
}

- (void)session:(ARSession *)session cameraDidChangeTrackingState:(ARCamera *)camera
{
	m_arSession->OnArCameraTrackingChange(session, camera);
}

- (void)session:(ARSession *)session didUpdateAnchors:(NSArray<__kindof ARAnchor*>*)anchors
{
	m_arSession->OnArAnchorsUpdate(anchors);
}
@end
