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( ...@@ -545,21 +545,23 @@ XrResult OpenXrApiWrapper::GetHeadPose(
XrResult xr_result; XrResult xr_result;
XrSpaceLocation location = {XR_TYPE_SPACE_LOCATION}; XrSpaceLocation view_from_local = {XR_TYPE_SPACE_LOCATION};
RETURN_IF_XR_FAILED(xrLocateSpace( RETURN_IF_XR_FAILED(xrLocateSpace(view_space_, local_space_,
view_space_, local_space_, frame_state_.predictedDisplayTime, &location)); 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( *orientation = gfx::Quaternion(
location.pose.orientation.x, location.pose.orientation.y, view_from_local.pose.orientation.x, view_from_local.pose.orientation.y,
location.pose.orientation.z, location.pose.orientation.w); view_from_local.pose.orientation.z, view_from_local.pose.orientation.w);
} else { } else {
*orientation = base::nullopt; *orientation = base::nullopt;
} }
if (location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) { if (view_from_local.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) {
*position = gfx::Point3F(location.pose.position.x, location.pose.position.y, *position = gfx::Point3F(view_from_local.pose.position.x,
location.pose.position.z); view_from_local.pose.position.y,
view_from_local.pose.position.z);
} else { } else {
*position = base::nullopt; *position = base::nullopt;
} }
...@@ -668,10 +670,11 @@ XrResult OpenXrApiWrapper::GetStageBounds(XrExtent2Df* stage_bounds) const { ...@@ -668,10 +670,11 @@ XrResult OpenXrApiWrapper::GetStageBounds(XrExtent2Df* stage_bounds) const {
stage_bounds); stage_bounds);
} }
bool OpenXrApiWrapper::GetStageParameters(XrExtent2Df* stage_bounds, bool OpenXrApiWrapper::GetStageParameters(
gfx::Transform* transform) const { XrExtent2Df* stage_bounds,
gfx::Transform* local_from_stage) const {
DCHECK(stage_bounds); DCHECK(stage_bounds);
DCHECK(transform); DCHECK(local_from_stage);
DCHECK(HasSession()); DCHECK(HasSession());
if (!HasSpace(XR_REFERENCE_SPACE_TYPE_LOCAL)) if (!HasSpace(XR_REFERENCE_SPACE_TYPE_LOCAL))
...@@ -683,25 +686,33 @@ bool OpenXrApiWrapper::GetStageParameters(XrExtent2Df* stage_bounds, ...@@ -683,25 +686,33 @@ bool OpenXrApiWrapper::GetStageParameters(XrExtent2Df* stage_bounds,
if (XR_FAILED(GetStageBounds(stage_bounds))) if (XR_FAILED(GetStageBounds(stage_bounds)))
return false; return false;
XrSpaceLocation location = {XR_TYPE_SPACE_LOCATION}; XrSpaceLocation local_from_stage_location = {XR_TYPE_SPACE_LOCATION};
if (FAILED(xrLocateSpace(local_space_, stage_space_, if (FAILED(xrLocateSpace(local_space_, stage_space_,
frame_state_.predictedDisplayTime, &location)) || frame_state_.predictedDisplayTime,
!(location.locationFlags & XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) || &local_from_stage_location)) ||
!(location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT)) { !(local_from_stage_location.locationFlags &
XR_SPACE_LOCATION_ORIENTATION_VALID_BIT) ||
!(local_from_stage_location.locationFlags &
XR_SPACE_LOCATION_POSITION_VALID_BIT)) {
return false; return false;
} }
// Convert the orientation and translation given by runtime into a // Convert the orientation and translation given by runtime into a
// transformation matrix. // transformation matrix.
gfx::DecomposedTransform seat_to_standing_decomp; gfx::DecomposedTransform local_from_stage_decomp;
seat_to_standing_decomp.quaternion = local_from_stage_decomp.quaternion =
gfx::Quaternion(location.pose.orientation.x, location.pose.orientation.y, gfx::Quaternion(local_from_stage_location.pose.orientation.x,
location.pose.orientation.z, location.pose.orientation.w); local_from_stage_location.pose.orientation.y,
seat_to_standing_decomp.translate[0] = location.pose.position.x; local_from_stage_location.pose.orientation.z,
seat_to_standing_decomp.translate[1] = location.pose.position.y; local_from_stage_location.pose.orientation.w);
seat_to_standing_decomp.translate[2] = location.pose.position.z; local_from_stage_decomp.translate[0] =
local_from_stage_location.pose.position.x;
*transform = gfx::ComposeTransform(seat_to_standing_decomp); 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; return true;
} }
......
...@@ -61,7 +61,7 @@ class OpenXrApiWrapper { ...@@ -61,7 +61,7 @@ class OpenXrApiWrapper {
XrResult GetLuid(LUID* luid) const; XrResult GetLuid(LUID* luid) const;
std::string GetRuntimeName() const; std::string GetRuntimeName() const;
bool GetStageParameters(XrExtent2Df* stage_bounds, bool GetStageParameters(XrExtent2Df* stage_bounds,
gfx::Transform* standing_transform) const; gfx::Transform* local_from_stage) const;
static void DEVICE_VR_EXPORT SetTestHook(VRTestHook* hook); static void DEVICE_VR_EXPORT SetTestHook(VRTestHook* hook);
......
...@@ -237,38 +237,42 @@ mojom::VRPosePtr OpenXrController::GetPose(XrTime predicted_display_time, ...@@ -237,38 +237,42 @@ mojom::VRPosePtr OpenXrController::GetPose(XrTime predicted_display_time,
return nullptr; return nullptr;
} }
XrSpaceVelocity velocity = {XR_TYPE_SPACE_VELOCITY}; XrSpaceVelocity local_from_grip_speed = {XR_TYPE_SPACE_VELOCITY};
XrSpaceLocation space_location = {XR_TYPE_SPACE_LOCATION}; XrSpaceLocation local_from_grip = {XR_TYPE_SPACE_LOCATION};
space_location.next = &velocity; local_from_grip.next = &local_from_grip_speed;
if (XR_FAILED(xrLocateSpace(grip_pose_space_, local_space, if (XR_FAILED(xrLocateSpace(grip_pose_space_, local_space,
predicted_display_time, &space_location))) { predicted_display_time, &local_from_grip))) {
return nullptr; return nullptr;
} }
mojom::VRPosePtr pose = mojom::VRPose::New(); mojom::VRPosePtr pose = mojom::VRPose::New();
if (space_location.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) { if (local_from_grip.locationFlags & XR_SPACE_LOCATION_POSITION_VALID_BIT) {
pose->position = gfx::Point3F(space_location.pose.position.x, pose->position = gfx::Point3F(local_from_grip.pose.position.x,
space_location.pose.position.y, local_from_grip.pose.position.y,
space_location.pose.position.z); 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( pose->orientation = gfx::Quaternion(
space_location.pose.orientation.x, space_location.pose.orientation.y, local_from_grip.pose.orientation.x, local_from_grip.pose.orientation.y,
space_location.pose.orientation.z, space_location.pose.orientation.w); 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 = pose->linear_velocity =
gfx::Vector3dF(velocity.linearVelocity.x, velocity.linearVelocity.y, gfx::Vector3dF(local_from_grip_speed.linearVelocity.x,
velocity.linearVelocity.z); 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 = pose->angular_velocity =
gfx::Vector3dF(velocity.angularVelocity.x, velocity.angularVelocity.y, gfx::Vector3dF(local_from_grip_speed.angularVelocity.x,
velocity.angularVelocity.z); local_from_grip_speed.angularVelocity.y,
local_from_grip_speed.angularVelocity.z);
} }
return pose; return pose;
......
...@@ -265,8 +265,8 @@ bool OpenXrRenderLoop::UpdateEye(const XrView& view, ...@@ -265,8 +265,8 @@ bool OpenXrRenderLoop::UpdateEye(const XrView& view,
bool OpenXrRenderLoop::UpdateStageParameters() { bool OpenXrRenderLoop::UpdateStageParameters() {
bool changed = false; bool changed = false;
XrExtent2Df stage_bounds; XrExtent2Df stage_bounds;
gfx::Transform transform; gfx::Transform local_from_stage;
if (openxr_->GetStageParameters(&stage_bounds, &transform)) { if (openxr_->GetStageParameters(&stage_bounds, &local_from_stage)) {
if (!current_display_info_->stage_parameters) { if (!current_display_info_->stage_parameters) {
current_display_info_->stage_parameters = mojom::VRStageParameters::New(); current_display_info_->stage_parameters = mojom::VRStageParameters::New();
changed = true; changed = true;
...@@ -281,8 +281,9 @@ bool OpenXrRenderLoop::UpdateStageParameters() { ...@@ -281,8 +281,9 @@ bool OpenXrRenderLoop::UpdateStageParameters() {
} }
if (current_display_info_->stage_parameters->standing_transform != if (current_display_info_->stage_parameters->standing_transform !=
transform) { local_from_stage) {
current_display_info_->stage_parameters->standing_transform = transform; current_display_info_->stage_parameters->standing_transform =
local_from_stage;
changed = true; changed = true;
} }
} else if (current_display_info_->stage_parameters) { } 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