Skip to content

Support composition layers anywhere in the tree#114324

Open
m4gr3d wants to merge 1 commit intogodotengine:masterfrom
m4gr3d:support_composition_layers_anywhere_in_tree
Open

Support composition layers anywhere in the tree#114324
m4gr3d wants to merge 1 commit intogodotengine:masterfrom
m4gr3d:support_composition_layers_anywhere_in_tree

Conversation

@m4gr3d
Copy link
Contributor

@m4gr3d m4gr3d commented Dec 24, 2025

No description provided.

@m4gr3d m4gr3d added this to the 4.7 milestone Dec 24, 2025
@m4gr3d m4gr3d force-pushed the support_composition_layers_anywhere_in_tree branch from 87fc625 to 6627795 Compare December 24, 2025 22:50

void OpenXRCompositionLayer::_remove_fallback_node() {
ERR_FAIL_COND(fallback != nullptr);
ERR_FAIL_COND(fallback == nullptr);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dsnopek Looks like the cond check was inverted, or am I misreading this logic?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, at first glance, I think you're right! I wonder why we haven't had issues with this in the past, though

@Repiteo Repiteo modified the milestones: 4.7, 4.x Jan 26, 2026
@m4gr3d m4gr3d force-pushed the support_composition_layers_anywhere_in_tree branch 2 times, most recently from 251cbdc to 599adb2 Compare February 8, 2026 16:02
@m4gr3d m4gr3d force-pushed the support_composition_layers_anywhere_in_tree branch 2 times, most recently from df0c7ec to 9726c97 Compare February 26, 2026 08:32
@m4gr3d m4gr3d modified the milestones: 4.x, 4.7 Feb 26, 2026
@m4gr3d m4gr3d force-pushed the support_composition_layers_anywhere_in_tree branch from 9726c97 to d7490a6 Compare February 26, 2026 08:47
@m4gr3d m4gr3d marked this pull request as ready for review February 26, 2026 11:49
@m4gr3d m4gr3d requested a review from a team as a code owner February 26, 2026 11:49
if (ancestor_camera) {
xf = ancestor_camera->get_global_transform().affine_inverse() * get_global_transform();
} else {
xf = XRServer::get_singleton()->get_world_origin().affine_inverse() * get_global_transform();
Copy link
Contributor

@dsnopek dsnopek Feb 26, 2026

Choose a reason for hiding this comment

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

Because this calculation includes XRServer::get_singleton()->get_world_origin().affine_inverse(), we need to run update_transform() any time the XROrigin3D is moved/rotated as well.

I did some testing, and all was fine if I started the app with the XROrigin3D moved away from the origin and rotated. However, if I moved/rotated the XROrigin3D at runtime (like, when teleporting or snap turning), the composition layers would end up in the wrong spot (which can look really weird with hole punching, because the "hole" will be in the right spot, but the composition layer will be in the wrong spot).

To solve this, I think we'll need either:

  1. A way to get the current XROrigin3D and then watch for it to move/rotate, or
  2. A signal that's emitted every time XRServer::get_singleton()->get_world_orgin() has a new value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with the second approach and added a signal that's emitted when the world origin changes. This mirrors what we already do for the reference frame.

@m4gr3d m4gr3d force-pushed the support_composition_layers_anywhere_in_tree branch from d7490a6 to b389d58 Compare February 27, 2026 05:54
@m4gr3d m4gr3d requested a review from a team as a code owner February 27, 2026 05:54
@m4gr3d m4gr3d requested a review from dsnopek February 27, 2026 05:56
@insanepure
Copy link

I am looking forward for this! Great work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants