summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-01-25 09:18:48 +0100
committerRémi Verschelde <rverschelde@gmail.com>2023-01-25 09:18:48 +0100
commit893310fbd1272260156c4cfeaa78dc14a7cd7916 (patch)
tree5f3c5a88105de52e0e6a3f75992291872f6f7a11
parentb9bf12e99a222d9a1b8d663399d96462b6c7b064 (diff)
parent9196c470321860b82640aa5dee1ef89ca6582871 (diff)
Merge pull request #71948 from dsnopek/webxr-godot4-world-scale
Correctly apply world_scale in WebXR (Godot 4)
-rw-r--r--modules/webxr/webxr_interface_js.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/modules/webxr/webxr_interface_js.cpp b/modules/webxr/webxr_interface_js.cpp
index 8485c62218..97b2eea4d7 100644
--- a/modules/webxr/webxr_interface_js.cpp
+++ b/modules/webxr/webxr_interface_js.cpp
@@ -347,9 +347,8 @@ Transform3D WebXRInterfaceJS::get_camera_transform() {
ERR_FAIL_NULL_V(xr_server, camera_transform);
if (initialized) {
- float world_scale = xr_server->get_world_scale();
+ double world_scale = xr_server->get_world_scale();
- // just scale our origin point of our transform
Transform3D _head_transform = head_transform;
_head_transform.origin *= world_scale;
@@ -372,13 +371,8 @@ Transform3D WebXRInterfaceJS::get_transform_for_view(uint32_t p_view, const Tran
Transform3D transform_for_view = _js_matrix_to_transform(js_matrix);
- float world_scale = xr_server->get_world_scale();
- // Scale only the center point of our eye transform, so we don't scale the
- // distance between the eyes.
- Transform3D _head_transform = head_transform;
- transform_for_view.origin -= _head_transform.origin;
- _head_transform.origin *= world_scale;
- transform_for_view.origin += _head_transform.origin;
+ double world_scale = xr_server->get_world_scale();
+ transform_for_view.origin *= world_scale;
return p_cam_transform * xr_server->get_reference_frame() * transform_for_view;
};