Commit a1da00d3 authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Remove unused VRPose attributes

Removes the unused linear/angular acceleration/velocity attributes from
VRPose.  These attributes were used for the head pose in WebVr, but are
not used in WebXr.

Also cleans up some WMR code that calculated similar values for the old
WebVr gamepad which was previously removed.

Bug: 1017843
Change-Id: Ie5c4259068c3c3b98d0eae4ab71fe92ffac76e86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1903617Reviewed-by: default avatarBrandon Jones <bajones@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714067}
parent 6b53051c
...@@ -18,63 +18,6 @@ namespace { ...@@ -18,63 +18,6 @@ namespace {
// exposed, use that instead (it defaults to 50ms on most platforms). // exposed, use that instead (it defaults to 50ms on most platforms).
static constexpr int64_t kPredictionTimeWithoutVsyncNanos = 50000000; static constexpr int64_t kPredictionTimeWithoutVsyncNanos = 50000000;
// Time offset used for calculating angular velocity from a pair of predicted
// poses. The precise value shouldn't matter as long as it's nonzero and much
// less than a frame.
static constexpr int64_t kAngularVelocityEpsilonNanos = 1000000;
gfx::Vector3dF GetAngularVelocityFromPoses(gfx::Transform head_mat,
gfx::Transform head_mat_2,
double epsilon_seconds) {
// The angular velocity is a 3-element vector pointing along the rotation
// axis with magnitude equal to rotation speed in radians/second, expressed
// in the seated frame of reference.
//
// The 1.1 spec isn't very clear on details, clarification requested in
// https://github.com/w3c/webvr/issues/212 . For now, assuming that we
// want a vector in the sitting reference frame.
//
// Assuming that pose prediction is simply based on adding a time * angular
// velocity rotation to the pose, we can approximate the angular velocity
// from the difference between two successive poses. This is a first order
// estimate that assumes small enough rotations so that we can do linear
// approximation.
//
// See:
// https://en.wikipedia.org/wiki/Angular_velocity#Calculation_from_the_orientation_matrix
gfx::Transform delta_mat;
gfx::Transform inverse_head_mat;
// Calculate difference matrix, and inverse head matrix rotation.
// For the inverse rotation, just transpose the 3x3 subsection.
//
// Assume that epsilon is nonzero since it's based on a compile-time constant
// provided by the caller.
for (int j = 0; j < 3; ++j) {
for (int i = 0; i < 3; ++i) {
delta_mat.matrix().set(
j, i,
(head_mat_2.matrix().get(j, i) - head_mat.matrix().get(j, i)) /
epsilon_seconds);
inverse_head_mat.matrix().set(j, i, head_mat.matrix().get(i, j));
}
delta_mat.matrix().set(j, 3, 0);
delta_mat.matrix().set(3, j, 0);
inverse_head_mat.matrix().set(j, 3, 0);
inverse_head_mat.matrix().set(3, j, 0);
}
delta_mat.matrix().set(3, 3, 1);
inverse_head_mat.matrix().set(3, 3, 1);
gfx::Transform omega_mat = delta_mat * inverse_head_mat;
gfx::Vector3dF omega_vec(-omega_mat.matrix().get(2, 1),
omega_mat.matrix().get(2, 0),
-omega_mat.matrix().get(1, 0));
// Rotate by inverse head matrix to bring into seated space.
inverse_head_mat.TransformVector(&omega_vec);
return omega_vec;
}
} // namespace } // namespace
/* static */ /* static */
...@@ -139,18 +82,6 @@ mojom::VRPosePtr GvrDelegate::GetVRPosePtrWithNeckModel( ...@@ -139,18 +82,6 @@ mojom::VRPosePtr GvrDelegate::GetVRPosePtrWithNeckModel(
mojom::VRPosePtr pose = GvrDelegate::VRPosePtrFromGvrPose(*head_mat_ptr); mojom::VRPosePtr pose = GvrDelegate::VRPosePtrFromGvrPose(*head_mat_ptr);
// Get a second pose a bit later to calculate angular velocity.
target_time.monotonic_system_time_nanos += kAngularVelocityEpsilonNanos;
gvr::Mat4f gvr_head_mat_2 =
gvr_api->GetHeadSpaceFromStartSpaceRotation(target_time);
gfx::Transform head_mat_2;
gvr_utils::GvrMatToTransform(gvr_head_mat_2, &head_mat_2);
// Add headset angular velocity to the pose.
double epsilon_seconds = kAngularVelocityEpsilonNanos * 1e-9;
pose->angular_velocity =
GetAngularVelocityFromPoses(*head_mat_ptr, head_mat_2, epsilon_seconds);
// The position is emulated unless the current tracking status is 6DoF and is // The position is emulated unless the current tracking status is 6DoF and is
// not still initializing or invalid. // not still initializing or invalid.
pose->emulated_position = true; pose->emulated_position = true;
......
...@@ -33,13 +33,6 @@ TypeConverter<device::mojom::VRPosePtr, vr::TrackedDevicePose_t>::Convert( ...@@ -33,13 +33,6 @@ TypeConverter<device::mojom::VRPosePtr, vr::TrackedDevicePose_t>::Convert(
} }
pose->position->SetPoint(m[0][3], m[1][3], m[2][3]); pose->position->SetPoint(m[0][3], m[1][3], m[2][3]);
pose->linear_velocity =
gfx::Vector3dF(hmd_pose.vVelocity.v[0], hmd_pose.vVelocity.v[1],
hmd_pose.vVelocity.v[2]);
pose->angular_velocity = gfx::Vector3dF(hmd_pose.vAngularVelocity.v[0],
hmd_pose.vAngularVelocity.v[1],
hmd_pose.vAngularVelocity.v[2]);
} }
return pose; return pose;
......
...@@ -198,12 +198,6 @@ struct VRPose { ...@@ -198,12 +198,6 @@ struct VRPose {
// False when position is based on sensors tracking a 6DoF pose. // False when position is based on sensors tracking a 6DoF pose.
bool emulated_position; bool emulated_position;
// Velocity/Acceleration is in global coordinates, as rad/s.
gfx.mojom.Vector3dF? angular_velocity;
gfx.mojom.Vector3dF? linear_velocity;
gfx.mojom.Vector3dF? angular_acceleration;
gfx.mojom.Vector3dF? linear_acceleration;
// For WebXR sessions only, reports the state of all active input devices // For WebXR sessions only, reports the state of all active input devices
// synced with the head pose. // synced with the head pose.
array<XRInputSourceState>? input_state; array<XRInputSourceState>? input_state;
......
...@@ -31,20 +31,6 @@ bool MockWMRInputLocation::TryGetPosition( ...@@ -31,20 +31,6 @@ bool MockWMRInputLocation::TryGetPosition(
return true; return true;
} }
bool MockWMRInputLocation::TryGetVelocity(
ABI::Windows::Foundation::Numerics::Vector3* velocity) const {
DCHECK(velocity);
if (!data_.pose_data.is_valid)
return false;
// We could potentially store a history of poses and calculate the velocity,
// but that is more complicated and doesn't currently provide any benefit for
// tests. So, just report 0s.
velocity->X = 0;
velocity->Y = 0;
velocity->Z = 0;
return true;
}
bool MockWMRInputLocation::TryGetOrientation( bool MockWMRInputLocation::TryGetOrientation(
ABI::Windows::Foundation::Numerics::Quaternion* orientation) const { ABI::Windows::Foundation::Numerics::Quaternion* orientation) const {
DCHECK(orientation); DCHECK(orientation);
...@@ -58,20 +44,6 @@ bool MockWMRInputLocation::TryGetOrientation( ...@@ -58,20 +44,6 @@ bool MockWMRInputLocation::TryGetOrientation(
return true; return true;
} }
bool MockWMRInputLocation::TryGetAngularVelocity(
ABI::Windows::Foundation::Numerics::Vector3* angular_velocity) const {
DCHECK(angular_velocity);
if (!data_.pose_data.is_valid)
return false;
// We could potentially store a history of poses and calculate the angular
// velocity, but that is more complicated and doesn't currently provide any
// benefit for tests. So, just report 0s.
angular_velocity->X = 0;
angular_velocity->Y = 0;
angular_velocity->Z = 0;
return true;
}
bool MockWMRInputLocation::TryGetPositionAccuracy( bool MockWMRInputLocation::TryGetPositionAccuracy(
ABI::Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy* ABI::Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy*
position_accuracy) const { position_accuracy) const {
......
...@@ -17,12 +17,8 @@ class MockWMRInputLocation : public WMRInputLocation { ...@@ -17,12 +17,8 @@ class MockWMRInputLocation : public WMRInputLocation {
bool TryGetPosition( bool TryGetPosition(
ABI::Windows::Foundation::Numerics::Vector3* position) const override; ABI::Windows::Foundation::Numerics::Vector3* position) const override;
bool TryGetVelocity(
ABI::Windows::Foundation::Numerics::Vector3* velocity) const override;
bool TryGetOrientation(ABI::Windows::Foundation::Numerics::Quaternion* bool TryGetOrientation(ABI::Windows::Foundation::Numerics::Quaternion*
orientation) const override; orientation) const override;
bool TryGetAngularVelocity(ABI::Windows::Foundation::Numerics::Vector3*
angular_velocity) const override;
bool TryGetPositionAccuracy(ABI::Windows::UI::Input::Spatial:: bool TryGetPositionAccuracy(ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourcePositionAccuracy* SpatialInteractionSourcePositionAccuracy*
position_accuracy) const override; position_accuracy) const override;
......
...@@ -51,16 +51,6 @@ bool WMRInputLocationImpl::TryGetPosition(WFN::Vector3* position) const { ...@@ -51,16 +51,6 @@ bool WMRInputLocationImpl::TryGetPosition(WFN::Vector3* position) const {
return TryGetValue(ref, position); return TryGetValue(ref, position);
} }
bool WMRInputLocationImpl::TryGetVelocity(WFN::Vector3* velocity) const {
DCHECK(velocity);
if (!location_)
return false;
ComPtr<IReference<WFN::Vector3>> ref;
HRESULT hr = location_->get_Velocity(&ref);
DCHECK(SUCCEEDED(hr));
return TryGetValue(ref, velocity);
}
bool WMRInputLocationImpl::TryGetOrientation( bool WMRInputLocationImpl::TryGetOrientation(
WFN::Quaternion* orientation) const { WFN::Quaternion* orientation) const {
DCHECK(orientation); DCHECK(orientation);
...@@ -72,17 +62,6 @@ bool WMRInputLocationImpl::TryGetOrientation( ...@@ -72,17 +62,6 @@ bool WMRInputLocationImpl::TryGetOrientation(
return TryGetValue(ref, orientation); return TryGetValue(ref, orientation);
} }
bool WMRInputLocationImpl::TryGetAngularVelocity(
WFN::Vector3* angular_velocity) const {
DCHECK(angular_velocity);
if (!location3_)
return false;
ComPtr<IReference<WFN::Vector3>> ref;
HRESULT hr = location3_->get_AngularVelocity(&ref);
DCHECK(SUCCEEDED(hr));
return TryGetValue(ref, angular_velocity);
}
bool WMRInputLocationImpl::TryGetPositionAccuracy( bool WMRInputLocationImpl::TryGetPositionAccuracy(
ABI::Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy* ABI::Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy*
position_accuracy) const { position_accuracy) const {
......
...@@ -16,14 +16,10 @@ class WMRInputLocation { ...@@ -16,14 +16,10 @@ class WMRInputLocation {
virtual bool TryGetPosition( virtual bool TryGetPosition(
ABI::Windows::Foundation::Numerics::Vector3* position) const = 0; ABI::Windows::Foundation::Numerics::Vector3* position) const = 0;
virtual bool TryGetVelocity(
ABI::Windows::Foundation::Numerics::Vector3* velocity) const = 0;
virtual bool TryGetOrientation( virtual bool TryGetOrientation(
ABI::Windows::Foundation::Numerics::Quaternion* orientation) const = 0; ABI::Windows::Foundation::Numerics::Quaternion* orientation) const = 0;
virtual bool TryGetAngularVelocity(
ABI::Windows::Foundation::Numerics::Vector3* angular_velocity) const = 0;
virtual bool TryGetPositionAccuracy( virtual bool TryGetPositionAccuracy(
ABI::Windows::UI::Input::Spatial:: ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourcePositionAccuracy* position_accuracy) SpatialInteractionSourcePositionAccuracy* position_accuracy)
...@@ -41,16 +37,12 @@ class WMRInputLocationImpl : public WMRInputLocation { ...@@ -41,16 +37,12 @@ class WMRInputLocationImpl : public WMRInputLocation {
// Uses ISpatialInteractionSourceLocation. // Uses ISpatialInteractionSourceLocation.
bool TryGetPosition( bool TryGetPosition(
ABI::Windows::Foundation::Numerics::Vector3* position) const override; ABI::Windows::Foundation::Numerics::Vector3* position) const override;
bool TryGetVelocity(
ABI::Windows::Foundation::Numerics::Vector3* velocity) const override;
// Uses ISpatialInteractionSourceLocation2. // Uses ISpatialInteractionSourceLocation2.
bool TryGetOrientation(ABI::Windows::Foundation::Numerics::Quaternion* bool TryGetOrientation(ABI::Windows::Foundation::Numerics::Quaternion*
orientation) const override; orientation) const override;
// Uses ISpatialInteractionSourceLocation3. // Uses ISpatialInteractionSourceLocation3.
bool TryGetAngularVelocity(ABI::Windows::Foundation::Numerics::Vector3*
angular_velocity) const override;
bool TryGetPositionAccuracy(ABI::Windows::UI::Input::Spatial:: bool TryGetPositionAccuracy(ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourcePositionAccuracy* SpatialInteractionSourcePositionAccuracy*
position_accuracy) const override; position_accuracy) const override;
......
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