Commit 00ac7f6b authored by Jacob DeWitt's avatar Jacob DeWitt Committed by Commit Bot

Set emulatedPosition for WMR controllers.

When a controller's PositionAccuracy is "approximate", emulatedPosition
should be true.

Also update a test page to only display the target ray/laser for a
controller when emulatedPosition = false (the controller mesh itself
remains visible). That gives an easy way to know the value of
emulatedPosition while still in VR.

Bug: 1011103
Change-Id: Ie90acc51afd914d1e082be7ddd12643257e9d9cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1842477
Commit-Queue: Jacob DeWitt <jacde@chromium.org>
Reviewed-by: default avatarAlexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703329}
parent 1a4f374b
...@@ -43,6 +43,8 @@ using Handedness = ...@@ -43,6 +43,8 @@ using Handedness =
using PressKind = ABI::Windows::UI::Input::Spatial::SpatialInteractionPressKind; using PressKind = ABI::Windows::UI::Input::Spatial::SpatialInteractionPressKind;
using SourceKind = using SourceKind =
ABI::Windows::UI::Input::Spatial::SpatialInteractionSourceKind; ABI::Windows::UI::Input::Spatial::SpatialInteractionSourceKind;
using PositionAccuracy =
ABI::Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy;
ParsedInputState::ParsedInputState() = default; ParsedInputState::ParsedInputState() = default;
ParsedInputState::~ParsedInputState() = default; ParsedInputState::~ParsedInputState() = default;
...@@ -503,6 +505,7 @@ ParsedInputState MixedRealityInputHelper::ParseWindowsSourceState( ...@@ -503,6 +505,7 @@ ParsedInputState MixedRealityInputHelper::ParseWindowsSourceState(
// Voice input is always untracked. // Voice input is always untracked.
gfx::Transform origin_from_grip; gfx::Transform origin_from_grip;
bool is_tracked = false; bool is_tracked = false;
bool emulated_position = false;
if (is_controller) { if (is_controller) {
input_state.button_data = ParseButtonState(state); input_state.button_data = ParseButtonState(state);
std::unique_ptr<WMRInputLocation> location_in_origin = std::unique_ptr<WMRInputLocation> location_in_origin =
...@@ -516,6 +519,15 @@ ParsedInputState MixedRealityInputHelper::ParseWindowsSourceState( ...@@ -516,6 +519,15 @@ ParsedInputState MixedRealityInputHelper::ParseWindowsSourceState(
is_tracked = true; is_tracked = true;
} }
PositionAccuracy position_accuracy;
if (location_in_origin->TryGetPositionAccuracy(&position_accuracy) &&
(position_accuracy ==
PositionAccuracy::
SpatialInteractionSourcePositionAccuracy_Approximate)) {
// Controller lost precise tracking or has its position estimated.
emulated_position = true;
}
input_state.gamepad_pose = gamepad_pose; input_state.gamepad_pose = gamepad_pose;
} }
...@@ -552,8 +564,7 @@ ParsedInputState MixedRealityInputHelper::ParseWindowsSourceState( ...@@ -552,8 +564,7 @@ ParsedInputState MixedRealityInputHelper::ParseWindowsSourceState(
device::mojom::XRInputSourceDescriptionPtr description = device::mojom::XRInputSourceDescriptionPtr description =
device::mojom::XRInputSourceDescription::New(); device::mojom::XRInputSourceDescription::New();
// If we've gotten this far we've gotten the real position. source_state->emulated_position = emulated_position;
source_state->emulated_position = false;
description->pointer_offset = grip_from_pointer; description->pointer_offset = grip_from_pointer;
if (is_voice) { if (is_voice) {
......
...@@ -72,4 +72,10 @@ bool MockWMRInputLocation::TryGetAngularVelocity( ...@@ -72,4 +72,10 @@ bool MockWMRInputLocation::TryGetAngularVelocity(
return true; return true;
} }
bool MockWMRInputLocation::TryGetPositionAccuracy(
ABI::Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy*
position_accuracy) const {
return false;
}
} // namespace device } // namespace device
...@@ -23,6 +23,9 @@ class MockWMRInputLocation : public WMRInputLocation { ...@@ -23,6 +23,9 @@ class MockWMRInputLocation : public WMRInputLocation {
orientation) const override; orientation) const override;
bool TryGetAngularVelocity(ABI::Windows::Foundation::Numerics::Vector3* bool TryGetAngularVelocity(ABI::Windows::Foundation::Numerics::Vector3*
angular_velocity) const override; angular_velocity) const override;
bool TryGetPositionAccuracy(ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourcePositionAccuracy*
position_accuracy) const override;
private: private:
ControllerFrameData data_; ControllerFrameData data_;
......
...@@ -83,4 +83,15 @@ bool WMRInputLocationImpl::TryGetAngularVelocity( ...@@ -83,4 +83,15 @@ bool WMRInputLocationImpl::TryGetAngularVelocity(
return TryGetValue(ref, angular_velocity); return TryGetValue(ref, angular_velocity);
} }
bool WMRInputLocationImpl::TryGetPositionAccuracy(
ABI::Windows::UI::Input::Spatial::SpatialInteractionSourcePositionAccuracy*
position_accuracy) const {
DCHECK(position_accuracy);
if (!location3_)
return false;
HRESULT hr = location3_->get_PositionAccuracy(position_accuracy);
DCHECK(SUCCEEDED(hr));
return true;
}
} // namespace device } // namespace device
...@@ -24,6 +24,10 @@ class WMRInputLocation { ...@@ -24,6 +24,10 @@ class WMRInputLocation {
virtual bool TryGetAngularVelocity( virtual bool TryGetAngularVelocity(
ABI::Windows::Foundation::Numerics::Vector3* angular_velocity) const = 0; ABI::Windows::Foundation::Numerics::Vector3* angular_velocity) const = 0;
virtual bool TryGetPositionAccuracy(
ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourcePositionAccuracy* position_accuracy)
const = 0;
}; };
class WMRInputLocationImpl : public WMRInputLocation { class WMRInputLocationImpl : public WMRInputLocation {
...@@ -47,6 +51,9 @@ class WMRInputLocationImpl : public WMRInputLocation { ...@@ -47,6 +51,9 @@ class WMRInputLocationImpl : public WMRInputLocation {
// Uses ISpatialInteractionSourceLocation3. // Uses ISpatialInteractionSourceLocation3.
bool TryGetAngularVelocity(ABI::Windows::Foundation::Numerics::Vector3* bool TryGetAngularVelocity(ABI::Windows::Foundation::Numerics::Vector3*
angular_velocity) const override; angular_velocity) const override;
bool TryGetPositionAccuracy(ABI::Windows::UI::Input::Spatial::
SpatialInteractionSourcePositionAccuracy*
position_accuracy) const override;
private: private:
Microsoft::WRL::ComPtr< Microsoft::WRL::ComPtr<
......
...@@ -219,11 +219,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ...@@ -219,11 +219,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
let pose = frame.getPose(inputSource.targetRaySpace, refSpace); let pose = frame.getPose(inputSource.targetRaySpace, refSpace);
if (pose) { if (pose) {
let targetRay = new XRRay(pose.transform); let targetRay = new XRRay(pose.transform);
if (inputSource.targetRayMode == 'tracked-pointer') { if (inputSource.targetRayMode == 'tracked-pointer' &&
!pose.emulatedPosition) {
// If we have a pointer matrix and the pointer origin is the users // If we have a pointer matrix and the pointer origin is the users
// hand (as opposed to their head or the screen) use it to render // hand (as opposed to their head or the screen) use it to render
// a ray coming out of the input device to indicate the pointer // a ray coming out of the input device to indicate the pointer
// direction. // direction.
// Only show the laser when the position is not emulated, so that
// it's easy to know that value while still in VR.
scene.inputRenderer.addLaserPointer(targetRay); scene.inputRenderer.addLaserPointer(targetRay);
} }
......
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