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

[WIP] Fix interpolation in XR #103233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion scene/3d/xr_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,12 @@ void XROrigin3D::_set_current(bool p_enabled, bool p_update_others) {
ERR_FAIL_NULL(xr_server);

xr_server->set_world_origin(get_global_transform());

if (is_physics_interpolated()) {
set_process_internal(true);
}
} else if (is_physics_interpolated()) {
set_process_internal(false);
}

// Check if we need to update our other origin nodes accordingly
Expand Down Expand Up @@ -784,10 +790,16 @@ void XROrigin3D::_notification(int p_what) {

case NOTIFICATION_LOCAL_TRANSFORM_CHANGED:
case NOTIFICATION_TRANSFORM_CHANGED: {
if (current && !Engine::get_singleton()->is_editor_hint()) {
if (current && !Engine::get_singleton()->is_editor_hint() && !is_physics_interpolated_and_enabled()) {
xr_server->set_world_origin(get_global_transform());
}
} break;

case NOTIFICATION_INTERNAL_PROCESS: {
if (current && !Engine::get_singleton()->is_editor_hint() && is_physics_interpolated_and_enabled()) {
xr_server->set_world_origin(get_global_transform_interpolated());
}
} break;
}

if (current) {
Expand All @@ -800,3 +812,9 @@ void XROrigin3D::_notification(int p_what) {
}
}
}

void XROrigin3D::_physics_interpolated_changed() {
if (current && !Engine::get_singleton()->is_editor_hint()) {
set_process_internal(is_physics_interpolated());
}
}
1 change: 1 addition & 0 deletions scene/3d/xr_nodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class XROrigin3D : public Node3D {
protected:
void _notification(int p_what);
static void _bind_methods();
virtual void _physics_interpolated_changed() override;

public:
PackedStringArray get_configuration_warnings() const override;
Expand Down