2019-03-18 05:52:32 +00:00
|
|
|
// Copyright 2019, Collabora, Ltd.
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
/*!
|
|
|
|
* @file
|
|
|
|
* @brief Space, space, space, SPAAAAAAAAAAAAAAAAAAAAAAAAAACE!
|
|
|
|
* @author Jakob Bornecrantz <jakob@collabora.com>
|
|
|
|
* @ingroup oxr_api
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "xrt/xrt_compiler.h"
|
|
|
|
|
2019-07-21 12:40:27 +00:00
|
|
|
#include "math/m_api.h"
|
2019-03-18 05:52:32 +00:00
|
|
|
#include "util/u_debug.h"
|
|
|
|
|
|
|
|
#include "oxr_objects.h"
|
|
|
|
#include "oxr_logger.h"
|
|
|
|
#include "oxr_two_call.h"
|
|
|
|
|
|
|
|
#include "oxr_api_funcs.h"
|
|
|
|
#include "oxr_api_verify.h"
|
|
|
|
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrCreateActionSpace(XrAction action,
|
|
|
|
const XrActionSpaceCreateInfo* createInfo,
|
|
|
|
XrSpace* space)
|
|
|
|
{
|
|
|
|
struct oxr_action* act;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_ACTION_AND_INIT_LOG(&log, action, act,
|
|
|
|
"xrCreateActionSpace");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, createInfo,
|
|
|
|
XR_TYPE_ACTION_SPACE_CREATE_INFO);
|
2019-07-21 12:40:27 +00:00
|
|
|
OXR_VERIFY_POSE(&log, createInfo->poseInActionSpace);
|
2019-04-05 22:28:36 +00:00
|
|
|
|
|
|
|
struct oxr_space* spc;
|
|
|
|
XrResult ret = oxr_space_action_create(&log, act, createInfo, &spc);
|
|
|
|
if (ret != XR_SUCCESS) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
*space = oxr_space_to_openxr(spc);
|
|
|
|
|
|
|
|
return XR_SUCCESS;
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const XrReferenceSpaceType session_spaces[] = {
|
|
|
|
XR_REFERENCE_SPACE_TYPE_VIEW,
|
|
|
|
XR_REFERENCE_SPACE_TYPE_LOCAL,
|
|
|
|
XR_REFERENCE_SPACE_TYPE_STAGE,
|
|
|
|
};
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrEnumerateReferenceSpaces(XrSession session,
|
|
|
|
uint32_t spaceCapacityInput,
|
|
|
|
uint32_t* spaceCountOutput,
|
|
|
|
XrReferenceSpaceType* spaces)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrEnumerateReferenceSpaces");
|
|
|
|
|
|
|
|
OXR_TWO_CALL_HELPER(&log, spaceCapacityInput, spaceCountOutput, spaces,
|
|
|
|
ARRAY_SIZE(session_spaces), session_spaces);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrGetReferenceSpaceBoundsRect(XrSession session,
|
|
|
|
XrReferenceSpaceType referenceSpaceType,
|
|
|
|
XrExtent2Df* bounds)
|
|
|
|
{
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrGetReferenceSpaceBoundsRect");
|
|
|
|
|
|
|
|
//! @todo Implement
|
2019-03-27 13:35:15 +00:00
|
|
|
return oxr_error(&log, XR_ERROR_FUNCTION_UNSUPPORTED,
|
|
|
|
" not implemented");
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrCreateReferenceSpace(XrSession session,
|
|
|
|
const XrReferenceSpaceCreateInfo* createInfo,
|
|
|
|
XrSpace* out_space)
|
|
|
|
{
|
|
|
|
XrResult ret;
|
|
|
|
struct oxr_session* sess;
|
|
|
|
struct oxr_space* spc;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SESSION_AND_INIT_LOG(&log, session, sess,
|
|
|
|
"xrCreateReferenceSpace");
|
|
|
|
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, createInfo,
|
|
|
|
XR_TYPE_REFERENCE_SPACE_CREATE_INFO);
|
2019-07-21 12:40:27 +00:00
|
|
|
OXR_VERIFY_POSE(&log, createInfo->poseInReferenceSpace);
|
2019-03-18 05:52:32 +00:00
|
|
|
|
|
|
|
ret = oxr_space_reference_create(&log, sess, createInfo, &spc);
|
|
|
|
if (ret != XR_SUCCESS) {
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
*out_space = oxr_space_to_openxr(spc);
|
|
|
|
|
|
|
|
return XR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrLocateSpace(XrSpace space,
|
|
|
|
XrSpace baseSpace,
|
|
|
|
XrTime time,
|
|
|
|
XrSpaceRelation* relation)
|
|
|
|
{
|
|
|
|
struct oxr_space* spc;
|
|
|
|
struct oxr_space* baseSpc;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SPACE_AND_INIT_LOG(&log, space, spc, "xrLocateSpace");
|
|
|
|
OXR_VERIFY_SPACE_NOT_NULL(&log, baseSpace, baseSpc);
|
|
|
|
OXR_VERIFY_ARG_NOT_NULL(&log, relation);
|
|
|
|
|
|
|
|
return oxr_space_locate(&log, spc, baseSpc, time, relation);
|
|
|
|
}
|
|
|
|
|
|
|
|
XrResult
|
|
|
|
oxr_xrDestroySpace(XrSpace space)
|
|
|
|
{
|
|
|
|
struct oxr_space* spc;
|
|
|
|
struct oxr_logger log;
|
|
|
|
OXR_VERIFY_SPACE_AND_INIT_LOG(&log, space, spc, "xrDestroySpace");
|
|
|
|
|
2019-04-05 19:18:03 +00:00
|
|
|
return oxr_handle_destroy(&log, &spc->handle);
|
2019-03-18 05:52:32 +00:00
|
|
|
}
|