st/oxr: Verify poses in space create functions

This commit is contained in:
Jakob Bornecrantz 2019-07-21 13:40:27 +01:00 committed by Jakob Bornecrantz
parent 505d5cf5d6
commit e7a933a168
2 changed files with 17 additions and 1 deletions

View file

@ -13,6 +13,7 @@
#include "xrt/xrt_compiler.h"
#include "math/m_api.h"
#include "util/u_debug.h"
#include "oxr_objects.h"
@ -34,7 +35,7 @@ oxr_xrCreateActionSpace(XrAction action,
"xrCreateActionSpace");
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, createInfo,
XR_TYPE_ACTION_SPACE_CREATE_INFO);
OXR_VERIFY_POSE(&log, createInfo->poseInActionSpace);
struct oxr_space* spc;
XrResult ret = oxr_space_action_create(&log, act, createInfo, &spc);
@ -96,6 +97,7 @@ oxr_xrCreateReferenceSpace(XrSession session,
"xrCreateReferenceSpace");
OXR_VERIFY_ARG_TYPE_AND_NULL(&log, createInfo,
XR_TYPE_REFERENCE_SPACE_CREATE_INFO);
OXR_VERIFY_POSE(&log, createInfo->poseInReferenceSpace);
ret = oxr_space_reference_create(&log, sess, createInfo, &spc);
if (ret != XR_SUCCESS) {

View file

@ -130,6 +130,20 @@ extern "C" {
} \
} while (false)
#define OXR_VERIFY_POSE(log, p) \
do { \
if (!math_quat_validate((struct xrt_quat*)&p.orientation)) { \
return oxr_error(log, XR_ERROR_POSE_INVALID, \
"(" #p \
".orientation) is not a valid quat"); \
} \
\
if (!math_vec3_validate((struct xrt_vec3*)&p.position)) { \
return oxr_error(log, XR_ERROR_POSE_INVALID, \
"(" #p ".position) is not valid"); \
} \
} while (false)
/*
*
* Implementation in oxr_verify.cpp