summaryrefslogtreecommitdiff
path: root/servers/xr/xr_interface_extension.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'servers/xr/xr_interface_extension.cpp')
-rw-r--r--servers/xr/xr_interface_extension.cpp188
1 files changed, 80 insertions, 108 deletions
diff --git a/servers/xr/xr_interface_extension.cpp b/servers/xr/xr_interface_extension.cpp
index a0bec0f95b..89752b3017 100644
--- a/servers/xr/xr_interface_extension.cpp
+++ b/servers/xr/xr_interface_extension.cpp
@@ -29,9 +29,7 @@
/*************************************************************************/
#include "xr_interface_extension.h"
-#include "servers/rendering/renderer_rd/renderer_storage_rd.h"
#include "servers/rendering/renderer_rd/storage_rd/texture_storage.h"
-#include "servers/rendering/renderer_storage.h"
#include "servers/rendering/rendering_server_globals.h"
void XRInterfaceExtension::_bind_methods() {
@@ -52,6 +50,7 @@ void XRInterfaceExtension::_bind_methods() {
GDVIRTUAL_BIND(_get_camera_transform);
GDVIRTUAL_BIND(_get_transform_for_view, "view", "cam_transform");
GDVIRTUAL_BIND(_get_projection_for_view, "view", "aspect", "z_near", "z_far");
+ GDVIRTUAL_BIND(_get_vrs_texture);
GDVIRTUAL_BIND(_process);
GDVIRTUAL_BIND(_pre_render);
@@ -75,6 +74,15 @@ void XRInterfaceExtension::_bind_methods() {
GDVIRTUAL_BIND(_set_anchor_detection_is_enabled, "enabled");
GDVIRTUAL_BIND(_get_camera_feed_id);
+ // override output methods
+ GDVIRTUAL_BIND(_get_color_texture);
+ GDVIRTUAL_BIND(_get_depth_texture);
+ GDVIRTUAL_BIND(_get_velocity_texture);
+
+ ClassDB::bind_method(D_METHOD("get_color_texture"), &XRInterfaceExtension::get_color_texture);
+ ClassDB::bind_method(D_METHOD("get_depth_texture"), &XRInterfaceExtension::get_depth_texture);
+ ClassDB::bind_method(D_METHOD("get_velocity_texture"), &XRInterfaceExtension::get_velocity_texture);
+
// helper methods
ClassDB::bind_method(D_METHOD("add_blit", "render_target", "src_rect", "dst_rect", "use_layer", "layer", "apply_lens_distortion", "eye_center", "k1", "k2", "upscale", "aspect_ratio"), &XRInterfaceExtension::add_blit);
ClassDB::bind_method(D_METHOD("get_render_target_texture", "render_target"), &XRInterfaceExtension::get_render_target_texture);
@@ -92,33 +100,21 @@ StringName XRInterfaceExtension::get_name() const {
}
uint32_t XRInterfaceExtension::get_capabilities() const {
- uint32_t capabilities;
-
- if (GDVIRTUAL_CALL(_get_capabilities, capabilities)) {
- return capabilities;
- }
-
- return 0;
+ uint32_t capabilities = 0;
+ GDVIRTUAL_CALL(_get_capabilities, capabilities);
+ return capabilities;
}
bool XRInterfaceExtension::is_initialized() const {
- bool initialised = false;
-
- if (GDVIRTUAL_CALL(_is_initialized, initialised)) {
- return initialised;
- }
-
- return false;
+ bool initialized = false;
+ GDVIRTUAL_CALL(_is_initialized, initialized);
+ return initialized;
}
bool XRInterfaceExtension::initialize() {
- bool initialised = false;
-
- if (GDVIRTUAL_CALL(_initialize, initialised)) {
- return initialised;
- }
-
- return false;
+ bool initialized = false;
+ GDVIRTUAL_CALL(_initialize, initialized);
+ return initialized;
}
void XRInterfaceExtension::uninitialize() {
@@ -142,13 +138,9 @@ PackedStringArray XRInterfaceExtension::get_suggested_pose_names(const StringNam
}
XRInterface::TrackingStatus XRInterfaceExtension::get_tracking_status() const {
- uint32_t status;
-
- if (GDVIRTUAL_CALL(_get_tracking_status, status)) {
- return TrackingStatus(status);
- }
-
- return XR_UNKNOWN_TRACKING;
+ uint32_t status = XR_UNKNOWN_TRACKING;
+ GDVIRTUAL_CALL(_get_tracking_status, status);
+ return TrackingStatus(status);
}
void XRInterfaceExtension::trigger_haptic_pulse(const String &p_action_name, const StringName &p_tracker_name, double p_frequency, double p_amplitude, double p_duration_sec, double p_delay_sec) {
@@ -156,52 +148,34 @@ void XRInterfaceExtension::trigger_haptic_pulse(const String &p_action_name, con
}
bool XRInterfaceExtension::supports_play_area_mode(XRInterface::PlayAreaMode p_mode) {
- bool is_supported;
-
- if (GDVIRTUAL_CALL(_supports_play_area_mode, p_mode, is_supported)) {
- return is_supported;
- }
-
- return false;
+ bool is_supported = false;
+ GDVIRTUAL_CALL(_supports_play_area_mode, p_mode, is_supported);
+ return is_supported;
}
XRInterface::PlayAreaMode XRInterfaceExtension::get_play_area_mode() const {
- uint32_t mode;
-
- if (GDVIRTUAL_CALL(_get_play_area_mode, mode)) {
- return XRInterface::PlayAreaMode(mode);
- }
-
- return XRInterface::XR_PLAY_AREA_UNKNOWN;
+ uint32_t mode = XR_PLAY_AREA_UNKNOWN;
+ GDVIRTUAL_CALL(_get_play_area_mode, mode);
+ return XRInterface::PlayAreaMode(mode);
}
bool XRInterfaceExtension::set_play_area_mode(XRInterface::PlayAreaMode p_mode) {
- bool success;
-
- if (GDVIRTUAL_CALL(_set_play_area_mode, p_mode, success)) {
- return success;
- }
-
- return false;
+ bool success = false;
+ GDVIRTUAL_CALL(_set_play_area_mode, p_mode, success);
+ return success;
}
PackedVector3Array XRInterfaceExtension::get_play_area() const {
PackedVector3Array arr;
-
GDVIRTUAL_CALL(_get_play_area, arr);
-
return arr;
}
/** these will only be implemented on AR interfaces, so we want dummies for VR **/
bool XRInterfaceExtension::get_anchor_detection_is_enabled() const {
- bool enabled;
-
- if (GDVIRTUAL_CALL(_get_anchor_detection_is_enabled, enabled)) {
- return enabled;
- }
-
- return false;
+ bool enabled = false;
+ GDVIRTUAL_CALL(_get_anchor_detection_is_enabled, enabled);
+ return enabled;
}
void XRInterfaceExtension::set_anchor_detection_is_enabled(bool p_enable) {
@@ -210,69 +184,76 @@ void XRInterfaceExtension::set_anchor_detection_is_enabled(bool p_enable) {
}
int XRInterfaceExtension::get_camera_feed_id() {
- int feed_id;
-
- if (GDVIRTUAL_CALL(_get_camera_feed_id, feed_id)) {
- return feed_id;
- }
-
- return 0;
+ int feed_id = 0;
+ GDVIRTUAL_CALL(_get_camera_feed_id, feed_id);
+ return feed_id;
}
Size2 XRInterfaceExtension::get_render_target_size() {
Size2 size;
-
- if (GDVIRTUAL_CALL(_get_render_target_size, size)) {
- return size;
- }
-
- return Size2(0, 0);
+ GDVIRTUAL_CALL(_get_render_target_size, size);
+ return size;
}
uint32_t XRInterfaceExtension::get_view_count() {
- uint32_t view_count;
-
- if (GDVIRTUAL_CALL(_get_view_count, view_count)) {
- return view_count;
- }
-
- return 1;
+ uint32_t view_count = 1;
+ GDVIRTUAL_CALL(_get_view_count, view_count);
+ return view_count;
}
Transform3D XRInterfaceExtension::get_camera_transform() {
Transform3D transform;
-
- if (GDVIRTUAL_CALL(_get_camera_transform, transform)) {
- return transform;
- }
-
- return Transform3D();
+ GDVIRTUAL_CALL(_get_camera_transform, transform);
+ return transform;
}
Transform3D XRInterfaceExtension::get_transform_for_view(uint32_t p_view, const Transform3D &p_cam_transform) {
Transform3D transform;
-
- if (GDVIRTUAL_CALL(_get_transform_for_view, p_view, p_cam_transform, transform)) {
- return transform;
- }
-
- return Transform3D();
+ GDVIRTUAL_CALL(_get_transform_for_view, p_view, p_cam_transform, transform);
+ return transform;
}
-CameraMatrix XRInterfaceExtension::get_projection_for_view(uint32_t p_view, double p_aspect, double p_z_near, double p_z_far) {
- CameraMatrix cm;
+Projection XRInterfaceExtension::get_projection_for_view(uint32_t p_view, double p_aspect, double p_z_near, double p_z_far) {
+ Projection cm;
PackedFloat64Array arr;
if (GDVIRTUAL_CALL(_get_projection_for_view, p_view, p_aspect, p_z_near, p_z_far, arr)) {
- ERR_FAIL_COND_V_MSG(arr.size() != 16, CameraMatrix(), "Projection matrix must contain 16 floats");
- real_t *m = (real_t *)cm.matrix;
+ ERR_FAIL_COND_V_MSG(arr.size() != 16, Projection(), "Projection matrix must contain 16 floats");
+ real_t *m = (real_t *)cm.columns;
for (int i = 0; i < 16; i++) {
m[i] = arr[i];
}
return cm;
}
- return CameraMatrix();
+ return Projection();
+}
+
+RID XRInterfaceExtension::get_vrs_texture() {
+ RID vrs_texture;
+ if (GDVIRTUAL_CALL(_get_vrs_texture, vrs_texture)) {
+ return vrs_texture;
+ } else {
+ return XRInterface::get_vrs_texture();
+ }
+}
+
+RID XRInterfaceExtension::get_color_texture() {
+ RID texture;
+ GDVIRTUAL_CALL(_get_color_texture, texture);
+ return texture;
+}
+
+RID XRInterfaceExtension::get_depth_texture() {
+ RID texture;
+ GDVIRTUAL_CALL(_get_depth_texture, texture);
+ return texture;
+}
+
+RID XRInterfaceExtension::get_velocity_texture() {
+ RID texture;
+ GDVIRTUAL_CALL(_get_velocity_texture, texture);
+ return texture;
}
void XRInterfaceExtension::add_blit(RID p_render_target, Rect2 p_src_rect, Rect2i p_dst_rect, bool p_use_layer, uint32_t p_layer, bool p_apply_lens_distortion, Vector2 p_eye_center, double p_k1, double p_k2, double p_upscale, double p_aspect_ratio) {
@@ -307,13 +288,8 @@ void XRInterfaceExtension::pre_render() {
bool XRInterfaceExtension::pre_draw_viewport(RID p_render_target) {
bool do_render = true;
-
- if (GDVIRTUAL_CALL(_pre_draw_viewport, p_render_target, do_render)) {
- return do_render;
- } else {
- // if not implemented we're returning true
- return true;
- }
+ GDVIRTUAL_CALL(_pre_draw_viewport, p_render_target, do_render);
+ return do_render; // If not implemented we're returning true.
}
Vector<BlitToScreen> XRInterfaceExtension::post_draw_viewport(RID p_render_target, const Rect2 &p_screen_rect) {
@@ -350,9 +326,5 @@ RID XRInterfaceExtension::get_render_target_texture(RID p_render_target) {
RID XRInterfaceExtension::get_render_target_depth(RID p_render_target) {
// TODO implement this, the problem is that our depth texture isn't part of our render target as it is used for 3D rendering only
// but we don't have access to our render buffers from here....
- RendererSceneRenderRD * rd_scene = ?????;
- ERR_FAIL_NULL_V_MSG(rd_scene, RID(), "Renderer scene render not setup");
-
- return rd_scene->render_buffers_get_depth_texture(????????????);
}
*/