Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opaque-display-only environment/room #11067

Closed
wants to merge 24 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
560a592
Making reference transform coordinate system explicit
Zee2 Sep 20, 2022
c6236f4
Switching all coordinate transformations to be explicit about rig-loc…
Zee2 Sep 20, 2022
c0e6847
Naming fix
Zee2 Sep 20, 2022
90b8b05
Naming
Zee2 Sep 20, 2022
ffd43bd
Revising based on convo with Kurtis
Zee2 Sep 22, 2022
b30131a
Removing extra properties
Zee2 Sep 22, 2022
502eb29
Refactoring
Zee2 Sep 22, 2022
13510fc
Fixing incorrect coordinate space transformation in PolyfillHandRayPo…
Zee2 Sep 22, 2022
0b723c3
Playspace math refactor
Zee2 Sep 22, 2022
dedbaf2
Lots of simulator fixes
Zee2 Sep 22, 2022
d150b5a
Rearranging rig
Zee2 Sep 27, 2022
1681950
Adjusting HIE scene height
Zee2 Sep 27, 2022
ff63192
SpatialMapping scene update
Zee2 Sep 27, 2022
feac84d
More descriptive spatial mapping info panel
Zee2 Sep 27, 2022
239859a
Adjusting vertical position of all scenes
Zee2 Sep 27, 2022
36ba43b
Merge branch 'mrtk3' into origin_math
Zee2 Sep 28, 2022
3cd449a
Merge branch 'mrtk3' into origin_math
Zee2 Sep 28, 2022
170b77a
Making input sim default to Grab anchor due to new (more accurate) ra…
Zee2 Sep 28, 2022
eda5721
Adding Pose property and constructor to HandJointPose
Zee2 Sep 29, 2022
d021f32
Adding more reasonable overloads/utility methods in PlayspaceUtilities
Zee2 Sep 29, 2022
747e42f
Fixing device pose math in ArticulatedHandController
Zee2 Sep 29, 2022
e65d5b8
Room model
Zee2 Sep 30, 2022
730545b
Adding prefab, visibility script
Zee2 Sep 30, 2022
8817b4d
Prefab + script edits
Zee2 Sep 30, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switching all coordinate transformations to be explicit about rig-loc…
…al space vs floor-offset-relative-space.
Zee2 committed Sep 20, 2022
commit c6236f43b650cdaf400c8223ee119710cf1377c9
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ private void Awake()
/// </summary>
public void SetHandRaysActive(bool value)
{
var handRays = PlayspaceUtilities.ReferenceTransform.GetComponentsInChildren<MRTKRayInteractor>(true);
var handRays = PlayspaceUtilities.Origin.GetComponentsInChildren<MRTKRayInteractor>(true);

foreach (var interactor in handRays)
{
@@ -81,7 +81,7 @@ public void SetHandRaysActive(bool value)
/// </summary>
public void SetGazePinchActive(bool value)
{
var gazePinchInteractors = PlayspaceUtilities.ReferenceTransform.GetComponentsInChildren<GazePinchInteractor>(true);
var gazePinchInteractors = PlayspaceUtilities.Origin.GetComponentsInChildren<GazePinchInteractor>(true);

foreach (var interactor in gazePinchInteractors)
{
Original file line number Diff line number Diff line change
@@ -230,7 +230,7 @@ private void ComputeAttachTransform(IXRSelectInteractable interactable)
if (DevicePoseSource != null && DevicePoseSource.TryGetPose(out Pose devicePose) &&
PinchPoseSource != null && PinchPoseSource.TryGetPose(out Pose pinchPose))
{
rotationToApply = PlayspaceUtilities.ReferenceTransform.rotation * devicePose.rotation;
rotationToApply = PlayspaceUtilities.OriginOffsetTransform.rotation * devicePose.rotation;
if (hasSelection && interactable != null)
{
var pinchCentroid = GetPinchCentroid(interactable);
Original file line number Diff line number Diff line change
@@ -94,12 +94,12 @@ internal class SimulatedController : IDisposable
/// <summary>
/// Returns the current position, in worldspace, of the simulated controller.
/// </summary>
public Vector3 WorldPosition => PlayspaceUtilities.ReferenceTransform.TransformPoint(simulatedControllerState.devicePosition);
public Vector3 WorldPosition => PlayspaceUtilities.OriginOffsetTransform.TransformPoint(simulatedControllerState.devicePosition);

/// <summary>
/// Returns the current rotation, in worldspace, of the simulated controller.
/// </summary>
public Quaternion WorldRotation => PlayspaceUtilities.ReferenceTransform.rotation * simulatedControllerState.deviceRotation;
public Quaternion WorldRotation => PlayspaceUtilities.OriginOffsetTransform.rotation * simulatedControllerState.deviceRotation;

/// <summary>
/// Returns the position of the index finger joint on the simulated device,
@@ -512,8 +512,8 @@ private void SetWorldPose(
{
using (SetWorldPosePerfMarker.Auto())
{
Vector3 rigLocalPosition = PlayspaceUtilities.ReferenceTransform.InverseTransformPoint(position);
Quaternion rigLocalRotation = Quaternion.Inverse(PlayspaceUtilities.ReferenceTransform.rotation) * rotation;
Vector3 rigLocalPosition = PlayspaceUtilities.OriginOffsetTransform.InverseTransformPoint(position);
Quaternion rigLocalRotation = Quaternion.Inverse(PlayspaceUtilities.OriginOffsetTransform.rotation) * rotation;
SetRigLocalPose(rigLocalPosition, rigLocalRotation, rotationMode, shouldUseRayVector);
}
}
@@ -544,7 +544,7 @@ private void SetRigLocalPose(
if (rotationMode == ControllerRotationMode.FaceCamera)
{
Quaternion worldLookAtCamera = Quaternion.LookRotation(Camera.main.transform.position - position);
Quaternion rigLocalLookAtCamera = Quaternion.Inverse(PlayspaceUtilities.ReferenceTransform.rotation) * worldLookAtCamera;
Quaternion rigLocalLookAtCamera = Quaternion.Inverse(PlayspaceUtilities.OriginOffsetTransform.rotation) * worldLookAtCamera;
simulatedControllerState.deviceRotation = Smoothing.SmoothTo(
simulatedControllerState.deviceRotation,
rigLocalLookAtCamera,
@@ -554,7 +554,7 @@ private void SetRigLocalPose(
else if (rotationMode == ControllerRotationMode.CameraAligned)
{
Quaternion worldCameraForward = Quaternion.LookRotation(Camera.main.transform.forward);
Quaternion rigLocalCameraForward = Quaternion.Inverse(PlayspaceUtilities.ReferenceTransform.rotation) * worldCameraForward;
Quaternion rigLocalCameraForward = Quaternion.Inverse(PlayspaceUtilities.OriginOffsetTransform.rotation) * worldCameraForward;
simulatedControllerState.deviceRotation = Smoothing.SmoothTo(
simulatedControllerState.deviceRotation,
rigLocalCameraForward,
@@ -572,10 +572,10 @@ private void SetRigLocalPose(
{
// If prompted to use the ray vector, this is pose is calculated by simulating a hand ray initialized at the device pose.
// This occurs when the simulation mode is set to ArticulatedHand
handRay.Update(PlayspaceUtilities.ReferenceTransform.TransformPoint(simulatedControllerState.devicePosition), -palmPose.Up, Camera.main.transform, Handedness);
handRay.Update(PlayspaceUtilities.OriginOffsetTransform.TransformPoint(simulatedControllerState.devicePosition), -palmPose.Up, Camera.main.transform, Handedness);
Ray ray = handRay.Ray;
simulatedControllerState.pointerPosition = PlayspaceUtilities.ReferenceTransform.InverseTransformPoint(ray.origin);
simulatedControllerState.pointerRotation = Quaternion.Inverse(PlayspaceUtilities.ReferenceTransform.rotation) * Quaternion.LookRotation(ray.direction);
simulatedControllerState.pointerPosition = PlayspaceUtilities.OriginOffsetTransform.InverseTransformPoint(ray.origin);
simulatedControllerState.pointerRotation = Quaternion.Inverse(PlayspaceUtilities.OriginOffsetTransform.rotation) * Quaternion.LookRotation(ray.direction);
}
else
{
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ public void Update(
moveDelta;

simulatedHmdState.trackingState = (int)(InputTrackingState.Position | InputTrackingState.Rotation);
simulatedHmdState.centerEyePosition += Quaternion.Inverse(PlayspaceUtilities.ReferenceTransform.rotation) * Camera.main.transform.rotation * (smoothedMoveDelta * moveSpeed);
simulatedHmdState.centerEyePosition += Quaternion.Inverse(PlayspaceUtilities.OriginOffsetTransform.rotation) * Camera.main.transform.rotation * (smoothedMoveDelta * moveSpeed);
simulatedHmdState.devicePosition = simulatedHmdState.centerEyePosition;

cameraRotation += rotationDelta * rotationSensitivity;
Original file line number Diff line number Diff line change
@@ -96,7 +96,9 @@ public override bool TryGetJoint(TrackedHandJoint joint, out HandJointPose pose)
return false;
}

Transform playspaceTransform = PlayspaceUtilities.ReferenceTransform;
// Here, we use the origin transform (rather than the offset transform)
// as joints are reported in rig-local space.
Transform playspaceTransform = PlayspaceUtilities.OriginTransform;
if (playspaceTransform == null)
{
pose = handJoints[index];
@@ -141,7 +143,9 @@ private void TryCalculateEntireHand()
// Null checks against Unity objects can be expensive, especially when you do
// it 52 times per frame (26 hand joints across 2 hands). Instead, we manage
// the playspace transformation internally for hand joints.
Transform playspaceTransform = PlayspaceUtilities.ReferenceTransform;
// Here, we use the origin transform (rather than the offset transform)
// as joints are reported in rig-local space.
Transform playspaceTransform = PlayspaceUtilities.OriginTransform;
if (playspaceTransform == null)
{
return;
Original file line number Diff line number Diff line change
@@ -95,7 +95,9 @@ public override bool TryGetJoint(TrackedHandJoint joint, out HandJointPose pose)
return false;
}

Transform playspaceTransform = PlayspaceUtilities.ReferenceTransform;
// Here, we use the origin transform (rather than the offset transform)
// as joints are reported in rig-local space.
Transform playspaceTransform = PlayspaceUtilities.OriginTransform;
if (playspaceTransform == null)
{
pose = handJoints[HandsUtils.ConvertToIndex(joint)];
@@ -200,7 +202,9 @@ private void TryCalculateEntireHand()
// Null checks against Unity objects can be expensive, especially when you do
// it 52 times per frame (26 hand joints across 2 hands). Instead, we manage
// the playspace transformation internally for hand joints.
Transform playspaceTransform = PlayspaceUtilities.ReferenceTransform;
// Here, we use the origin transform (rather than the offset transform)
// as joints are reported in rig-local space.
Transform playspaceTransform = PlayspaceUtilities.OriginTransform;
if (playspaceTransform == null)
{
return;
Original file line number Diff line number Diff line change
@@ -333,7 +333,9 @@ private void TryCalculateEntireHand()
// Null checks against Unity objects can be expensive, especially when you do
// it 52 times per frame (26 hand joints across 2 hands). Instead, we manage
// the playspace transformation internally for hand joints.
Transform playspaceTransform = PlayspaceUtilities.ReferenceTransform;
// Here, we use the origin transform (rather than the offset transform)
// as joints are reported in rig-local space.
Transform playspaceTransform = PlayspaceUtilities.OriginTransform;
if (playspaceTransform == null)
{
return;
Original file line number Diff line number Diff line change
@@ -38,9 +38,10 @@ public bool TryGetPose(out Pose pose)
&& rotationAction != null && rotationAction.controls.Count != 0
&& ((InputTrackingState)trackingStateAction.ReadValue<int>() & (InputTrackingState.Position | InputTrackingState.Rotation)) != 0)
{
// Transform the pose into worldspace, as input actions are returned in rig space
pose.position = PlayspaceUtilities.ReferenceTransform.TransformPoint(positionAction.ReadValue<Vector3>());
pose.rotation = PlayspaceUtilities.ReferenceTransform.rotation * rotationAction.ReadValue<Quaternion>();
// Transform the pose into worldspace, as input actions are returned
// in floor-offset-relative coordinates.
pose.position = PlayspaceUtilities.OriginOffsetTransform.TransformPoint(positionAction.ReadValue<Vector3>());
pose.rotation = PlayspaceUtilities.OriginOffsetTransform.rotation * rotationAction.ReadValue<Quaternion>();

return true;
}
Original file line number Diff line number Diff line change
@@ -47,9 +47,9 @@ public override bool TryGetPose(out Pose pose)
Ray ray = handRay.Ray;

// controllerState is in rig-local space, our ray generator works in worldspace!
pose.position = PlayspaceUtilities.ReferenceTransform.InverseTransformPoint(ray.origin);
pose.rotation = Quaternion.LookRotation(PlayspaceUtilities.ReferenceTransform.InverseTransformVector(ray.direction),
PlayspaceUtilities.ReferenceTransform.InverseTransformVector(palm.Up));
pose.position = PlayspaceUtilities.CameraFloorOffsetObject.InverseTransformPoint(ray.origin);
pose.rotation = Quaternion.LookRotation(PlayspaceUtilities.CameraFloorOffsetObject.InverseTransformVector(ray.direction),
PlayspaceUtilities.CameraFloorOffsetObject.InverseTransformVector(palm.Up));
}
else
{