Commit bb1a10b0 authored by Kevin Qin's avatar Kevin Qin Committed by Commit Bot

Renaming OpenXR Location Related Variables

Renaming OpenXR location related variables/functions so their meanning
is more clear

Change-Id: I760b143b9f4d4a498741278b507b9608bca51b6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1820022Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Commit-Queue: Zheng Qin <zheqi@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#700000}
parent 925d6d63
......@@ -545,21 +545,23 @@ XrResult OpenXrApiWrapper::GetHeadPose(
XrResult xr_result;
XrSpaceLocation location = {XR_TYPE_SPACE_LOCATION};
RETURN_IF_XR_FAILED(xrLocateSpace(
view_space_, local_space_, frame_state_.predictedDisplayTime, &location));
XrSpaceLocation view_from_local = {XR_TYPE_SPACE_LOCATION};
RETURN_IF_XR_FAILED(xrLocateSpace(view_space_, local_space_,
frame_state_.predictedDisplayTime,
&view_from_local));
if (location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) {
if (view_from_local.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) {
*orientation = gfx::Quaternion(
location.pose.orientation.x, location.pose.orientation.y,
location.pose.orientation.z, location.pose.orientation.w);
view_from_local.pose.orientation.x, view_from_local.pose.orientation.y,
view_from_local.pose.orientation.z, view_from_local.pose.orientation.w);
} else {
*orientation = base::nullopt;
}
if (location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) {
*position = gfx::Point3F(location.pose.position.x, location.pose.position.y,
location.pose.position.z);
if (view_from_local.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) {
*position = gfx::Point3F(view_from_local.pose.position.x,
view_from_local.pose.position.y,
view_from_local.pose.position.z);
} else {
*position = base::nullopt;
}
......@@ -668,10 +670,11 @@ XrResult OpenXrApiWrapper::GetStageBounds(XrExtent2Df* stage_bounds) const {
stage_bounds);
}
bool OpenXrApiWrapper::GetStageParameters(XrExtent2Df* stage_bounds,
gfx::Transform* transform) const {
bool OpenXrApiWrapper::GetStageParameters(
XrExtent2Df* stage_bounds,
gfx::Transform* local_from_stage) const {
DCHECK(stage_bounds);
DCHECK(transform);
DCHECK(local_from_stage);
DCHECK(HasSession());
if (!HasSpace(XR_REFERENCE_SPACE_TYPE_LOCAL))
......@@ -683,25 +686,33 @@ bool OpenXrApiWrapper::GetStageParameters(XrExtent2Df* stage_bounds,
if (XR_FAILED(GetStageBounds(stage_bounds)))
return false;
XrSpaceLocation location = {XR_TYPE_SPACE_LOCATION};
XrSpaceLocation local_from_stage_location = {XR_TYPE_SPACE_LOCATION};
if (FAILED(xrLocateSpace(local_space_, stage_space_,
frame_state_.predictedDisplayTime, &location)) ||
!(location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) ||
!(location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)) {
frame_state_.predictedDisplayTime,
&local_from_stage_location)) ||
!(local_from_stage_location.locationFlags &
XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) ||
!(local_from_stage_location.locationFlags &
XR_SPACE_LOCATION_POSITION_VALID_BIT)) {
return false;
}
// Convert the orientation and translation given by runtime into a
// transformation matrix.
gfx::DecomposedTransform seat_to_standing_decomp;
seat_to_standing_decomp.quaternion =
gfx::Quaternion(location.pose.orientation.x, location.pose.orientation.y,
location.pose.orientation.z, location.pose.orientation.w);
seat_to_standing_decomp.translate[0] = location.pose.position.x;
seat_to_standing_decomp.translate[1] = location.pose.position.y;
seat_to_standing_decomp.translate[2] = location.pose.position.z;
*transform = gfx::ComposeTransform(seat_to_standing_decomp);
gfx::DecomposedTransform local_from_stage_decomp;
local_from_stage_decomp.quaternion =
gfx::Quaternion(local_from_stage_location.pose.orientation.x,
local_from_stage_location.pose.orientation.y,
local_from_stage_location.pose.orientation.z,
local_from_stage_location.pose.orientation.w);
local_from_stage_decomp.translate[0] =
local_from_stage_location.pose.position.x;
local_from_stage_decomp.translate[1] =
local_from_stage_location.pose.position.y;
local_from_stage_decomp.translate[2] =
local_from_stage_location.pose.position.z;
*local_from_stage = gfx::ComposeTransform(local_from_stage_decomp);
return true;
}
......
......@@ -61,7 +61,7 @@ class OpenXrApiWrapper {
XrResult GetLuid(LUID* luid) const;
std::string GetRuntimeName() const;
bool GetStageParameters(XrExtent2Df* stage_bounds,
gfx::Transform* standing_transform) const;
gfx::Transform* local_from_stage) const;
static void DEVICE_VR_EXPORT SetTestHook(VRTestHook* hook);
......
......@@ -237,38 +237,42 @@ mojom::VRPosePtr OpenXrController::GetPose(XrTime predicted_display_time,
return nullptr;
}
XrSpaceVelocity velocity = {XR_TYPE_SPACE_VELOCITY};
XrSpaceLocation space_location = {XR_TYPE_SPACE_LOCATION};
space_location.next = &velocity;
XrSpaceVelocity local_from_grip_speed = {XR_TYPE_SPACE_VELOCITY};
XrSpaceLocation local_from_grip = {XR_TYPE_SPACE_LOCATION};
local_from_grip.next = &local_from_grip_speed;
if (XR_FAILED(xrLocateSpace(grip_pose_space_, local_space,
predicted_display_time, &space_location))) {
predicted_display_time, &local_from_grip))) {
return nullptr;
}
mojom::VRPosePtr pose = mojom::VRPose::New();
if (space_location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) {
pose->position = gfx::Point3F(space_location.pose.position.x,
space_location.pose.position.y,
space_location.pose.position.z);
if (local_from_grip.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) {
pose->position = gfx::Point3F(local_from_grip.pose.position.x,
local_from_grip.pose.position.y,
local_from_grip.pose.position.z);
}
if (space_location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) {
if (local_from_grip.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) {
pose->orientation = gfx::Quaternion(
space_location.pose.orientation.x, space_location.pose.orientation.y,
space_location.pose.orientation.z, space_location.pose.orientation.w);
local_from_grip.pose.orientation.x, local_from_grip.pose.orientation.y,
local_from_grip.pose.orientation.z, local_from_grip.pose.orientation.w);
}
if (velocity.velocityFlags & XR_SPACE_VELOCITY_LINEAR_VALID_BIT) {
if (local_from_grip_speed.velocityFlags &
XR_SPACE_VELOCITY_LINEAR_VALID_BIT) {
pose->linear_velocity =
gfx::Vector3dF(velocity.linearVelocity.x, velocity.linearVelocity.y,
velocity.linearVelocity.z);
gfx::Vector3dF(local_from_grip_speed.linearVelocity.x,
local_from_grip_speed.linearVelocity.y,
local_from_grip_speed.linearVelocity.z);
}
if (velocity.velocityFlags & XR_SPACE_VELOCITY_ANGULAR_VALID_BIT) {
if (local_from_grip_speed.velocityFlags &
XR_SPACE_VELOCITY_ANGULAR_VALID_BIT) {
pose->angular_velocity =
gfx::Vector3dF(velocity.angularVelocity.x, velocity.angularVelocity.y,
velocity.angularVelocity.z);
gfx::Vector3dF(local_from_grip_speed.angularVelocity.x,
local_from_grip_speed.angularVelocity.y,
local_from_grip_speed.angularVelocity.z);
}
return pose;
......
......@@ -265,8 +265,8 @@ bool OpenXrRenderLoop::UpdateEye(const XrView& view,
bool OpenXrRenderLoop::UpdateStageParameters() {
bool changed = false;
XrExtent2Df stage_bounds;
gfx::Transform transform;
if (openxr_->GetStageParameters(&stage_bounds, &transform)) {
gfx::Transform local_from_stage;
if (openxr_->GetStageParameters(&stage_bounds, &local_from_stage)) {
if (!current_display_info_->stage_parameters) {
current_display_info_->stage_parameters = mojom::VRStageParameters::New();
changed = true;
......@@ -281,8 +281,9 @@ bool OpenXrRenderLoop::UpdateStageParameters() {
}
if (current_display_info_->stage_parameters->standing_transform !=
transform) {
current_display_info_->stage_parameters->standing_transform = transform;
local_from_stage) {
current_display_info_->stage_parameters->standing_transform =
local_from_stage;
changed = true;
}
} else if (current_display_info_->stage_parameters) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment