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

Fix Matrix Transpose #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

LittleFinix
Copy link

@LittleFinix LittleFinix commented Sep 11, 2021

The ToHmdMatrix34_t and ToMatrix4x4 methods do not properly transpose their matrices.

Dotnet uses row vectors, whereas ovr uses column vectors. This requires the entire Matrix to be transposed, but the current methods only transpose the last row/column (the translation component).

This isn't noticeable as long as scaling is uniform and rotation only happens along one axis, but does not allow for more complex affine transformations.

This pull request fixes this. However, this is a breaking change, since rotations now happen the other (correct) way around.

@LittleFinix
Copy link
Author

LittleFinix commented Sep 11, 2021

Here's a demonstration:

There's a 'parent' and a 'local' ('test') overlay. The local overlay's matrix is multiplied with the parent to make their transformation relative to the parent.

The steps in this demo are:

  • move local overlay 25cm to the right
  • rotate local 90deg clockwise
  • rotate parent 45deg counter-clockwise
  • move parent 50cm forward (away)

Here's the version with the previous code:
https://user-images.githubusercontent.com/3407997/132946105-52564624-17fd-4f58-8c43-53cea0be6ad8.mp4

And with the new code:
https://user-images.githubusercontent.com/3407997/132946109-91ff89db-692b-4d8c-afd6-32f2b66c3159.mp4

Here's the code for the demo, it requires only OVRSharp and .net 6:
https://gist.github.com/LittleFinix/92c355efd3f935b2d20ffca2ea4c61c3

@tjhorner
Copy link
Member

tjhorner commented Sep 13, 2021

Thanks for the fix (and the detailed explanation/demo)! I'll test this out sometime this week and release this, maybe with a major version bump due to the breaking change.

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