1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595 | /**************************************************************************/
/* webxr_interface_js.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#ifdef JAVASCRIPT_ENABLED
#include "webxr_interface_js.h"
#include "core/os/input.h"
#include "core/os/os.h"
#include "emscripten.h"
#include "godot_webxr.h"
#include "main/input_default.h"
#include "servers/visual/visual_server_globals.h"
#include <stdlib.h>
void _emwebxr_on_session_supported(char *p_session_mode, int p_supported) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRInterface> interface = arvr_server->find_interface("WebXR");
ERR_FAIL_COND(interface.is_null());
String session_mode = String(p_session_mode);
interface->emit_signal("session_supported", session_mode, p_supported ? true : false);
}
void _emwebxr_on_session_started(char *p_reference_space_type) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRInterface> interface = arvr_server->find_interface("WebXR");
ERR_FAIL_COND(interface.is_null());
String reference_space_type = String(p_reference_space_type);
((WebXRInterfaceJS *)interface.ptr())->_set_reference_space_type(reference_space_type);<--- C-style pointer casting [+]C-style pointer casting detected. C++ offers four different kinds of casts as replacements: static_cast, const_cast, dynamic_cast and reinterpret_cast. A C-style cast could evaluate to any of those automatically, thus it is considered safer if the programmer explicitly states which kind of cast is expected. See also: https://www.securecoding.cert.org/confluence/display/cplusplus/EXP05-CPP.+Do+not+use+C-style+casts.
interface->emit_signal("session_started");
}
void _emwebxr_on_session_ended() {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRInterface> interface = arvr_server->find_interface("WebXR");
ERR_FAIL_COND(interface.is_null());
interface->uninitialize();
interface->emit_signal("session_ended");
}
void _emwebxr_on_session_failed(char *p_message) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRInterface> interface = arvr_server->find_interface("WebXR");
ERR_FAIL_COND(interface.is_null());
interface->uninitialize();
String message = String(p_message);
interface->emit_signal("session_failed", message);
}
void _emwebxr_on_controller_changed() {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRInterface> interface = arvr_server->find_interface("WebXR");
ERR_FAIL_COND(interface.is_null());
((WebXRInterfaceJS *)interface.ptr())->_on_controller_changed();<--- C-style pointer casting [+]C-style pointer casting detected. C++ offers four different kinds of casts as replacements: static_cast, const_cast, dynamic_cast and reinterpret_cast. A C-style cast could evaluate to any of those automatically, thus it is considered safer if the programmer explicitly states which kind of cast is expected. See also: https://www.securecoding.cert.org/confluence/display/cplusplus/EXP05-CPP.+Do+not+use+C-style+casts.
}
extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_input_event(int p_event_type, int p_input_source) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRInterface> interface = arvr_server->find_interface("WebXR");
ERR_FAIL_COND(interface.is_null());
((WebXRInterfaceJS *)interface.ptr())->_on_input_event(p_event_type, p_input_source);<--- C-style pointer casting [+]C-style pointer casting detected. C++ offers four different kinds of casts as replacements: static_cast, const_cast, dynamic_cast and reinterpret_cast. A C-style cast could evaluate to any of those automatically, thus it is considered safer if the programmer explicitly states which kind of cast is expected. See also: https://www.securecoding.cert.org/confluence/display/cplusplus/EXP05-CPP.+Do+not+use+C-style+casts.
}
extern "C" EMSCRIPTEN_KEEPALIVE void _emwebxr_on_simple_event(char *p_signal_name) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRInterface> interface = arvr_server->find_interface("WebXR");
ERR_FAIL_COND(interface.is_null());
StringName signal_name = StringName(p_signal_name);
interface->emit_signal(signal_name);
}
void WebXRInterfaceJS::is_session_supported(const String &p_session_mode) {
godot_webxr_is_session_supported(p_session_mode.utf8().get_data(), &_emwebxr_on_session_supported);
}
void WebXRInterfaceJS::set_session_mode(String p_session_mode) {
session_mode = p_session_mode;
}
String WebXRInterfaceJS::get_session_mode() const {
return session_mode;
}
void WebXRInterfaceJS::set_required_features(String p_required_features) {
required_features = p_required_features;
}
String WebXRInterfaceJS::get_required_features() const {
return required_features;
}
void WebXRInterfaceJS::set_optional_features(String p_optional_features) {
optional_features = p_optional_features;
}
String WebXRInterfaceJS::get_optional_features() const {
return optional_features;
}
void WebXRInterfaceJS::set_requested_reference_space_types(String p_requested_reference_space_types) {
requested_reference_space_types = p_requested_reference_space_types;
}
String WebXRInterfaceJS::get_requested_reference_space_types() const {
return requested_reference_space_types;
}
void WebXRInterfaceJS::_set_reference_space_type(String p_reference_space_type) {
reference_space_type = p_reference_space_type;
}
String WebXRInterfaceJS::get_reference_space_type() const {
return reference_space_type;
}
Ref<ARVRPositionalTracker> WebXRInterfaceJS::get_controller(int p_controller_id) const {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL_V(arvr_server, nullptr);
return arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
}
WebXRInterface::TargetRayMode WebXRInterfaceJS::get_controller_target_ray_mode(int p_controller_id) const {
ERR_FAIL_COND_V(p_controller_id <= 0, WebXRInterface::TARGET_RAY_MODE_UNKNOWN);
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL_V(arvr_server, WebXRInterface::TARGET_RAY_MODE_UNKNOWN);
return (WebXRInterface::TargetRayMode)godot_webxr_get_controller_target_ray_mode(p_controller_id - 1);
}
String WebXRInterfaceJS::get_visibility_state() const {
char *c_str = godot_webxr_get_visibility_state();
if (c_str) {
String visibility_state = String(c_str);
free(c_str);
return visibility_state;
}
return String();
}
PoolVector3Array WebXRInterfaceJS::get_bounds_geometry() const {
PoolVector3Array ret;
int *js_bounds = godot_webxr_get_bounds_geometry();
if (js_bounds) {
ret.resize(js_bounds[0]);
for (int i = 0; i < js_bounds[0]; i++) {
float *js_vector3 = ((float *)js_bounds) + (i * 3) + 1;<--- Casting between signed int * and float * which have an incompatible binary data representation.
ret.set(i, Vector3(js_vector3[0], js_vector3[1], js_vector3[2]));
}
free(js_bounds);
}
return ret;
}
void WebXRInterfaceJS::set_xr_standard_mapping(bool p_xr_standard_mapping) {
xr_standard_mapping = p_xr_standard_mapping;
}
bool WebXRInterfaceJS::get_xr_standard_mapping() const {
return xr_standard_mapping;
}
StringName WebXRInterfaceJS::get_name() const {
return "WebXR";
};
int WebXRInterfaceJS::get_capabilities() const {
return ARVRInterface::ARVR_STEREO | ARVRInterface::ARVR_MONO;
};
bool WebXRInterfaceJS::is_stereo() {
return godot_webxr_get_view_count() == 2;
};
bool WebXRInterfaceJS::is_initialized() const {
return (initialized);
};
bool WebXRInterfaceJS::initialize() {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL_V(arvr_server, false);
if (!initialized) {
if (!godot_webxr_is_supported()) {
return false;
}
if (requested_reference_space_types.size() == 0) {
return false;
}
// make this our primary interface
arvr_server->set_primary_interface(this);
// Clear state variables.
memset(controllers_state, 0, sizeof controllers_state);
memset(touching, 0, sizeof touching);
// Clear render_targetsize to make sure it gets reset to the new size.
// Clearing in uninitialize() doesn't work because a frame can still be
// rendered after it's called, which will fill render_targetsize again.
render_targetsize.width = 0;
render_targetsize.height = 0;
initialized = true;
godot_webxr_initialize(
session_mode.utf8().get_data(),
required_features.utf8().get_data(),
optional_features.utf8().get_data(),
requested_reference_space_types.utf8().get_data(),
&_emwebxr_on_session_started,
&_emwebxr_on_session_ended,
&_emwebxr_on_session_failed,
&_emwebxr_on_controller_changed,
&_emwebxr_on_input_event,
&_emwebxr_on_simple_event);
};
return true;
};
void WebXRInterfaceJS::uninitialize() {
if (initialized) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
if (arvr_server != NULL) {
// no longer our primary interface
arvr_server->clear_primary_interface_if(this);
}
godot_webxr_uninitialize();
reference_space_type = "";
initialized = false;
};
};
Transform WebXRInterfaceJS::_js_matrix_to_transform(float *p_js_matrix) {
Transform transform;
transform.basis.elements[0].x = p_js_matrix[0];
transform.basis.elements[1].x = p_js_matrix[1];
transform.basis.elements[2].x = p_js_matrix[2];
transform.basis.elements[0].y = p_js_matrix[4];
transform.basis.elements[1].y = p_js_matrix[5];
transform.basis.elements[2].y = p_js_matrix[6];
transform.basis.elements[0].z = p_js_matrix[8];
transform.basis.elements[1].z = p_js_matrix[9];
transform.basis.elements[2].z = p_js_matrix[10];
transform.origin.x = p_js_matrix[12];
transform.origin.y = p_js_matrix[13];
transform.origin.z = p_js_matrix[14];
return transform;
}
Size2 WebXRInterfaceJS::get_render_targetsize() {
if (render_targetsize.width != 0 && render_targetsize.height != 0) {
return render_targetsize;
}
int *js_size = godot_webxr_get_render_targetsize();
if (!initialized || js_size == nullptr) {
// As a temporary default (until WebXR is fully initialized), use half the window size.
Size2 temp = OS::get_singleton()->get_window_size();
temp.width /= 2.0;
return temp;
}
render_targetsize.width = js_size[0];
render_targetsize.height = js_size[1];
free(js_size);
return render_targetsize;
};
Transform WebXRInterfaceJS::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
Transform transform_for_eye;
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL_V(arvr_server, transform_for_eye);
float *js_matrix = godot_webxr_get_transform_for_eye(p_eye);
if (js_matrix != nullptr) {
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;
};
CameraMatrix WebXRInterfaceJS::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
CameraMatrix eye;
float *js_matrix = godot_webxr_get_projection_for_eye(p_eye);
if (!initialized || js_matrix == nullptr) {
return eye;
}
int k = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
eye.matrix[i][j] = js_matrix[k++];
}
}
free(js_matrix);
// Copied from godot_oculus_mobile's ovr_mobile_session.cpp
eye.matrix[2][2] = -(p_z_far + p_z_near) / (p_z_far - p_z_near);
eye.matrix[3][2] = -(2.0f * p_z_far * p_z_near) / (p_z_far - p_z_near);
return eye;
}
void WebXRInterfaceJS::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
if (!initialized) {
return;
}
RID texture = VSG::storage->render_target_get_texture(p_render_target);
uint32_t texture_id = VSG::storage->texture_get_texid(texture);
godot_webxr_commit_for_eye(p_eye, texture_id);
};
void WebXRInterfaceJS::process() {
if (initialized) {
godot_webxr_sample_controller_data();
int controller_count = godot_webxr_get_controller_count();
if (controller_count == 0) {
return;
}
for (int i = 0; i < controller_count; i++) {
_update_tracker(i);
}
};
};
void WebXRInterfaceJS::_update_tracker(int p_controller_id) {
ARVRServer *arvr_server = ARVRServer::get_singleton();
ERR_FAIL_NULL(arvr_server);
Ref<ARVRPositionalTracker> tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id + 1);
if (godot_webxr_is_controller_connected(p_controller_id)) {
if (tracker.is_null()) {
tracker.instance();
tracker->set_type(ARVRServer::TRACKER_CONTROLLER);
// Controller id's 0 and 1 are always the left and right hands.
if (p_controller_id < 2) {
tracker->set_name(p_controller_id == 0 ? "Left" : "Right");
tracker->set_hand(p_controller_id == 0 ? ARVRPositionalTracker::TRACKER_LEFT_HAND : ARVRPositionalTracker::TRACKER_RIGHT_HAND);
}
// Use the ids we're giving to our "virtual" gamepads.
tracker->set_joy_id(p_controller_id + 100);
arvr_server->add_tracker(tracker);
}
InputDefault *input = (InputDefault *)Input::get_singleton();
int joy_id = p_controller_id + 100;
float *tracker_matrix = godot_webxr_get_controller_transform(p_controller_id);
if (tracker_matrix) {
Transform transform = _js_matrix_to_transform(tracker_matrix);
tracker->set_rw_position(transform.origin);
tracker->set_orientation(transform.basis);
free(tracker_matrix);
}
int *buttons = godot_webxr_get_controller_buttons(p_controller_id, xr_standard_mapping);
if (buttons) {
for (int i = 0; i < buttons[0]; i++) {
input->joy_button(joy_id, i, *((float *)buttons + (i + 1)));<--- Casting between signed int * and float * which have an incompatible binary data representation.
}
free(buttons);
}
int *axes = godot_webxr_get_controller_axes(p_controller_id, xr_standard_mapping);
if (axes) {
WebXRInterface::TargetRayMode target_ray_mode = (WebXRInterface::TargetRayMode)godot_webxr_get_controller_target_ray_mode(p_controller_id);
if (target_ray_mode == WebXRInterface::TARGET_RAY_MODE_SCREEN) {
int touch_index = _get_touch_index(p_controller_id);
if (touch_index < 5 && touching[touch_index]) {
Vector2 joy_vector = _get_joy_vector_from_axes(axes);
Vector2 previous_joy_vector(input->get_joy_axis(joy_id, 0), input->get_joy_axis(joy_id, 1));
if (!joy_vector.is_equal_approx(previous_joy_vector)) {
Vector2 position = _get_screen_position_from_joy_vector(joy_vector);
Vector2 previous_position = _get_screen_position_from_joy_vector(previous_joy_vector);
Ref<InputEventScreenDrag> event;
event.instance();
event->set_index(touch_index);
event->set_position(position);
event->set_relative(position - previous_position);
input->parse_input_event(event);
}
}
}
for (int i = 0; i < axes[0]; i++) {
float value = *((float *)axes + (i + 1));<--- Casting between signed int * and float * which have an incompatible binary data representation.
input->joy_axis(joy_id, i, value);
}
free(axes);
}
} else if (tracker.is_valid()) {
arvr_server->remove_tracker(tracker);
}
}
void WebXRInterfaceJS::_on_controller_changed() {
// Register "virtual" gamepads with Godot for the ones we get from WebXR.
godot_webxr_sample_controller_data();
for (int i = 0; i < 2; i++) {
bool controller_connected = godot_webxr_is_controller_connected(i);
if (controllers_state[i] != controller_connected) {
Input::get_singleton()->joy_connection_changed(i + 100, controller_connected, i == 0 ? "Left" : "Right", "");
controllers_state[i] = controller_connected;
}
}
}
void WebXRInterfaceJS::_on_input_event(int p_event_type, int p_input_source) {
if (p_event_type == WEBXR_INPUT_EVENT_SELECTSTART || p_event_type == WEBXR_INPUT_EVENT_SELECTEND) {
int target_ray_mode = godot_webxr_get_controller_target_ray_mode(p_input_source);
if (target_ray_mode == WebXRInterface::TARGET_RAY_MODE_SCREEN) {
int touch_index = _get_touch_index(p_input_source);
if (touch_index < 5) {
touching[touch_index] = (p_event_type == WEBXR_INPUT_EVENT_SELECTSTART);
}
int *axes = godot_webxr_get_controller_axes(p_input_source, false);
if (axes) {
Vector2 joy_vector = _get_joy_vector_from_axes(axes);
Vector2 position = _get_screen_position_from_joy_vector(joy_vector);
free(axes);
InputDefault *input = (InputDefault *)Input::get_singleton();
int joy_id = p_input_source + 100;
input->set_joy_axis(joy_id, 0, joy_vector.x);
input->set_joy_axis(joy_id, 1, joy_vector.y);
Ref<InputEventScreenTouch> event;
event.instance();
event->set_index(touch_index);
event->set_position(position);
event->set_pressed(p_event_type == WEBXR_INPUT_EVENT_SELECTSTART);
Input::get_singleton()->parse_input_event(event);
}
}
}
int controller_id = p_input_source + 1;
switch (p_event_type) {
case WEBXR_INPUT_EVENT_SELECTSTART:
emit_signal("selectstart", controller_id);
break;
case WEBXR_INPUT_EVENT_SELECTEND:
emit_signal("selectend", controller_id);
break;
case WEBXR_INPUT_EVENT_SELECT:
emit_signal("select", controller_id);
break;
case WEBXR_INPUT_EVENT_SQUEEZESTART:
emit_signal("squeezestart", controller_id);
break;
case WEBXR_INPUT_EVENT_SQUEEZEEND:
emit_signal("squeezeend", controller_id);
break;
case WEBXR_INPUT_EVENT_SQUEEZE:
emit_signal("squeeze", controller_id);
break;
}
}
int WebXRInterfaceJS::_get_touch_index(int p_input_source) {
int index = 0;
for (int i = 0; i < p_input_source; i++) {
if (godot_webxr_get_controller_target_ray_mode(i) == WebXRInterface::TARGET_RAY_MODE_SCREEN) {
index++;
}
}
return index;
}
Vector2 WebXRInterfaceJS::_get_joy_vector_from_axes(int *p_axes) {
float x_axis = 0.0;
float y_axis = 0.0;
if (p_axes[0] >= 2) {
x_axis = *((float *)p_axes + 1);<--- Casting between signed int * and float * which have an incompatible binary data representation.
y_axis = *((float *)p_axes + 2);<--- Casting between signed int * and float * which have an incompatible binary data representation.
}
return Vector2(x_axis, y_axis);
}
Vector2 WebXRInterfaceJS::_get_screen_position_from_joy_vector(const Vector2 &p_joy_vector) {
SceneTree *scene_tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
if (!scene_tree) {
return Vector2();
}
Viewport *viewport = scene_tree->get_root();
Vector2 position_percentage((p_joy_vector.x + 1.0f) / 2.0f, ((p_joy_vector.y) + 1.0f) / 2.0f);
Vector2 position = viewport->get_size() * position_percentage;
return position;
}
void WebXRInterfaceJS::notification(int p_what) {
// Nothing to do here.
}
WebXRInterfaceJS::WebXRInterfaceJS() {<--- Member variable 'WebXRInterfaceJS::controllers_state' is not initialized in the constructor.<--- Member variable 'WebXRInterfaceJS::touching' is not initialized in the constructor.
initialized = false;
xr_standard_mapping = false;
session_mode = "inline";<--- Variable 'session_mode' is assigned in constructor body. Consider performing initialization in initialization list. [+]When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'session_mode' a value by passing the value to the constructor in the initialization list.
requested_reference_space_types = "local";<--- Variable 'requested_reference_space_types' is assigned in constructor body. Consider performing initialization in initialization list. [+]When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'requested_reference_space_types' a value by passing the value to the constructor in the initialization list.
};
WebXRInterfaceJS::~WebXRInterfaceJS() {
// and make sure we cleanup if we haven't already
if (initialized) {
uninitialize();
};
};
#endif // JAVASCRIPT_ENABLED
|