2017-10-07 13:51:17 +00:00
/*************************************************************************/
/* arvr_interface_gdnative.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
2021-01-01 19:13:46 +00:00
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
2017-10-07 13:51:17 +00:00
/* */
/* 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. */
/*************************************************************************/
# include "arvr_interface_gdnative.h"
# include "main/input_default.h"
# include "servers/arvr/arvr_positional_tracker.h"
2019-02-12 13:23:35 +00:00
# include "servers/visual/visual_server_globals.h"
2017-10-07 13:51:17 +00:00
2019-06-01 13:42:22 +00:00
void ARVRInterfaceGDNative : : _bind_methods ( ) {
ADD_PROPERTY_DEFAULT ( " interface_is_initialized " , false ) ;
ADD_PROPERTY_DEFAULT ( " ar_is_anchor_detection_enabled " , false ) ;
}
2017-10-07 13:51:17 +00:00
ARVRInterfaceGDNative : : ARVRInterfaceGDNative ( ) {
2019-06-01 13:42:22 +00:00
print_verbose ( " Construct gdnative interface \n " ) ;
2017-10-07 13:51:17 +00:00
// we won't have our data pointer until our library gets set
data = NULL ;
2017-10-14 16:05:01 +00:00
interface = NULL ;
2017-10-07 13:51:17 +00:00
}
ARVRInterfaceGDNative : : ~ ARVRInterfaceGDNative ( ) {
2019-06-01 13:42:22 +00:00
print_verbose ( " Destruct gdnative interface \n " ) ;
2017-10-07 13:51:17 +00:00
2019-06-01 13:42:22 +00:00
if ( interface ! = NULL & & is_initialized ( ) ) {
2017-10-07 13:51:17 +00:00
uninitialize ( ) ;
} ;
// cleanup after ourselves
cleanup ( ) ;
}
void ARVRInterfaceGDNative : : cleanup ( ) {
2017-10-14 16:05:01 +00:00
if ( interface ! = NULL ) {
interface - > destructor ( data ) ;
2017-10-07 13:51:17 +00:00
data = NULL ;
2017-10-14 16:05:01 +00:00
interface = NULL ;
}
}
2017-10-07 13:51:17 +00:00
2017-10-14 22:58:36 +00:00
void ARVRInterfaceGDNative : : set_interface ( const godot_arvr_interface_gdnative * p_interface ) {
// this should only be called once, just being paranoid..
2017-10-14 16:05:01 +00:00
if ( interface ) {
2017-10-07 13:51:17 +00:00
cleanup ( ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
2017-10-14 22:58:36 +00:00
// bind to our interface
interface = p_interface ;
2017-10-07 13:51:17 +00:00
// Now we do our constructing...
2017-10-14 16:05:01 +00:00
data = interface - > constructor ( ( godot_object * ) this ) ;
2017-10-07 13:51:17 +00:00
}
StringName ARVRInterfaceGDNative : : get_name ( ) const {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , StringName ( ) ) ;
godot_string result = interface - > get_name ( data ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
StringName name = * ( String * ) & result ;
godot_string_destroy ( & result ) ;
2017-10-07 13:51:17 +00:00
return name ;
}
int ARVRInterfaceGDNative : : get_capabilities ( ) const {
int capabilities ;
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , 0 ) ; // 0 = None
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
capabilities = interface - > get_capabilities ( data ) ;
2017-10-07 13:51:17 +00:00
return capabilities ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
bool ARVRInterfaceGDNative : : get_anchor_detection_is_enabled ( ) const {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , false ) ;
2017-10-07 13:51:17 +00:00
2019-06-01 13:42:22 +00:00
return interface - > get_anchor_detection_is_enabled ( data ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
void ARVRInterfaceGDNative : : set_anchor_detection_is_enabled ( bool p_enable ) {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND ( interface = = NULL ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
interface - > set_anchor_detection_is_enabled ( data , p_enable ) ;
}
2017-10-07 13:51:17 +00:00
2017-08-20 14:17:24 +00:00
int ARVRInterfaceGDNative : : get_camera_feed_id ( ) {
ERR_FAIL_COND_V ( interface = = NULL , 0 ) ;
if ( ( interface - > version . major > 1 ) | | ( ( interface - > version . major ) = = 1 & & ( interface - > version . minor > = 1 ) ) ) {
return ( unsigned int ) interface - > get_camera_feed_id ( data ) ;
} else {
return 0 ;
}
}
2017-10-07 13:51:17 +00:00
bool ARVRInterfaceGDNative : : is_stereo ( ) {
bool stereo ;
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , false ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
stereo = interface - > is_stereo ( data ) ;
2017-10-07 13:51:17 +00:00
return stereo ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
2018-07-25 01:11:03 +00:00
bool ARVRInterfaceGDNative : : is_initialized ( ) const {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , false ) ;
2017-10-07 13:51:17 +00:00
2019-06-01 13:42:22 +00:00
return interface - > is_initialized ( data ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
bool ARVRInterfaceGDNative : : initialize ( ) {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , false ) ;
2017-10-07 13:51:17 +00:00
2019-06-01 13:42:22 +00:00
bool initialized = interface - > initialize ( data ) ;
2017-10-07 13:51:17 +00:00
if ( initialized ) {
// if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
if ( ( arvr_server ! = NULL ) & & ( arvr_server - > get_primary_interface ( ) = = NULL ) ) {
arvr_server - > set_primary_interface ( this ) ;
} ;
} ;
return initialized ;
}
void ARVRInterfaceGDNative : : uninitialize ( ) {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND ( interface = = NULL ) ;
2017-10-07 13:51:17 +00:00
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
if ( arvr_server ! = NULL ) {
// Whatever happens, make sure this is no longer our primary interface
arvr_server - > clear_primary_interface_if ( this ) ;
}
2017-10-14 16:05:01 +00:00
interface - > uninitialize ( data ) ;
2017-10-07 13:51:17 +00:00
}
2017-11-04 00:50:05 +00:00
Size2 ARVRInterfaceGDNative : : get_render_targetsize ( ) {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , Size2 ( ) ) ;
2017-10-07 13:51:17 +00:00
2017-11-04 00:50:05 +00:00
godot_vector2 result = interface - > get_render_targetsize ( data ) ;
2017-10-14 16:05:01 +00:00
Vector2 * vec = ( Vector2 * ) & result ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
return * vec ;
2017-10-07 13:51:17 +00:00
}
Transform ARVRInterfaceGDNative : : get_transform_for_eye ( ARVRInterface : : Eyes p_eye , const Transform & p_cam_transform ) {
2017-10-14 16:05:01 +00:00
Transform * ret ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , Transform ( ) ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
godot_transform t = interface - > get_transform_for_eye ( data , ( int ) p_eye , ( godot_transform * ) & p_cam_transform ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
ret = ( Transform * ) & t ;
return * ret ;
2017-10-07 13:51:17 +00:00
}
CameraMatrix ARVRInterfaceGDNative : : get_projection_for_eye ( ARVRInterface : : Eyes p_eye , real_t p_aspect , real_t p_z_near , real_t p_z_far ) {
CameraMatrix cm ;
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND_V ( interface = = NULL , CameraMatrix ( ) ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
interface - > fill_projection_for_eye ( data , ( godot_real * ) cm . matrix , ( godot_int ) p_eye , p_aspect , p_z_near , p_z_far ) ;
2017-10-07 13:51:17 +00:00
return cm ;
}
2019-03-30 13:03:49 +00:00
unsigned int ARVRInterfaceGDNative : : get_external_texture_for_eye ( ARVRInterface : : Eyes p_eye ) {
ERR_FAIL_COND_V ( interface = = NULL , 0 ) ;
if ( ( interface - > version . major > 1 ) | | ( ( interface - > version . major ) = = 1 & & ( interface - > version . minor > = 1 ) ) ) {
return ( unsigned int ) interface - > get_external_texture_for_eye ( data , ( godot_int ) p_eye ) ;
} else {
return 0 ;
}
}
2021-03-25 11:15:23 +00:00
unsigned int ARVRInterfaceGDNative : : get_external_depth_for_eye ( ARVRInterface : : Eyes p_eye ) {
ERR_FAIL_COND_V ( interface = = NULL , 0 ) ;
if ( ( interface - > version . major > 1 ) | | ( ( interface - > version . major ) = = 1 & & ( interface - > version . minor > = 2 ) ) ) {
return ( unsigned int ) interface - > get_external_depth_for_eye ( data , ( godot_int ) p_eye ) ;
} else {
return 0 ;
}
}
2017-10-07 13:51:17 +00:00
void ARVRInterfaceGDNative : : commit_for_eye ( ARVRInterface : : Eyes p_eye , RID p_render_target , const Rect2 & p_screen_rect ) {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND ( interface = = NULL ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
interface - > commit_for_eye ( data , ( godot_int ) p_eye , ( godot_rid * ) & p_render_target , ( godot_rect2 * ) & p_screen_rect ) ;
2017-10-07 13:51:17 +00:00
}
void ARVRInterfaceGDNative : : process ( ) {
2017-10-14 16:05:01 +00:00
ERR_FAIL_COND ( interface = = NULL ) ;
2017-10-07 13:51:17 +00:00
2017-10-14 16:05:01 +00:00
interface - > process ( data ) ;
2017-10-07 13:51:17 +00:00
}
2019-03-13 09:43:21 +00:00
void ARVRInterfaceGDNative : : notification ( int p_what ) {
ERR_FAIL_COND ( interface = = NULL ) ;
// this is only available in interfaces that implement 1.1 or later
if ( ( interface - > version . major > 1 ) | | ( ( interface - > version . major = = 1 ) & & ( interface - > version . minor > 0 ) ) ) {
2019-04-30 11:47:14 +00:00
interface - > notification ( data , p_what ) ;
2019-03-13 09:43:21 +00:00
}
}
2017-10-07 13:51:17 +00:00
/////////////////////////////////////////////////////////////////////////////////////
// some helper callbacks
2017-10-14 16:05:01 +00:00
extern " C " {
2017-10-14 22:58:36 +00:00
void GDAPI godot_arvr_register_interface ( const godot_arvr_interface_gdnative * p_interface ) {
2018-05-26 00:03:25 +00:00
// If our major version is 0 or bigger then 10, we're likely looking at our constructor pointer from an older plugin
2019-08-09 04:49:33 +00:00
ERR_FAIL_COND_MSG ( ( p_interface - > version . major = = 0 ) | | ( p_interface - > version . major > 10 ) , " GDNative ARVR interfaces build for Godot 3.0 are not supported. " ) ;
2018-05-26 00:03:25 +00:00
2017-10-14 22:58:36 +00:00
Ref < ARVRInterfaceGDNative > new_interface ;
new_interface . instance ( ) ;
2019-02-21 19:24:29 +00:00
new_interface - > set_interface ( ( const godot_arvr_interface_gdnative * ) p_interface ) ;
2017-10-14 22:58:36 +00:00
ARVRServer : : get_singleton ( ) - > add_interface ( new_interface ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
godot_real GDAPI godot_arvr_get_worldscale ( ) {
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
ERR_FAIL_NULL_V ( arvr_server , 1.0 ) ;
return arvr_server - > get_world_scale ( ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
godot_transform GDAPI godot_arvr_get_reference_frame ( ) {
godot_transform reference_frame ;
Transform * reference_frame_ptr = ( Transform * ) & reference_frame ;
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
if ( arvr_server ! = NULL ) {
* reference_frame_ptr = arvr_server - > get_reference_frame ( ) ;
} else {
godot_transform_new_identity ( & reference_frame ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
return reference_frame ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
void GDAPI godot_arvr_blit ( godot_int p_eye , godot_rid * p_render_target , godot_rect2 * p_rect ) {
// blits out our texture as is, handy for preview display of one of the eyes that is already rendered with lens distortion on an external HMD
ARVRInterface : : Eyes eye = ( ARVRInterface : : Eyes ) p_eye ;
RID * render_target = ( RID * ) p_render_target ;
Rect2 screen_rect = * ( Rect2 * ) p_rect ;
if ( eye = = ARVRInterface : : EYE_LEFT ) {
screen_rect . size . x / = 2.0 ;
} else if ( p_eye = = ARVRInterface : : EYE_RIGHT ) {
screen_rect . size . x / = 2.0 ;
screen_rect . position . x + = screen_rect . size . x ;
}
VSG : : rasterizer - > set_current_render_target ( RID ( ) ) ;
VSG : : rasterizer - > blit_render_target_to_screen ( * render_target , screen_rect , 0 ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
godot_int GDAPI godot_arvr_get_texid ( godot_rid * p_render_target ) {
// In order to send off our textures to display on our hardware we need the opengl texture ID instead of the render target RID
// This is a handy function to expose that.
RID * render_target = ( RID * ) p_render_target ;
RID eye_texture = VSG : : storage - > render_target_get_texture ( * render_target ) ;
uint32_t texid = VS : : get_singleton ( ) - > texture_get_texid ( eye_texture ) ;
return texid ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
godot_int GDAPI godot_arvr_add_controller ( char * p_device_name , godot_int p_hand , godot_bool p_tracks_orientation , godot_bool p_tracks_position ) {
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
ERR_FAIL_NULL_V ( arvr_server , 0 ) ;
InputDefault * input = ( InputDefault * ) Input : : get_singleton ( ) ;
ERR_FAIL_NULL_V ( input , 0 ) ;
2021-03-29 10:07:48 +00:00
Ref < ARVRPositionalTracker > new_tracker ;
new_tracker . instance ( ) ;
2017-10-07 13:51:17 +00:00
new_tracker - > set_name ( p_device_name ) ;
new_tracker - > set_type ( ARVRServer : : TRACKER_CONTROLLER ) ;
if ( p_hand = = 1 ) {
new_tracker - > set_hand ( ARVRPositionalTracker : : TRACKER_LEFT_HAND ) ;
} else if ( p_hand = = 2 ) {
new_tracker - > set_hand ( ARVRPositionalTracker : : TRACKER_RIGHT_HAND ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
// also register as joystick...
int joyid = input - > get_unused_joy_id ( ) ;
if ( joyid ! = - 1 ) {
new_tracker - > set_joy_id ( joyid ) ;
input - > joy_connection_changed ( joyid , true , p_device_name , " " ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
if ( p_tracks_orientation ) {
Basis orientation ;
new_tracker - > set_orientation ( orientation ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
if ( p_tracks_position ) {
Vector3 position ;
new_tracker - > set_position ( position ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
// add our tracker to our server and remember its pointer
arvr_server - > add_tracker ( new_tracker ) ;
// note, this ID is only unique within controllers!
return new_tracker - > get_tracker_id ( ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
void GDAPI godot_arvr_remove_controller ( godot_int p_controller_id ) {
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
ERR_FAIL_NULL ( arvr_server ) ;
InputDefault * input = ( InputDefault * ) Input : : get_singleton ( ) ;
ERR_FAIL_NULL ( input ) ;
2021-03-29 10:07:48 +00:00
Ref < ARVRPositionalTracker > remove_tracker = arvr_server - > find_by_type_and_id ( ARVRServer : : TRACKER_CONTROLLER , p_controller_id ) ;
if ( remove_tracker . is_valid ( ) ) {
2017-10-07 13:51:17 +00:00
// unset our joystick if applicable
int joyid = remove_tracker - > get_joy_id ( ) ;
if ( joyid ! = - 1 ) {
input - > joy_connection_changed ( joyid , false , " " , " " ) ;
remove_tracker - > set_joy_id ( - 1 ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
// remove our tracker from our server
arvr_server - > remove_tracker ( remove_tracker ) ;
2021-03-29 10:07:48 +00:00
remove_tracker . unref ( ) ;
2017-10-14 16:05:01 +00:00
}
}
2017-10-07 13:51:17 +00:00
void GDAPI godot_arvr_set_controller_transform ( godot_int p_controller_id , godot_transform * p_transform , godot_bool p_tracks_orientation , godot_bool p_tracks_position ) {
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
ERR_FAIL_NULL ( arvr_server ) ;
2021-03-29 10:07:48 +00:00
Ref < ARVRPositionalTracker > tracker = arvr_server - > find_by_type_and_id ( ARVRServer : : TRACKER_CONTROLLER , p_controller_id ) ;
if ( tracker . is_valid ( ) ) {
2017-10-07 13:51:17 +00:00
Transform * transform = ( Transform * ) p_transform ;
if ( p_tracks_orientation ) {
tracker - > set_orientation ( transform - > basis ) ;
2017-10-14 16:05:01 +00:00
}
2017-10-07 13:51:17 +00:00
if ( p_tracks_position ) {
2017-11-28 12:28:35 +00:00
tracker - > set_rw_position ( transform - > origin ) ;
2017-10-14 16:05:01 +00:00
}
}
}
2017-10-07 13:51:17 +00:00
void GDAPI godot_arvr_set_controller_button ( godot_int p_controller_id , godot_int p_button , godot_bool p_is_pressed ) {
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
ERR_FAIL_NULL ( arvr_server ) ;
InputDefault * input = ( InputDefault * ) Input : : get_singleton ( ) ;
ERR_FAIL_NULL ( input ) ;
2021-03-29 10:07:48 +00:00
Ref < ARVRPositionalTracker > tracker = arvr_server - > find_by_type_and_id ( ARVRServer : : TRACKER_CONTROLLER , p_controller_id ) ;
if ( tracker . is_valid ( ) ) {
2017-10-07 13:51:17 +00:00
int joyid = tracker - > get_joy_id ( ) ;
if ( joyid ! = - 1 ) {
input - > joy_button ( joyid , p_button , p_is_pressed ) ;
2017-10-14 16:05:01 +00:00
}
}
}
2017-10-07 13:51:17 +00:00
void GDAPI godot_arvr_set_controller_axis ( godot_int p_controller_id , godot_int p_axis , godot_real p_value , godot_bool p_can_be_negative ) {
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
ERR_FAIL_NULL ( arvr_server ) ;
InputDefault * input = ( InputDefault * ) Input : : get_singleton ( ) ;
ERR_FAIL_NULL ( input ) ;
2021-03-29 10:07:48 +00:00
Ref < ARVRPositionalTracker > tracker = arvr_server - > find_by_type_and_id ( ARVRServer : : TRACKER_CONTROLLER , p_controller_id ) ;
if ( tracker . is_valid ( ) ) {
2017-10-07 13:51:17 +00:00
int joyid = tracker - > get_joy_id ( ) ;
if ( joyid ! = - 1 ) {
InputDefault : : JoyAxis jx ;
jx . min = p_can_be_negative ? - 1 : 0 ;
jx . value = p_value ;
input - > joy_axis ( joyid , p_axis , jx ) ;
2017-10-14 16:05:01 +00:00
}
}
}
2017-11-01 10:46:37 +00:00
godot_real GDAPI godot_arvr_get_controller_rumble ( godot_int p_controller_id ) {
ARVRServer * arvr_server = ARVRServer : : get_singleton ( ) ;
ERR_FAIL_NULL_V ( arvr_server , 0.0 ) ;
2021-03-29 10:07:48 +00:00
Ref < ARVRPositionalTracker > tracker = arvr_server - > find_by_type_and_id ( ARVRServer : : TRACKER_CONTROLLER , p_controller_id ) ;
if ( tracker . is_valid ( ) ) {
2017-11-01 10:46:37 +00:00
return tracker - > get_rumble ( ) ;
}
return 0.0 ;
}
2021-03-25 11:15:23 +00:00
void GDAPI godot_arvr_set_interface ( godot_object * p_arvr_interface , const godot_arvr_interface_gdnative * p_gdn_interface ) {
// If our major version is 0 or bigger then 10, we're likely looking at our constructor pointer from an older plugin
ERR_FAIL_COND_MSG ( ( p_gdn_interface - > version . major = = 0 ) | | ( p_gdn_interface - > version . major > 10 ) , " GDNative ARVR interfaces build for Godot 3.0 are not supported. " ) ;
ARVRInterfaceGDNative * interface = ( ARVRInterfaceGDNative * ) p_arvr_interface ;
interface - > set_interface ( ( const godot_arvr_interface_gdnative * ) p_gdn_interface ) ;
}
godot_int GDAPI godot_arvr_get_depthid ( godot_rid * p_render_target ) {
// We also need to access our depth texture for reprojection.
RID * render_target = ( RID * ) p_render_target ;
uint32_t texid = VSG : : storage - > render_target_get_depth_texture_id ( * render_target ) ;
return texid ;
}
2017-10-14 16:05:01 +00:00
}