Skip to content

add space reset in openvr bindings#148

Open
meir wants to merge 19 commits intowlx-team:mainfrom
meir:space-reset-ovr
Open

add space reset in openvr bindings#148
meir wants to merge 19 commits intowlx-team:mainfrom
meir:space-reset-ovr

Conversation

@meir
Copy link

@meir meir commented Feb 7, 2025

Tried to add the spacedrag bindings in SteamVR yesterday but found out the option for the space reset is missing.

This should add it in SteamVR.

Will have to test when i get back home, ill keep the PR in draft until ive managed to test it.

@meir meir force-pushed the main branch 2 times, most recently from 1ab2c2d to c41b5f4 Compare February 7, 2025 17:29
@meir meir marked this pull request as ready for review February 7, 2025 17:38
@meir
Copy link
Author

meir commented Feb 7, 2025

Tested, works in SteamVR now, however there is a bug where the DragReset puts you under the floor and away from the center for some reason, but that lies in the DragReset method

@galister
Copy link
Collaborator

galister commented Feb 7, 2025

If you want to look further into this, here's some info:

Moving the playspace on SteamVR consists of moving the actual chaperone (the boundary thing that your draw during steamvr room calibration).

When uncalibrated, the chaperone sits at the raw center of the playspace. (This is likely what it resets to as of now.)

Upon room calibration, the chaperone is saved to a file somewhere, and SteamVR will use this calibration for the chaperone on next launch.

Instead of resetting the chaperone by clearing its transform, we want to revert it to the pose that's in the calibration file.

There's an OpenVR method that seems to do just what we need: IVRChaperoneSetup::ReloadFromDisk

@meir
Copy link
Author

meir commented Feb 7, 2025

ahh alright, i'll see tomorrow if i can figure it out, might need to check my actual boundary in SteamVR aswell, i might have it improperly set since OVRAS sometimes broke it and i got sick of fixing it each time it happened

@meir
Copy link
Author

meir commented Feb 8, 2025

couldn't really stop thinking about it, especially since ive recently started learning rust so got a bit too excited about it

but looked into it and ReloadFromDisk wouldnt work since the CommitWorkingCopy would override the saved chaperone, this would technically mean that its overwritten entirely even between restarts, so i changed it out for the previewing the working data so that the saved chaperone stays in tact and does not get ruined

However this does come with another bug, it's only visual and not breaking, but when the preview is showing, the chaperone bounds will just fly away, but the actual playspace goes in the correct position

I'll look later into why this might be happening

@meir
Copy link
Author

meir commented Feb 10, 2025

found the issue with the boundaries flying off, adding an offset to them was breaking it, apparently steamvr already sets the offset when previewing the working set.

@galister
Copy link
Collaborator

i'm not sure what the nix part is about, we're already included in: https://github.com/nix-community/nixpkgs-xr

if it's needed then please make it into its own PR

@meir
Copy link
Author

meir commented Feb 10, 2025

i added the nix flake for local development, the flake in nixpkgs-xr builds a specific git branch, the one i added is to run/build the local code using nix

@meir
Copy link
Author

meir commented Feb 10, 2025

it is probably better to override the wlx package just like nixpkgs-xr does, im not sure if theres another option in nix to do local development using the nixpkgs-xr

@meir
Copy link
Author

meir commented Feb 10, 2025

removed the nix flake and squashed down the commits into one

i'll make a second pr later tonight with additions for a nix flake for local development on NixOS

@meir
Copy link
Author

meir commented Feb 11, 2025

found another issue before this pr gets merged, when moving, any windows shift with you, when resetting they dont, i'll figure this out later today

@meir
Copy link
Author

meir commented Mar 18, 2025

changed how the space drag moves the overlays, added an offset value to the overlay data instead which can in turn be easily reset instead.

Tested in SteamVR, works exactly as expected

@galister
Copy link
Collaborator

Thanks, it's starting to look pretty good.

Some ideas from me:

Let's keep OverlayState's transform as the effective transform. We don't want to calculate an effective transform every time.

We should store the inverse offset so that from the effective transform, we can calculate the original transform (and offset) when needed.

Since these offsets are only needed for SteamVR, let's store them in OpenVrOverlayData. (overlay.data instead of overlay.state)

@meir meir force-pushed the space-reset-ovr branch from c1d4d08 to c9a0f0f Compare April 14, 2025 09:16
@meir meir force-pushed the space-reset-ovr branch from c9a0f0f to 2339789 Compare April 14, 2025 09:31
@meir
Copy link
Author

meir commented Apr 14, 2025

alright, those changed are made, indeed its a better way of handling this.

i'll have to test if this build works, i'll give an update when i have done so

@meir
Copy link
Author

meir commented Apr 16, 2025

tested it out yesterday, everything seems to work like a dream

@galister
Copy link
Collaborator

just pushed a commit to main that will fix your checks

override_width: true,
image_view: Some(self.view.clone()),
image_dirty: true,
offset: Affine3A::IDENTITY,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Lines are only ever used for pointer lasers, and their transforms are recalculated every frame.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it is not, not sure why i added this, i'll fix this after testing the space rotate tonight so i can keep it in the same commit

Comment on lines +75 to +76
overlay.data.offset.translation =
overlay_transform.transform_point3a(overlay.state.transform.translation);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you had a chance to test the behavior of this with a space_rotate'd playspace?

I would wager you might run into issues when rotations are involved.

The equivalent matrix operation would be something along the lines of:
overlay.data.offset = overlay_transform * overlay.state.transform

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, i completely forgot about this, i never really use space rotate, i'll test this out tonight

Copy link
Collaborator

@galister galister Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the things about space rotate is that the space actually rotates around the center of the playspace, but we make it seem as if it's rotating around the HMD.

This is done by counter-adjusting the offset position to keep the HMD in the same position. I believe this will mess stuff up.

At the very least, you'd need to also write the offset from the space_rotate logic.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested this out yesterday, 2 things to note

  1. the reset is indeed broken, so ill update this with some code to account for rotation
  2. the rotation of the overlays seems to be broken aswell, they do move, but dont rotate with the space rotate, so ill look into this aswell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants