Closed Squareys closed 3 years ago
In order to do that, would the underlying implementation have access to these dual quaternions?
Hi @cabanier!
If by underlying implementation you mean the UA's implementation of the WebXR API, no. It exposes only the position and orientation, creating a dual quaternion from those is close enough to trivial and useful even outside of dual quats.
It already has all the information (see XRPose.transform.orientation
and XRPose.transform.position
), so a batch-getter for saving allocations should be straight forward to implement for the UAs.
We provided the matrix because we assumed that most implementations used matrices under the hood and that for others, the conversion from matrix to position/quaternion was simple enough. Do you have data that this conversion is taking too much time?
I guess not, judging by a very quick-and-dirty benchmark: time measured is converting 24*2 joints with both methods, averaging measurements over 100k repetitions.
fromMat4: 0.025 ms
fromRotationTranslation: 0.006 ms
Benchmark is attached, using glMatrix.
Note, this is on a i7-4790K @ 4 GHz, not sure what the results would equate to on the Oculus Browser and Quest 1 for example, but I guess it's not going to be dramatic.
Thanks for taking the time to benchmark this! Please let us know if you find any bottlenecks. Performance is the biggest issue with WebXR so we're always looking for ways to improve that.
Just want to add another opinion that using matrices for joint transforms does feel awkward given that OpenVR, OpenXR, and VrApi all use plain position and/or orientation. Using matrices requires twice as much storage and requires a matrix decomposition to get to the relevant info. My framework is exposing the data as [ x, y, z, _, qx, qy, qz, qw ]
, so I'm probably stuck doing some sort of conversion no matter what. Anyway, I'm not blocked by the current API but do think the availability of a format other than mat4 would be an improvement.
...Anyway, I'm not blocked by the current API but do think the availability of a format other than mat4 would be an improvement.
That's a reasonable request. Do you have a benchmark that shows this would save a lot of cpu time?
Hi all!
At the moment
fillPoses
(Explainer: https://github.com/immersive-web/webxr-hand-input/blob/main/explainer.md#efficiently-obtaining-hand-poses) added with #37 / #43 can only fill 4x4 Matrices. For Skinning, dual quaternions are quite popular and Wonderland Engine for example runs entirely on dual quaternions even.The options an implementation using dual quaternions has is either to use fillPoses and convert every Matrix to a dual quaternion or avoid fillPoses and use XRJointPose / XRPose - which yields the rotation quaternion through
XRPose.transform.orientation
.While these are both viable and work, they are not great.
I would suggest adding
fillPosePositions()
andfillPoseOrientations
, which would also be more consistent with what is offered by XRRigidTransfom. Maybe renamingfillPoses
tofillPoseMatrices
.Looking forward to your oppinions!
Best, Jonathan