microsoft / MixedReality-WorldLockingTools-Unity

Unity tools to provide a stable coordinate system anchored to the physical world.
https://microsoft.github.io/MixedReality-WorldLockingTools-Unity/README.html
MIT License
188 stars 45 forks source link

SpacePinMeshVisualizer vertical misalignment after tracking loss #294

Closed ZoltanAX closed 2 years ago

ZoltanAX commented 2 years ago

Hi,

I used the SpacePinMeshVisualizer component in a hangar environment and I found a strange behaviour that occured randomly after a tracking loss event.

Initially the visualizer component correctly displays the triangualation on the ground as expected: image

However after a tracking loss event, the visualization is misaligned vertically to about the height of the users head: image

I could not find a stable reproduction case for this behaviour, but in my experience it occures more frequently in a hangar environment compared to a normal room environment.

Build details:

Do you have any idea what could cause this issue? Thank you!

fast-slow-still commented 2 years ago

I think this was intended as an approximation, which works well in most cases, but falls down in a few.

(Note that the SpacePin visualizer was a generous contribution by the WLT community. I didn't write it, but I've been maintaining it. So there's a lot of guessing of intention here.)

I think the effect the author was going for was to project the visualization of the SpacePin graph onto "the floor". The problem, of course, is that a HoloLens application doesn't generally know where the floor is. So the approximation was used of a vertical offset down from the origin (the origin being the head's position at startup).

However, with loss-of-tracking events, the origin can move in unpredictable ways. WLT and the space pins shield your application from that so that your holograms stay where you put them, but here the origin is used directly.

Another place this falls down is when your space is multiple levels. If you start the application on the second floor, then move to the first floor and start manipulating SpacePins, all of the visualizations will be displayed on the second floor.

I've investigated a few tactics to achieve the same goal, a projection of the visualization onto the floor, but haven't come up with anything satisfactory.

I have, however, come up with an alternative. Rather than trying to project the graph visualization onto a plane, simply offset the visualization nodes vertically from the SpacePins. If the SpacePins are in the right place, the visualization will be in the right place. This has the further benefit that the full 3D positioning of the SpacePins is conveyed.

See the associated PR for details.