Commit 03abfbee authored by Alex Cooper's avatar Alex Cooper Committed by Commit Bot

Clarify XRSpace method's naming scheme

"Space" is a bit ambiguous, in order to remove some of this ambiguity,
explicitly refer to "Native" or "Offset", when referring to transforms.

Also renames OriginOffset to indicate what it is: OffsetFromNative.

Fixed: 1031600
Change-Id: I5863ac8a8c2bd81abd65e4ef17356de2c8891389
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1956109
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722735}
parent d1fa2dfb
......@@ -51,56 +51,50 @@ void XRBoundedReferenceSpace::EnsureUpdated() {
if (display_info && display_info->stage_parameters) {
// Use the transform given by xrDisplayInfo's stage_parameters if available.
bounded_space_from_mojo_ = std::make_unique<TransformationMatrix>(
bounded_native_from_mojo_ = std::make_unique<TransformationMatrix>(
display_info->stage_parameters->standing_transform.matrix());
// In order to ensure that the bounds continue to line up with the user's
// physical environment we need to transform by the inverse of the
// originOffset. TODO(https://crbug.com/1008466): move originOffset to
// separate class? If yes, that class would need to apply a transform
// in the boundsGeometry accessor.
TransformationMatrix bounds_transform = InverseOriginOffsetMatrix();
// physical environment we need to transform them from native to offset.
// Bounds are provided in our native coordinate space.
// TODO(https://crbug.com/1008466): move originOffset to separate class? If
// yes, that class would need to apply a transform in the boundsGeometry
// accessor.
TransformationMatrix offset_from_native = OffsetFromNativeMatrix();
// We may not have bounds if we've lost tracking after being created.
// Whether we have them or not, we need to clear the existing bounds.
bounds_geometry_.clear();
offset_bounds_geometry_.clear();
if (display_info->stage_parameters->bounds) {
for (const auto& bound : *(display_info->stage_parameters->bounds)) {
FloatPoint3D p =
bounds_transform.MapPoint(FloatPoint3D(bound.X(), 0.0, bound.Z()));
bounds_geometry_.push_back(RoundedDOMPoint(p));
FloatPoint3D p = offset_from_native.MapPoint(
FloatPoint3D(bound.X(), 0.0, bound.Z()));
offset_bounds_geometry_.push_back(RoundedDOMPoint(p));
}
}
} else {
// If stage parameters aren't available set the transform to null, which
// will subsequently cause this reference space to return null poses.
bounded_space_from_mojo_.reset();
bounds_geometry_.clear();
bounded_native_from_mojo_.reset();
offset_bounds_geometry_.clear();
}
DispatchEvent(*XRReferenceSpaceEvent::Create(event_type_names::kReset, this));
}
// Gets the pose of the mojo origin in this reference space, corresponding to a
// transform from mojo coordinates to reference space coordinates. Ideally in
// the future this reference space can be used without additional transforms,
// with the various XR backends returning poses already in the right space.
std::unique_ptr<TransformationMatrix> XRBoundedReferenceSpace::SpaceFromMojo() {
std::unique_ptr<TransformationMatrix>
XRBoundedReferenceSpace::NativeFromMojo() {
EnsureUpdated();
// If the reference space has a transform apply it to the base pose and return
// that, otherwise return null.
if (bounded_space_from_mojo_) {
std::unique_ptr<TransformationMatrix> space_from_mojo(
std::make_unique<TransformationMatrix>(*bounded_space_from_mojo_));
return space_from_mojo;
}
if (!bounded_native_from_mojo_)
return nullptr;
return std::make_unique<TransformationMatrix>(*bounded_native_from_mojo_);
}
HeapVector<Member<DOMPointReadOnly>> XRBoundedReferenceSpace::boundsGeometry() {
EnsureUpdated();
return bounds_geometry_;
return offset_bounds_geometry_;
}
base::Optional<XRNativeOriginInformation>
......@@ -109,7 +103,7 @@ XRBoundedReferenceSpace::NativeOrigin() const {
}
void XRBoundedReferenceSpace::Trace(blink::Visitor* visitor) {
visitor->Trace(bounds_geometry_);
visitor->Trace(offset_bounds_geometry_);
XRReferenceSpace::Trace(visitor);
}
......
......@@ -19,7 +19,7 @@ class XRBoundedReferenceSpace final : public XRReferenceSpace {
XRBoundedReferenceSpace(XRSession*, XRRigidTransform*);
~XRBoundedReferenceSpace() override;
std::unique_ptr<TransformationMatrix> SpaceFromMojo() override;
std::unique_ptr<TransformationMatrix> NativeFromMojo() override;
HeapVector<Member<DOMPointReadOnly>> boundsGeometry();
......@@ -35,8 +35,8 @@ class XRBoundedReferenceSpace final : public XRReferenceSpace {
void EnsureUpdated();
HeapVector<Member<DOMPointReadOnly>> bounds_geometry_;
std::unique_ptr<TransformationMatrix> bounded_space_from_mojo_;
HeapVector<Member<DOMPointReadOnly>> offset_bounds_geometry_;
std::unique_ptr<TransformationMatrix> bounded_native_from_mojo_;
unsigned int stage_parameters_id_ = 0;
};
......
......@@ -72,15 +72,16 @@ XRViewerPose* XRFrame::getViewerPose(XRReferenceSpace* reference_space,
session_->LogGetPose();
std::unique_ptr<TransformationMatrix> pose =
reference_space->OffsetSpaceFromViewer();
std::unique_ptr<TransformationMatrix> offset_space_from_viewer =
reference_space->OffsetFromViewer();
// Can only update an XRViewerPose's views with an invertible matrix.
if (!(pose && pose->IsInvertible())) {
if (!(offset_space_from_viewer && offset_space_from_viewer->IsInvertible())) {
return nullptr;
}
return MakeGarbageCollected<XRViewerPose>(session(), *pose);
return MakeGarbageCollected<XRViewerPose>(session(),
*offset_space_from_viewer);
}
XRAnchorSet* XRFrame::trackedAnchors() const {
......
......@@ -14,7 +14,7 @@ namespace blink {
XRGripSpace::XRGripSpace(XRSession* session, XRInputSource* source)
: XRSpace(session), input_source_(source) {}
std::unique_ptr<TransformationMatrix> XRGripSpace::MojoFromSpace() {
std::unique_ptr<TransformationMatrix> XRGripSpace::MojoFromNative() {
// Grip is only available when using tracked pointer for input.
if (input_source_->TargetRayMode() !=
device::mojom::XRTargetRayMode::POINTING) {
......@@ -28,8 +28,8 @@ std::unique_ptr<TransformationMatrix> XRGripSpace::MojoFromSpace() {
*(input_source_->MojoFromInput()));
}
std::unique_ptr<TransformationMatrix> XRGripSpace::SpaceFromMojo() {
return TryInvert(MojoFromSpace());
std::unique_ptr<TransformationMatrix> XRGripSpace::NativeFromMojo() {
return TryInvert(MojoFromNative());
}
bool XRGripSpace::EmulatedPosition() const {
......
......@@ -15,8 +15,8 @@ class XRGripSpace : public XRSpace {
public:
XRGripSpace(XRSession* session, XRInputSource* input_source);
std::unique_ptr<TransformationMatrix> MojoFromSpace() override;
std::unique_ptr<TransformationMatrix> SpaceFromMojo() override;
std::unique_ptr<TransformationMatrix> MojoFromNative() override;
std::unique_ptr<TransformationMatrix> NativeFromMojo() override;
bool EmulatedPosition() const override;
base::Optional<XRNativeOriginInformation> NativeOrigin() const override;
......
......@@ -14,11 +14,11 @@ XRHitTestResult::XRHitTestResult(const TransformationMatrix& pose)
: pose_(std::make_unique<TransformationMatrix>(pose)) {}
XRPose* XRHitTestResult::getPose(XRSpace* relative_to) {
DCHECK(relative_to->MojoFromSpace());
DCHECK(relative_to->MojoFromNative());
auto mojo_from_this = *pose_;
auto mojo_from_other = *relative_to->MojoFromSpace();
auto mojo_from_other = *relative_to->MojoFromNative();
DCHECK(mojo_from_other.IsInvertible());
auto other_from_mojo = mojo_from_other.Inverse();
......
......@@ -21,7 +21,7 @@ class XRObjectSpace : public XRSpace {
explicit XRObjectSpace(XRSession* session, const T* object)
: XRSpace(session), object_(object) {}
std::unique_ptr<TransformationMatrix> MojoFromSpace() override {
std::unique_ptr<TransformationMatrix> MojoFromNative() override {
auto object_from_mojo = object_->poseMatrix();
if (!object_from_mojo.IsInvertible()) {
......@@ -31,8 +31,8 @@ class XRObjectSpace : public XRSpace {
return std::make_unique<TransformationMatrix>(object_from_mojo.Inverse());
}
std::unique_ptr<TransformationMatrix> SpaceFromMojo() final {
return TryInvert(MojoFromSpace());
std::unique_ptr<TransformationMatrix> NativeFromMojo() final {
return TryInvert(MojoFromNative());
}
base::Optional<XRNativeOriginInformation> NativeOrigin() const override {
......
......@@ -48,18 +48,18 @@ XRReferenceSpace::~XRReferenceSpace() = default;
XRPose* XRReferenceSpace::getPose(XRSpace* other_space) {
if (type_ == Type::kTypeViewer) {
std::unique_ptr<TransformationMatrix> other_offsetspace_from_viewer =
other_space->OffsetSpaceFromViewer();
if (!other_offsetspace_from_viewer) {
std::unique_ptr<TransformationMatrix> other_offset_from_viewer =
other_space->OffsetFromViewer();
if (!other_offset_from_viewer) {
return nullptr;
}
auto viewer_from_offset = OriginOffsetMatrix();
auto viewer_from_offset = NativeFromOffsetMatrix();
auto other_offsetspace_from_offset =
*other_offsetspace_from_viewer * viewer_from_offset;
auto other_offset_from_offset =
*other_offset_from_viewer * viewer_from_offset;
return MakeGarbageCollected<XRPose>(other_offsetspace_from_offset,
return MakeGarbageCollected<XRPose>(other_offset_from_offset,
session()->EmulatedPosition());
} else {
return XRSpace::getPose(other_space);
......@@ -83,7 +83,7 @@ void XRReferenceSpace::SetFloorFromMojo() {
display_info_id_ = session()->DisplayInfoPtrId();
}
std::unique_ptr<TransformationMatrix> XRReferenceSpace::SpaceFromMojo() {
std::unique_ptr<TransformationMatrix> XRReferenceSpace::NativeFromMojo() {
auto mojo_from_viewer = session()->MojoFromViewer();
switch (type_) {
case Type::kTypeLocal:
......@@ -121,15 +121,12 @@ std::unique_ptr<TransformationMatrix> XRReferenceSpace::SpaceFromMojo() {
return nullptr;
}
// Returns the refspace-from-viewerspace transform, corresponding to the pose of
// the viewer in this space. This takes the mojo_from_viewer transform (viewer
// pose in mojo space) as input, and left-multiplies space_from_mojo onto that.
std::unique_ptr<TransformationMatrix> XRReferenceSpace::SpaceFromViewer(
std::unique_ptr<TransformationMatrix> XRReferenceSpace::NativeFromViewer(
const TransformationMatrix* mojo_from_viewer) {
if (type_ == Type::kTypeViewer) {
// Special case for viewer space, always return an identity matrix
// explicitly. In theory the default behavior of multiplying SpaceFromMojo *
// MojoFromViewer would be equivalent, but that would likely return an
// explicitly. In theory the default behavior of multiplying NativeFromMojo
// onto MojoFromViewer would be equivalent, but that would likely return an
// almost-identity due to rounding errors.
return std::make_unique<TransformationMatrix>();
}
......@@ -137,23 +134,23 @@ std::unique_ptr<TransformationMatrix> XRReferenceSpace::SpaceFromViewer(
if (!mojo_from_viewer)
return nullptr;
// Return space_from_viewer = space_from_mojo * mojo_from_viewer
auto space_from_viewer = SpaceFromMojo();
if (!space_from_viewer)
// Return native_from_viewer = native_from_mojo * mojo_from_viewer
auto native_from_viewer = NativeFromMojo();
if (!native_from_viewer)
return nullptr;
space_from_viewer->Multiply(*mojo_from_viewer);
return space_from_viewer;
native_from_viewer->Multiply(*mojo_from_viewer);
return native_from_viewer;
}
std::unique_ptr<TransformationMatrix> XRReferenceSpace::MojoFromSpace() {
return TryInvert(SpaceFromMojo());
std::unique_ptr<TransformationMatrix> XRReferenceSpace::MojoFromNative() {
return TryInvert(NativeFromMojo());
}
TransformationMatrix XRReferenceSpace::OriginOffsetMatrix() {
TransformationMatrix XRReferenceSpace::NativeFromOffsetMatrix() {
return origin_offset_->TransformMatrix();
}
TransformationMatrix XRReferenceSpace::InverseOriginOffsetMatrix() {
TransformationMatrix XRReferenceSpace::OffsetFromNativeMatrix() {
return origin_offset_->InverseTransformMatrix();
}
......@@ -164,7 +161,7 @@ XRReferenceSpace::Type XRReferenceSpace::GetType() const {
XRReferenceSpace* XRReferenceSpace::getOffsetReferenceSpace(
XRRigidTransform* additional_offset) {
auto matrix =
OriginOffsetMatrix().Multiply(additional_offset->TransformMatrix());
NativeFromOffsetMatrix().Multiply(additional_offset->TransformMatrix());
auto* result_transform = MakeGarbageCollected<XRRigidTransform>(matrix);
return cloneWithOriginOffset(result_transform);
......
......@@ -36,17 +36,17 @@ class XRReferenceSpace : public XRSpace {
Type type);
~XRReferenceSpace() override;
std::unique_ptr<TransformationMatrix> SpaceFromMojo() override;
std::unique_ptr<TransformationMatrix> SpaceFromViewer(
std::unique_ptr<TransformationMatrix> NativeFromMojo() override;
std::unique_ptr<TransformationMatrix> NativeFromViewer(
const TransformationMatrix* mojo_from_viewer) override;
// MojoFromSpace is final to enforce that children should be returning
// SpaceFromMojo, since this is simply written to always provide the inverse
// of SpaceFromMojo
std::unique_ptr<TransformationMatrix> MojoFromSpace() final;
// MojoFromNative is final to enforce that children should be returning
// NativeFromMojo, since this is simply written to always provide the inverse
// of NativeFromMojo
std::unique_ptr<TransformationMatrix> MojoFromNative() final;
TransformationMatrix OriginOffsetMatrix() override;
TransformationMatrix InverseOriginOffsetMatrix() override;
TransformationMatrix NativeFromOffsetMatrix() override;
TransformationMatrix OffsetFromNativeMatrix() override;
// We override getPose to ensure that the viewer pose in viewer space returns
// the identity pose instead of the result of multiplying inverse matrices.
......
......@@ -576,28 +576,28 @@ ScriptPromise XRSession::CreateAnchor(ScriptState* script_state,
ScriptPromise promise = resolver->Promise();
// Transformation from passed in |space| to mojo space.
std::unique_ptr<TransformationMatrix> mojo_from_space =
space->MojoFromSpace();
std::unique_ptr<TransformationMatrix> mojo_from_native =
space->MojoFromNative();
DVLOG(3) << __func__
<< ": mojo_from_space = " << mojo_from_space->ToString(true);
<< ": mojo_from_native = " << mojo_from_native->ToString(true);
// Matrix will be null if transformation from object space to mojo space is
// not invertible, log & bail out in that case.
if (!mojo_from_space || !mojo_from_space->IsInvertible()) {
if (!mojo_from_native || !mojo_from_native->IsInvertible()) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
kNonInvertibleMatrix);
return ScriptPromise();
}
auto space_from_mojo = mojo_from_space->Inverse();
auto native_from_mojo = mojo_from_native->Inverse();
DVLOG(3) << __func__
<< ": space_from_mojo = " << space_from_mojo.ToString(true);
<< ": native_from_mojo = " << native_from_mojo.ToString(true);
// Transformation from passed in pose to |space|.
auto mojo_from_initial_pose = initial_pose->TransformMatrix();
auto space_from_initial_pose = space_from_mojo * mojo_from_initial_pose;
auto space_from_initial_pose = native_from_mojo * mojo_from_initial_pose;
DVLOG(3) << __func__ << ": mojo_from_initial_pose = "
<< mojo_from_initial_pose.ToString(true);
......@@ -741,11 +741,10 @@ ScriptPromise XRSession::requestHitTestSource(
// 2. Convert the XRRay to be expressed in terms of passed in XRSpace. This
// should only matter for spaces whose transforms are not fully known on the
// device (for example any space containing origin-offset).
TransformationMatrix origin_from_space =
options_init->space()
->OriginOffsetMatrix(); // Null checks not needed since native origin
// wouldn't be set if options_init or space()
// were null.
// Null checks not needed since native origin wouldn't be set if options_init
// or space() were null.
TransformationMatrix native_from_offset =
options_init->space()->NativeFromOffsetMatrix();
if (options_init->hasEntityTypes() && options_init->entityTypes().IsEmpty()) {
exception_state.ThrowDOMException(DOMExceptionCode::kInvalidStateError,
......@@ -756,7 +755,7 @@ ScriptPromise XRSession::requestHitTestSource(
auto entity_types = GetEntityTypesForHitTest(options_init);
DVLOG(3) << __func__
<< ": origin_from_space = " << origin_from_space.ToString(true);
<< ": native_from_offset = " << native_from_offset.ToString(true);
// Transformation from passed in pose to |space|.
......@@ -764,7 +763,7 @@ ScriptPromise XRSession::requestHitTestSource(
? options_init->offsetRay()
: MakeGarbageCollected<XRRay>();
auto space_from_ray = offsetRay->RawMatrix();
auto origin_from_ray = origin_from_space * space_from_ray;
auto origin_from_ray = native_from_offset * space_from_ray;
DVLOG(3) << __func__
<< ": space_from_ray = " << space_from_ray.ToString(true);
......
......@@ -17,28 +17,28 @@ XRSpace::XRSpace(XRSession* session) : session_(session) {}
XRSpace::~XRSpace() = default;
std::unique_ptr<TransformationMatrix> XRSpace::SpaceFromViewer(
std::unique_ptr<TransformationMatrix> XRSpace::NativeFromViewer(
const TransformationMatrix* mojo_from_viewer) {
if (!mojo_from_viewer)
return nullptr;
std::unique_ptr<TransformationMatrix> space_from_mojo = SpaceFromMojo();
if (!space_from_mojo)
std::unique_ptr<TransformationMatrix> native_from_mojo = NativeFromMojo();
if (!native_from_mojo)
return nullptr;
space_from_mojo->Multiply(*mojo_from_viewer);
native_from_mojo->Multiply(*mojo_from_viewer);
// This is now space_from_viewer
return space_from_mojo;
// This is now native_from_viewer
return native_from_mojo;
;
}
TransformationMatrix XRSpace::OriginOffsetMatrix() {
TransformationMatrix XRSpace::NativeFromOffsetMatrix() {
TransformationMatrix identity;
return identity;
}
TransformationMatrix XRSpace::InverseOriginOffsetMatrix() {
TransformationMatrix XRSpace::OffsetFromNativeMatrix() {
TransformationMatrix identity;
return identity;
}
......@@ -57,47 +57,45 @@ bool XRSpace::EmulatedPosition() const {
}
XRPose* XRSpace::getPose(XRSpace* other_space) {
std::unique_ptr<TransformationMatrix> mojo_from_space = MojoFromSpace();
if (!mojo_from_space) {
// Named mojo_from_offset because that is what we will leave it as, though it
// starts mojo_from_native.
std::unique_ptr<TransformationMatrix> mojo_from_offset = MojoFromNative();
if (!mojo_from_offset) {
return nullptr;
}
// Add any origin offset now.
mojo_from_space->Multiply(OriginOffsetMatrix());
mojo_from_offset->Multiply(NativeFromOffsetMatrix());
std::unique_ptr<TransformationMatrix> other_from_mojo =
other_space->SpaceFromMojo();
other_space->NativeFromMojo();
if (!other_from_mojo)
return nullptr;
TransformationMatrix offset_other_from_mojo =
other_space->InverseOriginOffsetMatrix().Multiply(*other_from_mojo);
// Add any origin offset from the other space now.
TransformationMatrix other_offset_from_mojo =
other_space->OffsetFromNativeMatrix().Multiply(*other_from_mojo);
// TODO(crbug.com/969133): Update how EmulatedPosition is determined here once
// spec issue https://github.com/immersive-web/webxr/issues/534 has been
// resolved.
TransformationMatrix other_from_space =
offset_other_from_mojo.Multiply(*mojo_from_space);
TransformationMatrix other_offset_from_offset =
other_offset_from_mojo.Multiply(*mojo_from_offset);
return MakeGarbageCollected<XRPose>(
other_from_space, EmulatedPosition() || other_space->EmulatedPosition());
other_offset_from_offset,
EmulatedPosition() || other_space->EmulatedPosition());
}
std::unique_ptr<TransformationMatrix> XRSpace::OffsetSpaceFromViewer() {
std::unique_ptr<TransformationMatrix> space_from_viewer =
SpaceFromViewer(base::OptionalOrNullptr(session()->MojoFromViewer()));
std::unique_ptr<TransformationMatrix> XRSpace::OffsetFromViewer() {
std::unique_ptr<TransformationMatrix> native_from_viewer =
NativeFromViewer(base::OptionalOrNullptr(session()->MojoFromViewer()));
if (!space_from_viewer) {
if (!native_from_viewer) {
return nullptr;
}
// Account for any changes made to the reference space's origin offset so that
// things like teleportation works.
//
// This is offset_from_viewer = offset_from_space * space_from_viewer,
// where offset_from_viewer = inverse(viewer_from_offset).
// TODO(https://crbug.com/1008466): move originOffset to separate class?
return std::make_unique<TransformationMatrix>(
InverseOriginOffsetMatrix().Multiply(*space_from_viewer));
OffsetFromNativeMatrix().Multiply(*native_from_viewer));
}
ExecutionContext* XRSpace::GetExecutionContext() const {
......
......@@ -32,27 +32,38 @@ class XRSpace : public EventTargetWithInlineData {
~XRSpace() override;
// Gets the pose of this space's native origin in mojo space. This transform
// maps from this space to mojo space (aka device space). Unless noted
// otherwise, all data returned over vr_service.mojom interfaces is expressed
// in mojo space coordinates. Returns nullptr if computing a transform is not
// possible.
virtual std::unique_ptr<TransformationMatrix> MojoFromSpace() = 0;
// Gets the pose of the mojo origin in this reference space, corresponding
// to a transform from mojo coordinates to reference space coordinates.
// Note that it is expected to be the inverse of the above.
virtual std::unique_ptr<TransformationMatrix> SpaceFromMojo() = 0;
// Gets the viewer pose in this space, corresponding to a transform from
// viewer coordinates to this space's coordinates. (The position elements of
// the transformation matrix are the viewer's location in this space's
// coordinates.)
// Prefer this helper method over querying SpaceFromMojo and multiplying
// maps from this space's native origin to mojo space (aka device space).
// Unless noted otherwise, all data returned over vr_service.mojom interfaces
// is expressed in mojo space coordinates.
// Returns nullptr if computing a transform is not possible.
virtual std::unique_ptr<TransformationMatrix> MojoFromNative() = 0;
// Convenience method to try to get the inverse of the above. This will return
// the pose of the mojo origin in this space's native origin.
// Returns nullptr if computing a transform is not possible.
virtual std::unique_ptr<TransformationMatrix> NativeFromMojo() = 0;
// Gets the viewer pose in the native coordinates of this space, corresponding
// to a transform from viewer coordinates to this space's native coordinates.
// (The position elements of the transformation matrix are the viewer's
// location in this space's coordinates.)
// Prefer this helper method over querying NativeFromMojo and multiplying
// on the calling side, as this allows the viewer space to return identity
// instead of something near to, but not quite, identity.
virtual std::unique_ptr<TransformationMatrix> SpaceFromViewer(
// Returns nullptr if computing a transform is not possible.
virtual std::unique_ptr<TransformationMatrix> NativeFromViewer(
const TransformationMatrix* mojo_from_viewer);
// Convenience method for calling NativeFromViewer with the current
// MojoFromViewer of the session associated with this space. This also handles
// the multiplication of OffsetFromNative onto the result of NativeFromViewer.
// Returns nullptr if computing a transform is not possible.
std::unique_ptr<TransformationMatrix> OffsetFromViewer();
// Return origin offset matrix, aka native_origin_from_offset_space.
virtual TransformationMatrix NativeFromOffsetMatrix();
virtual TransformationMatrix OffsetFromNativeMatrix();
// Indicates whether or not the position portion of the native origin of this
// space is emulated.
virtual bool EmulatedPosition() const;
......@@ -61,23 +72,12 @@ class XRSpace : public EventTargetWithInlineData {
// that maps from this space to the other's space, or in other words:
// other_from_this.
virtual XRPose* getPose(XRSpace* other_space);
// Gets the viewer pose in this space, including using an appropriate
// default pose (i.e. if tracking is lost), and applying originOffset
// as applicable. TODO(https://crbug.com/1008466): consider moving
// the originOffset handling to a separate class?
std::unique_ptr<TransformationMatrix> OffsetSpaceFromViewer();
XRSession* session() const { return session_; }
// EventTarget overrides.
ExecutionContext* GetExecutionContext() const override;
const AtomicString& InterfaceName() const override;
// Return origin offset matrix, aka native_origin_from_offset_space.
virtual TransformationMatrix OriginOffsetMatrix();
virtual TransformationMatrix InverseOriginOffsetMatrix();
virtual base::Optional<XRNativeOriginInformation> NativeOrigin() const = 0;
void Trace(blink::Visitor* visitor) override;
......
......@@ -15,7 +15,7 @@ namespace blink {
XRTargetRaySpace::XRTargetRaySpace(XRSession* session, XRInputSource* source)
: XRSpace(session), input_source_(source) {}
std::unique_ptr<TransformationMatrix> XRTargetRaySpace::MojoFromSpace() {
std::unique_ptr<TransformationMatrix> XRTargetRaySpace::MojoFromNative() {
auto mojo_from_viewer = session()->MojoFromViewer();
switch (input_source_->TargetRayMode()) {
case device::mojom::XRTargetRayMode::TAPPING: {
......@@ -49,8 +49,8 @@ std::unique_ptr<TransformationMatrix> XRTargetRaySpace::MojoFromSpace() {
}
}
std::unique_ptr<TransformationMatrix> XRTargetRaySpace::SpaceFromMojo() {
return TryInvert(MojoFromSpace());
std::unique_ptr<TransformationMatrix> XRTargetRaySpace::NativeFromMojo() {
return TryInvert(MojoFromNative());
}
bool XRTargetRaySpace::EmulatedPosition() const {
......
......@@ -15,8 +15,8 @@ class XRTargetRaySpace : public XRSpace {
public:
XRTargetRaySpace(XRSession* session, XRInputSource* input_space);
std::unique_ptr<TransformationMatrix> MojoFromSpace() override;
std::unique_ptr<TransformationMatrix> SpaceFromMojo() override;
std::unique_ptr<TransformationMatrix> MojoFromNative() override;
std::unique_ptr<TransformationMatrix> NativeFromMojo() override;
bool EmulatedPosition() const override;
base::Optional<XRNativeOriginInformation> NativeOrigin() 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