MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

LinePointer shows overshooted after teleport

Open Alexees opened this issue 7 years ago • 10 comments

Overview

The straight LinePointer does overshoot for one frame when reappearing after the teleport arch hides

Expected Behavior

LinePointer is correct

Actual Behavior

LinePointer overshoots

Steps to reproduce

  • show the teleport arch
  • move the controller a little
  • stop teleport

notice how the overshoot reliably lies in extended direction of the controller movement

Unity Editor Version

2018.3.7f1

Mixed Reality Toolkit Release Version

mrtk_development

Alexees avatar Mar 07 '19 13:03 Alexees

Could please we get some screenshots to compare the differences?

StephenHodgson avatar Mar 08 '19 16:03 StephenHodgson

Sure, here you go:

  1. shows the initiation of the Teleport (notice the cup is in view)
  2. shows the release of the teleport a little to the left of the initiating position (cup not visible anymore) The straight beam is clearly off, as if the whole controller motion was extrapolated in that direction. Start position, endposition and therefore the angle of the beam relative to the controller orientation all look like that
  3. is the frame after that where the controller is totally fine again.

I guess it's a race condition of visibility and positioning in Update or something. Funny though, that the beam is updated to a position not encountered before.

The beam always appears in an extended position of the movement of the controller.

Teleport_Initiate Teleport_FrameOfReturn Teleport_FrameAfterReturn

Alexees avatar Mar 11 '19 10:03 Alexees

@StephenHodgson this problem does not happen when BaseMixedRealityLineDataProvider is configured to use the transform provided. The default case is using local matrix, which is set too late and wrong for some reason. Investigating further

Alexees avatar Mar 11 '19 11:03 Alexees

Ok I think I know what's happening. The matrix is Updated in OnEnable, Update and OnValidate. The Motion Controller is moved during Update of the MixedRealityToolkit. This means we have a race condition here. The controller could be repositioned after the matrix has been updated. Since the LineRenderer updates after the two and uses the matrix it's an overshooted version.

Alexees avatar Mar 11 '19 11:03 Alexees

So currenty the thing is the following: The Controller, it's matrix and the LineRenderer all had independent Updates, hence race conditions (I fixed the LineRenderer to update in LateUpdate). Ordering Controller and matrix update is the currently left task here.

Alexees avatar Mar 11 '19 11:03 Alexees

I suspect that for this to be bullet-proof the matrix will need to be refreshed during Update AND during LateUpdate, and script execution time will have to be set to take place very early.

Railboy avatar Mar 11 '19 17:03 Railboy

Great investigation @Alexees.

StephenHodgson avatar Mar 11 '19 19:03 StephenHodgson

@Railboy I disagree. The matrix should be updated once after the motion controller has moved during the frame. The movement is initially realised by the MixedRealityToolkit and it's services (not sure which one right now). I think positioning and matrix saving should be done in one go. The matrix is currently saved in OnValidate, Update and OnEnable, which already looks kind of dumb 😛

Alexees avatar Mar 12 '19 21:03 Alexees

@StephenHodgson @Railboy I have the situation layed out and need a hint how to solve it:

  • MixedRealityInputSystem Update: updates pointers and motion controller visuals via class ControllerPoseSynchronizer : InputSystemGlobalListener
  • BaseMixedRealityLineRenderer LateUpdate: updates the LineRenderer based on a BaseMixedRealityLineDataProvider
  • BaseMixedRealityLineDataProvider Update: updates its internal matrix

to resolve the Update issue between controller Position and DataProvider I wanted to derive the DataProvider from InputSystemGlobalListener as well, so it would get updated the same as the visualizers and pointers. Unfortunately the InputSystemGlobalListener in is MRTK.Services namespace and LineRenderers and DataProviders are directly part of the MRTK namespace, hence wrong dependency direction. This would solve the problem the easiest.

Since all relevant components are on the same gameobject another solution could be to introduce a cross reference from BaseMixedRealityLineDataProvider to BaseControllerPointer, to get an update whenever it updates.

What do you think?

Alexees avatar Mar 13 '19 08:03 Alexees

Closing myself as #3612 is also closed and it doesn't look like this problem is still there

Alexees avatar Sep 28 '19 13:09 Alexees