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 source pose not filtering for source ID #140

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

FejZa
Copy link
Contributor

@FejZa FejZa commented Jul 17, 2024

No description provided.

@SimonDarksideJ
Copy link
Contributor

Curious as to what issue this fixes @FejZa and is this not just going to cause empty events?

It is assumed, perhaps incorrectly? That the event is coming from the controller and having its data tagged to it.

Surely, if you are filtering, the event itself should not be propegated and not just the source data.

@FejZa
Copy link
Contributor Author

FejZa commented Jul 17, 2024

No problem. So the BaseControllerVisualizer is an extension of the ControllerPoseSynchronizer component which we all know and love. The ControllerPoseSynchronizer takes care of positioning an object in 3D space according to the input source pose provided by the controller's service module (native API etc.).

The BaseControllerVisualizer extends the ControllerPoseSynchronizer in a way that it allows to OVERRIDE and take manual control of the visualized controller position. This is used when we e.g. want to lock the controller visualizer to an object we are interacting with (e.g. a ladder, a handle etc.) no matter where the physical controller actually is. Makes sense?

Now an issue arose where we actually still need to know where the PHYSICAL controller is, even if we are not visualizing it there. That is why BaseControllerVisualizer.SourcePose was introduced. This property keeps track of the actual physical location of the controller that is reported to the ControllerPoseSynchronizer.

Now to this fix. The ControllerPoseSynchronizer is implemented in a way where it is a global input listener and will receive source pose updates for ALL found controllers. Thus we need to make sure that we filter within the event handler that it is actually the controller/input source we care about so we can update the BaseControllerVisualizer.SourcePose property with the latest pose of THAT controller.

This is not causing/raising events. This is a handler that simply handles events received but needs to make sure it cares about that event.

/// <inheritdoc />
        public override void OnSourcePoseChanged(SourcePoseEventData<Pose> eventData)
        {
            if (eventData.SourceId == Controller?.InputSource.SourceId)
            {
                SourcePose = eventData.SourceData;
            }

            if (OverrideSourcePose)
            {
                return;
            }

            base.OnSourcePoseChanged(eventData);
        }

If you look into the base.OnSourcePoseChanged(eventData); call you'll notice the ControllerPoseSynchronzer does the exact same check in the base implementation.

Let me know if this helps.

Copy link
Contributor

@SimonDarksideJ SimonDarksideJ left a comment

Choose a reason for hiding this comment

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

Makes sense, great work

@FejZa FejZa merged commit 5ffc2e3 into development Jul 17, 2024
9 checks passed
@FejZa FejZa deleted the feature/fix-smooth-unlock-two-hands branch July 17, 2024 08:01
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