From 82be475a8548db69aa8a8447d4466b1a29821b55 Mon Sep 17 00:00:00 2001 From: David Snopek Date: Sun, 22 Jan 2023 15:41:14 -0600 Subject: [PATCH] Correctly apply world_scale in WebXR --- modules/webxr/webxr_interface_js.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp index a26d9d9636c..9824a3d6969 100644 --- a/modules/webxr/webxr_interface_js.cpp +++ b/modules/webxr/webxr_interface_js.cpp @@ -334,13 +334,12 @@ Transform WebXRInterfaceJS::get_transform_for_eye(ARVRInterface::Eyes p_eye, con ERR_FAIL_NULL_V(arvr_server, transform_for_eye); float *js_matrix = godot_webxr_get_transform_for_eye(p_eye); - if (!initialized || js_matrix == nullptr) { - transform_for_eye = p_cam_transform; - return transform_for_eye; - } + if (js_matrix != nullptr) { + transform_for_eye = _js_matrix_to_transform(js_matrix); + free(js_matrix); - transform_for_eye = _js_matrix_to_transform(js_matrix); - free(js_matrix); + transform_for_eye.origin *= arvr_server->get_world_scale(); + } return p_cam_transform * arvr_server->get_reference_frame() * transform_for_eye; }; @@ -420,7 +419,7 @@ void WebXRInterfaceJS::_update_tracker(int p_controller_id) { float *tracker_matrix = godot_webxr_get_controller_transform(p_controller_id); if (tracker_matrix) { Transform transform = _js_matrix_to_transform(tracker_matrix); - tracker->set_position(transform.origin); + tracker->set_rw_position(transform.origin); tracker->set_orientation(transform.basis); free(tracker_matrix); }