diff --git a/src/xrt/state_trackers/oxr/oxr_api_space.c b/src/xrt/state_trackers/oxr/oxr_api_space.c index 09dfe7a89..96f3831ef 100644 --- a/src/xrt/state_trackers/oxr/oxr_api_space.c +++ b/src/xrt/state_trackers/oxr/oxr_api_space.c @@ -143,6 +143,9 @@ oxr_xrLocateSpace(XrSpace space, OXR_VERIFY_ARG_TYPE_AND_NOT_NULL(&log, location, XR_TYPE_SPACE_LOCATION); + OXR_VERIFY_ARG_TYPE_CAN_BE_NULL( + &log, ((XrSpaceVelocity *)location->next), XR_TYPE_SPACE_VELOCITY); + if (time <= (XrTime)0) { return oxr_error(&log, XR_ERROR_TIME_INVALID, "(time == %" PRIi64 ") is not a valid time.", diff --git a/src/xrt/state_trackers/oxr/oxr_space.c b/src/xrt/state_trackers/oxr/oxr_space.c index e159da787..f49c5af8c 100644 --- a/src/xrt/state_trackers/oxr/oxr_space.c +++ b/src/xrt/state_trackers/oxr/oxr_space.c @@ -325,6 +325,9 @@ get_xr_space_location_flags(enum xrt_space_relation_flags relation_flags) bool tracked_ori = (relation_flags & XRT_SPACE_RELATION_ORIENTATION_TRACKED_BIT) != 0; bool valid_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_VALID_BIT) != 0; bool tracked_pos = (relation_flags & XRT_SPACE_RELATION_POSITION_TRACKED_BIT) != 0; + + bool linear_vel = (relation_flags & XRT_SPACE_RELATION_LINEAR_VELOCITY_VALID_BIT) != 0; + bool angular_vel = (relation_flags & XRT_SPACE_RELATION_ANGULAR_VELOCITY_VALID_BIT) != 0; // clang-format on XrSpaceLocationFlags location_flags = (XrSpaceLocationFlags)0; @@ -340,6 +343,12 @@ get_xr_space_location_flags(enum xrt_space_relation_flags relation_flags) if (tracked_pos) { location_flags |= XR_SPACE_LOCATION_POSITION_TRACKED_BIT; } + if (linear_vel) { + location_flags |= XR_SPACE_VELOCITY_LINEAR_VALID_BIT; + } + if (angular_vel) { + location_flags |= XR_SPACE_VELOCITY_ANGULAR_VALID_BIT; + } return location_flags; } @@ -381,6 +390,22 @@ oxr_space_locate(struct oxr_logger *log, location->locationFlags = get_xr_space_location_flags(result.relation_flags); + XrSpaceVelocity *vel = (XrSpaceVelocity *)location->next; + if (vel) { + vel->linearVelocity.x = result.linear_velocity.x; + vel->linearVelocity.y = result.linear_velocity.y; + vel->linearVelocity.z = result.linear_velocity.z; + + vel->angularVelocity.x = result.angular_velocity.x; + vel->angularVelocity.y = result.angular_velocity.y; + vel->angularVelocity.z = result.angular_velocity.z; + + vel->velocityFlags |= (location->locationFlags & + XR_SPACE_VELOCITY_LINEAR_VALID_BIT); + vel->velocityFlags |= (location->locationFlags & + XR_SPACE_VELOCITY_ANGULAR_VALID_BIT); + } + #if 0 location->linearVelocity = *(XrVector3f *)&result.linear_velocity; location->angularVelocity = *(XrVector3f *)&result.angular_velocity;