Merge pull request #71880 from dsnopek/webxr-godot3-world-scale

Correctly apply world_scale in WebXR (Godot 3.x)
This commit is contained in:
Rémi Verschelde 2023-01-26 13:21:47 +01:00
commit a8c829cd91
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 6 additions and 7 deletions

View File

@ -334,14 +334,13 @@ Transform WebXRInterfaceJS::get_transform_for_eye(ARVRInterface::Eyes p_eye, con
ERR_FAIL_NULL_V(arvr_server, transform_for_eye); ERR_FAIL_NULL_V(arvr_server, transform_for_eye);
float *js_matrix = godot_webxr_get_transform_for_eye(p_eye); float *js_matrix = godot_webxr_get_transform_for_eye(p_eye);
if (!initialized || js_matrix == nullptr) { if (js_matrix != nullptr) {
transform_for_eye = p_cam_transform;
return transform_for_eye;
}
transform_for_eye = _js_matrix_to_transform(js_matrix); transform_for_eye = _js_matrix_to_transform(js_matrix);
free(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; 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); float *tracker_matrix = godot_webxr_get_controller_transform(p_controller_id);
if (tracker_matrix) { if (tracker_matrix) {
Transform transform = _js_matrix_to_transform(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); tracker->set_orientation(transform.basis);
free(tracker_matrix); free(tracker_matrix);
} }