mirror of
https://github.com/Relintai/gdnative.git
synced 2024-11-14 04:57:22 +01:00
Initial cleanup pass.
This commit is contained in:
parent
54e8b313ad
commit
bc25bde5b4
3
SCsub
3
SCsub
@ -12,12 +12,11 @@ env_gdnative.add_source_files(env.modules_sources, "nativescript/*.cpp")
|
|||||||
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp")
|
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp")
|
||||||
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp")
|
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp")
|
||||||
|
|
||||||
env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"])
|
env_gdnative.Prepend(CPPPATH=["./include/"])
|
||||||
|
|
||||||
Export("env_gdnative")
|
Export("env_gdnative")
|
||||||
|
|
||||||
SConscript("net/SCsub")
|
SConscript("net/SCsub")
|
||||||
SConscript("arvr/SCsub")
|
|
||||||
SConscript("pluginscript/SCsub")
|
SConscript("pluginscript/SCsub")
|
||||||
SConscript("videodecoder/SCsub")
|
SConscript("videodecoder/SCsub")
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "modules/gdnative/gdnative.h"
|
#include "gdnative/gdnative.h"
|
||||||
|
|
||||||
// Code by Paritosh97 with minor tweaks by Mux213
|
// Code by Paritosh97 with minor tweaks by Mux213
|
||||||
// These entry points are only for the android platform and are simple stubs in all others.
|
// These entry points are only for the android platform and are simple stubs in all others.
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
Import("env")
|
|
||||||
Import("env_gdnative")
|
|
||||||
|
|
||||||
env_gdnative.add_source_files(env.modules_sources, "*.cpp")
|
|
@ -1,450 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* arvr_interface_gdnative.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. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#include "arvr_interface_gdnative.h"
|
|
||||||
#include "main/input_default.h"
|
|
||||||
#include "servers/arvr/arvr_positional_tracker.h"
|
|
||||||
#include "servers/visual/visual_server_globals.h"
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::_bind_methods() {
|
|
||||||
ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
|
|
||||||
ADD_PROPERTY_DEFAULT("ar_is_anchor_detection_enabled", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
|
|
||||||
print_verbose("Construct gdnative interface\n");
|
|
||||||
|
|
||||||
// we won't have our data pointer until our library gets set
|
|
||||||
data = nullptr;
|
|
||||||
|
|
||||||
interface = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ARVRInterfaceGDNative::~ARVRInterfaceGDNative() {
|
|
||||||
print_verbose("Destruct gdnative interface\n");
|
|
||||||
|
|
||||||
if (interface != nullptr && is_initialized()) {
|
|
||||||
uninitialize();
|
|
||||||
};
|
|
||||||
|
|
||||||
// cleanup after ourselves
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::cleanup() {
|
|
||||||
if (interface != nullptr) {
|
|
||||||
interface->destructor(data);
|
|
||||||
data = nullptr;
|
|
||||||
interface = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::set_interface(const godot_arvr_interface_gdnative *p_interface) {
|
|
||||||
// this should only be called once, just being paranoid..
|
|
||||||
if (interface) {
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
// bind to our interface
|
|
||||||
interface = p_interface;
|
|
||||||
|
|
||||||
// Now we do our constructing...
|
|
||||||
data = interface->constructor((godot_object *)this);
|
|
||||||
}
|
|
||||||
|
|
||||||
StringName ARVRInterfaceGDNative::get_name() const {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, StringName());
|
|
||||||
|
|
||||||
godot_string result = interface->get_name(data);
|
|
||||||
|
|
||||||
StringName name = *(String *)&result;
|
|
||||||
|
|
||||||
godot_string_destroy(&result);
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ARVRInterfaceGDNative::get_capabilities() const {
|
|
||||||
int capabilities;
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, 0); // 0 = None
|
|
||||||
|
|
||||||
capabilities = interface->get_capabilities(data);
|
|
||||||
|
|
||||||
return capabilities;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
|
||||||
|
|
||||||
return interface->get_anchor_detection_is_enabled(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
|
|
||||||
ERR_FAIL_COND(interface == nullptr);
|
|
||||||
|
|
||||||
interface->set_anchor_detection_is_enabled(data, p_enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ARVRInterfaceGDNative::get_camera_feed_id() {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ARVRInterfaceGDNative::is_stereo() {
|
|
||||||
bool stereo;
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
|
||||||
|
|
||||||
stereo = interface->is_stereo(data);
|
|
||||||
|
|
||||||
return stereo;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ARVRInterfaceGDNative::is_initialized() const {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
|
||||||
|
|
||||||
return interface->is_initialized(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ARVRInterfaceGDNative::initialize() {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
|
||||||
|
|
||||||
bool initialized = interface->initialize(data);
|
|
||||||
|
|
||||||
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 != nullptr) && (arvr_server->get_primary_interface() == nullptr)) {
|
|
||||||
arvr_server->set_primary_interface(this);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
return initialized;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::uninitialize() {
|
|
||||||
ERR_FAIL_COND(interface == nullptr);
|
|
||||||
|
|
||||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
|
||||||
if (arvr_server != nullptr) {
|
|
||||||
// Whatever happens, make sure this is no longer our primary interface
|
|
||||||
arvr_server->clear_primary_interface_if(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface->uninitialize(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
Size2 ARVRInterfaceGDNative::get_render_targetsize() {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, Size2());
|
|
||||||
|
|
||||||
godot_vector2 result = interface->get_render_targetsize(data);
|
|
||||||
Vector2 *vec = (Vector2 *)&result;
|
|
||||||
|
|
||||||
return *vec;
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
|
|
||||||
Transform *ret;
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, Transform());
|
|
||||||
|
|
||||||
godot_transform t = interface->get_transform_for_eye(data, (int)p_eye, (godot_transform *)&p_cam_transform);
|
|
||||||
|
|
||||||
ret = (Transform *)&t;
|
|
||||||
|
|
||||||
return *ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, CameraMatrix());
|
|
||||||
|
|
||||||
interface->fill_projection_for_eye(data, (godot_real *)cm.matrix, (godot_int)p_eye, p_aspect, p_z_near, p_z_far);
|
|
||||||
|
|
||||||
return cm;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int ARVRInterfaceGDNative::get_external_texture_for_eye(ARVRInterface::Eyes p_eye) {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int ARVRInterfaceGDNative::get_external_depth_for_eye(ARVRInterface::Eyes p_eye) {
|
|
||||||
ERR_FAIL_COND_V(interface == nullptr, 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
|
|
||||||
ERR_FAIL_COND(interface == nullptr);
|
|
||||||
|
|
||||||
interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::process() {
|
|
||||||
ERR_FAIL_COND(interface == nullptr);
|
|
||||||
|
|
||||||
interface->process(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARVRInterfaceGDNative::notification(int p_what) {
|
|
||||||
ERR_FAIL_COND(interface == nullptr);
|
|
||||||
|
|
||||||
// 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))) {
|
|
||||||
interface->notification(data, p_what);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// some helper callbacks
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_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_interface->version.major == 0) || (p_interface->version.major > 10), "GDNative ARVR interfaces build for Godot 3.0 are not supported.");
|
|
||||||
|
|
||||||
Ref<ARVRInterfaceGDNative> new_interface;
|
|
||||||
new_interface.instance();
|
|
||||||
new_interface->set_interface((const godot_arvr_interface_gdnative *)p_interface);
|
|
||||||
ARVRServer::get_singleton()->add_interface(new_interface);
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
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 != nullptr) {
|
|
||||||
*reference_frame_ptr = arvr_server->get_reference_frame();
|
|
||||||
} else {
|
|
||||||
godot_transform_new_identity(&reference_frame);
|
|
||||||
}
|
|
||||||
|
|
||||||
return reference_frame;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Ref<ARVRPositionalTracker> new_tracker;
|
|
||||||
new_tracker.instance();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (p_tracks_orientation) {
|
|
||||||
Basis orientation;
|
|
||||||
new_tracker->set_orientation(orientation);
|
|
||||||
}
|
|
||||||
if (p_tracks_position) {
|
|
||||||
Vector3 position;
|
|
||||||
new_tracker->set_position(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Ref<ARVRPositionalTracker> remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
|
||||||
if (remove_tracker.is_valid()) {
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// remove our tracker from our server
|
|
||||||
arvr_server->remove_tracker(remove_tracker);
|
|
||||||
remove_tracker.unref();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Ref<ARVRPositionalTracker> tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
|
||||||
if (tracker.is_valid()) {
|
|
||||||
Transform *transform = (Transform *)p_transform;
|
|
||||||
if (p_tracks_orientation) {
|
|
||||||
tracker->set_orientation(transform->basis);
|
|
||||||
}
|
|
||||||
if (p_tracks_position) {
|
|
||||||
tracker->set_rw_position(transform->origin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Ref<ARVRPositionalTracker> tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
|
||||||
if (tracker.is_valid()) {
|
|
||||||
int joyid = tracker->get_joy_id();
|
|
||||||
if (joyid != -1) {
|
|
||||||
input->joy_button(joyid, p_button, p_is_pressed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Ref<ARVRPositionalTracker> tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
|
||||||
if (tracker.is_valid()) {
|
|
||||||
int joyid = tracker->get_joy_id();
|
|
||||||
if (joyid != -1) {
|
|
||||||
float value = p_value;
|
|
||||||
if (!p_can_be_negative) {
|
|
||||||
// Convert to a value between -1.0f and 1.0f.
|
|
||||||
value = p_value * 2.0f - 1.0f;
|
|
||||||
}
|
|
||||||
input->joy_axis(joyid, p_axis, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
Ref<ARVRPositionalTracker> tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
|
||||||
if (tracker.is_valid()) {
|
|
||||||
return tracker->get_rumble();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* arvr_interface_gdnative.h */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* 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. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef ARVR_INTERFACE_GDNATIVE_H
|
|
||||||
#define ARVR_INTERFACE_GDNATIVE_H
|
|
||||||
|
|
||||||
#include "modules/gdnative/gdnative.h"
|
|
||||||
#include "servers/arvr/arvr_interface.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
@authors Hinsbart & Karroffel & Mux213
|
|
||||||
|
|
||||||
This subclass of our AR/VR interface forms a bridge to GDNative.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class ARVRInterfaceGDNative : public ARVRInterface {
|
|
||||||
GDCLASS(ARVRInterfaceGDNative, ARVRInterface);
|
|
||||||
|
|
||||||
void cleanup();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
const godot_arvr_interface_gdnative *interface;
|
|
||||||
void *data;
|
|
||||||
|
|
||||||
static void _bind_methods();
|
|
||||||
|
|
||||||
public:
|
|
||||||
/** general interface information **/
|
|
||||||
ARVRInterfaceGDNative();
|
|
||||||
~ARVRInterfaceGDNative();
|
|
||||||
|
|
||||||
void set_interface(const godot_arvr_interface_gdnative *p_interface);
|
|
||||||
|
|
||||||
virtual StringName get_name() const;
|
|
||||||
virtual int get_capabilities() const;
|
|
||||||
|
|
||||||
virtual bool is_initialized() const;
|
|
||||||
virtual bool initialize();
|
|
||||||
virtual void uninitialize();
|
|
||||||
|
|
||||||
/** specific to AR **/
|
|
||||||
virtual bool get_anchor_detection_is_enabled() const;
|
|
||||||
virtual void set_anchor_detection_is_enabled(bool p_enable);
|
|
||||||
virtual int get_camera_feed_id();
|
|
||||||
|
|
||||||
/** rendering and internal **/
|
|
||||||
virtual Size2 get_render_targetsize();
|
|
||||||
virtual bool is_stereo();
|
|
||||||
virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
|
|
||||||
|
|
||||||
// and a CameraMatrix version to ARVRServer
|
|
||||||
virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
|
||||||
|
|
||||||
virtual unsigned int get_external_texture_for_eye(ARVRInterface::Eyes p_eye);
|
|
||||||
virtual unsigned int get_external_depth_for_eye(ARVRInterface::Eyes p_eye);
|
|
||||||
virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
|
|
||||||
|
|
||||||
virtual void process();
|
|
||||||
virtual void notification(int p_what);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ARVR_INTERFACE_GDNATIVE_H
|
|
@ -1,39 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* register_types.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. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#include "register_types.h"
|
|
||||||
#include "arvr_interface_gdnative.h"
|
|
||||||
|
|
||||||
void register_arvr_types() {
|
|
||||||
ClassDB::register_class<ARVRInterfaceGDNative>();
|
|
||||||
}
|
|
||||||
|
|
||||||
void unregister_arvr_types() {
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* register_types.h */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* 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. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef ARVR_REGISTER_TYPES_H
|
|
||||||
#define ARVR_REGISTER_TYPES_H
|
|
||||||
|
|
||||||
void register_arvr_types();
|
|
||||||
void unregister_arvr_types();
|
|
||||||
|
|
||||||
#endif // ARVR_REGISTER_TYPES_H
|
|
@ -8,7 +8,6 @@ def configure(env):
|
|||||||
|
|
||||||
def get_doc_classes():
|
def get_doc_classes():
|
||||||
return [
|
return [
|
||||||
"ARVRInterfaceGDNative",
|
|
||||||
"GDNative",
|
"GDNative",
|
||||||
"GDNativeLibrary",
|
"GDNativeLibrary",
|
||||||
"MultiplayerPeerGDNative",
|
"MultiplayerPeerGDNative",
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" version="3.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
|
|
||||||
<brief_description>
|
|
||||||
GDNative wrapper for an ARVR interface.
|
|
||||||
</brief_description>
|
|
||||||
<description>
|
|
||||||
This is a wrapper class for GDNative implementations of the ARVR interface. To use a GDNative ARVR interface, simply instantiate this object and set your GDNative library containing the ARVR interface implementation.
|
|
||||||
</description>
|
|
||||||
<tutorials>
|
|
||||||
</tutorials>
|
|
||||||
<methods>
|
|
||||||
</methods>
|
|
||||||
<constants>
|
|
||||||
</constants>
|
|
||||||
</class>
|
|
@ -35,7 +35,7 @@
|
|||||||
#include "core/os/dir_access.h"
|
#include "core/os/dir_access.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/scene_tree.h"
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/os/thread_safe.h"
|
#include "core/os/thread_safe.h"
|
||||||
#include "core/resource.h"
|
#include "core/object/resource.h"
|
||||||
|
|
||||||
#include "gdnative/gdnative.h"
|
#include "gdnative/gdnative.h"
|
||||||
#include "gdnative_api_struct.gen.h"
|
#include "gdnative_api_struct.gen.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/aabb.h"
|
#include "gdnative/aabb.h"
|
||||||
|
|
||||||
#include "core/math/aabb.h"
|
#include "core/math/aabb.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,13 +30,13 @@
|
|||||||
|
|
||||||
#include "gdnative/array.h"
|
#include "gdnative/array.h"
|
||||||
|
|
||||||
#include "core/array.h"
|
#include "core/variant/array.h"
|
||||||
#include "core/os/memory.h"
|
#include "core/os/memory.h"
|
||||||
|
|
||||||
#include "core/color.h"
|
#include "core/math/color.h"
|
||||||
#include "core/pool_vector.h"
|
#include "core/containers/pool_vector.h"
|
||||||
|
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/basis.h"
|
#include "gdnative/basis.h"
|
||||||
|
|
||||||
#include "core/math/basis.h"
|
#include "core/math/basis.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "gdnative/color.h"
|
#include "gdnative/color.h"
|
||||||
|
|
||||||
#include "core/color.h"
|
#include "core/math/color.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "gdnative/dictionary.h"
|
#include "gdnative/dictionary.h"
|
||||||
|
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
// core/variant.h before to avoid compile errors with MSVC
|
// core/variant.h before to avoid compile errors with MSVC
|
||||||
#include "core/dictionary.h"
|
#include "core/variant/dictionary.h"
|
||||||
#include "core/io/json.h"
|
#include "core/io/json.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -30,14 +30,14 @@
|
|||||||
|
|
||||||
#include "gdnative/gdnative.h"
|
#include "gdnative/gdnative.h"
|
||||||
|
|
||||||
#include "core/class_db.h"
|
#include "core/object/class_db.h"
|
||||||
#include "core/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/error_macros.h"
|
#include "core/error/error_macros.h"
|
||||||
#include "core/global_constants.h"
|
#include "core/global_constants.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#include "modules/gdnative/gdnative.h"
|
#include "../gdnative/gdnative.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "gdnative/node_path.h"
|
#include "gdnative/node_path.h"
|
||||||
|
|
||||||
#include "core/node_path.h"
|
#include "core/string/node_path.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/plane.h"
|
#include "gdnative/plane.h"
|
||||||
|
|
||||||
#include "core/math/plane.h"
|
#include "core/math/plane.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,11 +30,11 @@
|
|||||||
|
|
||||||
#include "gdnative/pool_arrays.h"
|
#include "gdnative/pool_arrays.h"
|
||||||
|
|
||||||
#include "core/array.h"
|
#include "core/variant/array.h"
|
||||||
#include "core/pool_vector.h"
|
#include "core/containers/pool_vector.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#include "core/color.h"
|
#include "core/math/color.h"
|
||||||
#include "core/math/vector2.h"
|
#include "core/math/vector2.h"
|
||||||
#include "core/math/vector3.h"
|
#include "core/math/vector3.h"
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/quat.h"
|
#include "gdnative/quat.h"
|
||||||
|
|
||||||
#include "core/math/quat.h"
|
#include "core/math/quat.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/rect2.h"
|
#include "gdnative/rect2.h"
|
||||||
|
|
||||||
#include "core/math/transform_2d.h"
|
#include "core/math/transform_2d.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "gdnative/rid.h"
|
#include "gdnative/rid.h"
|
||||||
|
|
||||||
#include "core/resource.h"
|
#include "core/object/resource.h"
|
||||||
#include "core/rid.h"
|
#include "core/object/rid.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include "gdnative/string.h"
|
#include "gdnative/string.h"
|
||||||
|
|
||||||
#include "core/string_name.h"
|
#include "core/string/string_name.h"
|
||||||
#include "core/ustring.h"
|
#include "core/string/ustring.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "gdnative/string_name.h"
|
#include "gdnative/string_name.h"
|
||||||
|
|
||||||
#include "core/string_name.h"
|
#include "core/string/string_name.h"
|
||||||
#include "core/ustring.h"
|
#include "core/string/ustring.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/transform.h"
|
#include "gdnative/transform.h"
|
||||||
|
|
||||||
#include "core/math/transform.h"
|
#include "core/math/transform.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/transform2d.h"
|
#include "gdnative/transform2d.h"
|
||||||
|
|
||||||
#include "core/math/transform_2d.h"
|
#include "core/math/transform_2d.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/variant.h"
|
#include "gdnative/variant.h"
|
||||||
|
|
||||||
#include "core/reference.h"
|
#include "core/reference.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "gdnative/vector2.h"
|
#include "gdnative/vector2.h"
|
||||||
|
|
||||||
#include "core/math/vector2.h"
|
#include "core/math/vector2.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
#include "gdnative/vector3.h"
|
#include "gdnative/vector3.h"
|
||||||
|
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
#include "core/vector.h"
|
#include "core/containers/vector.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -44,7 +44,6 @@ def _build_gdnative_api_struct_header(api):
|
|||||||
"",
|
"",
|
||||||
"#include <gdnative/gdnative.h>",
|
"#include <gdnative/gdnative.h>",
|
||||||
"#include <android/godot_android.h>",
|
"#include <android/godot_android.h>",
|
||||||
"#include <arvr/godot_arvr.h>",
|
|
||||||
"#include <nativescript/godot_nativescript.h>",
|
"#include <nativescript/godot_nativescript.h>",
|
||||||
"#include <net/godot_net.h>",
|
"#include <net/godot_net.h>",
|
||||||
"#include <pluginscript/godot_pluginscript.h>",
|
"#include <pluginscript/godot_pluginscript.h>",
|
||||||
@ -286,7 +285,6 @@ def _build_gdnative_wrapper_code(api):
|
|||||||
"#include <gdnative/gdnative.h>",
|
"#include <gdnative/gdnative.h>",
|
||||||
"#include <nativescript/godot_nativescript.h>",
|
"#include <nativescript/godot_nativescript.h>",
|
||||||
"#include <pluginscript/godot_pluginscript.h>",
|
"#include <pluginscript/godot_pluginscript.h>",
|
||||||
"#include <arvr/godot_arvr.h>",
|
|
||||||
"#include <videodecoder/godot_videodecoder.h>",
|
"#include <videodecoder/godot_videodecoder.h>",
|
||||||
"",
|
"",
|
||||||
"#include <gdnative_api_struct.gen.h>",
|
"#include <gdnative_api_struct.gen.h>",
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* godot_arvr.h */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* 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. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef GODOT_ARVR_H
|
|
||||||
#define GODOT_ARVR_H
|
|
||||||
|
|
||||||
#include <gdnative/gdnative.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For future versions of the API we should only add new functions at the end of the structure and use the
|
|
||||||
// version info to detect whether a call is available
|
|
||||||
|
|
||||||
// Use these to populate version in your plugin
|
|
||||||
#define GODOTVR_API_MAJOR 1
|
|
||||||
#define GODOTVR_API_MINOR 2
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
godot_gdnative_api_version version; /* version of our API */
|
|
||||||
void *(*constructor)(godot_object *);
|
|
||||||
void (*destructor)(void *);
|
|
||||||
godot_string (*get_name)(const void *);
|
|
||||||
godot_int (*get_capabilities)(const void *);
|
|
||||||
godot_bool (*get_anchor_detection_is_enabled)(const void *);
|
|
||||||
void (*set_anchor_detection_is_enabled)(void *, godot_bool);
|
|
||||||
godot_bool (*is_stereo)(const void *);
|
|
||||||
godot_bool (*is_initialized)(const void *);
|
|
||||||
godot_bool (*initialize)(void *);
|
|
||||||
void (*uninitialize)(void *);
|
|
||||||
godot_vector2 (*get_render_targetsize)(const void *);
|
|
||||||
godot_transform (*get_transform_for_eye)(void *, godot_int, godot_transform *);
|
|
||||||
void (*fill_projection_for_eye)(void *, godot_real *, godot_int, godot_real, godot_real, godot_real);
|
|
||||||
void (*commit_for_eye)(void *, godot_int, godot_rid *, godot_rect2 *);
|
|
||||||
void (*process)(void *);
|
|
||||||
// only in 1.1 onwards
|
|
||||||
godot_int (*get_external_texture_for_eye)(void *, godot_int);
|
|
||||||
void (*notification)(void *, godot_int);
|
|
||||||
godot_int (*get_camera_feed_id)(void *);
|
|
||||||
// only in 1.2 onwards
|
|
||||||
godot_int (*get_external_depth_for_eye)(void *, godot_int);
|
|
||||||
} godot_arvr_interface_gdnative;
|
|
||||||
|
|
||||||
void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface);
|
|
||||||
|
|
||||||
// helper functions to access ARVRServer data
|
|
||||||
godot_real GDAPI godot_arvr_get_worldscale();
|
|
||||||
godot_transform GDAPI godot_arvr_get_reference_frame();
|
|
||||||
|
|
||||||
// helper functions for rendering
|
|
||||||
void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect);
|
|
||||||
godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target);
|
|
||||||
|
|
||||||
// helper functions for updating ARVR controllers
|
|
||||||
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);
|
|
||||||
void GDAPI godot_arvr_remove_controller(godot_int p_controller_id);
|
|
||||||
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);
|
|
||||||
void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed);
|
|
||||||
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);
|
|
||||||
godot_real GDAPI godot_arvr_get_controller_rumble(godot_int p_controller_id);
|
|
||||||
|
|
||||||
// ARVR 1.2 functions
|
|
||||||
void GDAPI godot_arvr_set_interface(godot_object *p_arvr_interface, const godot_arvr_interface_gdnative *p_gdn_interface);
|
|
||||||
godot_int GDAPI godot_arvr_get_depthid(godot_rid *p_render_target);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // GODOT_ARVR_H
|
|
@ -114,7 +114,4 @@ void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// WebRTC Bindings
|
|
||||||
#include "net/godot_webrtc.h"
|
|
||||||
|
|
||||||
#endif // GODOT_NET_H
|
#endif // GODOT_NET_H
|
||||||
|
@ -1,129 +0,0 @@
|
|||||||
/**************************************************************************/
|
|
||||||
/* godot_webrtc.h */
|
|
||||||
/**************************************************************************/
|
|
||||||
/* 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. */
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
#ifndef GODOT_WEBRTC_H
|
|
||||||
#define GODOT_WEBRTC_H
|
|
||||||
|
|
||||||
#include <gdnative/gdnative.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GODOT_NET_WEBRTC_API_MAJOR 3
|
|
||||||
#define GODOT_NET_WEBRTC_API_MINOR 4
|
|
||||||
|
|
||||||
/* Library Interface (used to set default GDNative WebRTC implementation */
|
|
||||||
typedef struct {
|
|
||||||
godot_gdnative_api_version version; /* version of our API */
|
|
||||||
|
|
||||||
/* Called when the library is unset as default interface via godot_net_set_webrtc_library */
|
|
||||||
void (*unregistered)();
|
|
||||||
|
|
||||||
/* Used by WebRTCPeerConnection create when GDNative is the default implementation. */
|
|
||||||
/* Takes a pointer to WebRTCPeerConnectionGDNative, should bind and return OK, failure if binding was unsuccessful. */
|
|
||||||
godot_error (*create_peer_connection)(godot_object *);
|
|
||||||
|
|
||||||
void *next; /* For extension */
|
|
||||||
} godot_net_webrtc_library;
|
|
||||||
|
|
||||||
/* WebRTCPeerConnection interface */
|
|
||||||
typedef struct {
|
|
||||||
godot_gdnative_api_version version; /* version of our API */
|
|
||||||
|
|
||||||
godot_object *data; /* User reference */
|
|
||||||
|
|
||||||
/* This is WebRTCPeerConnection */
|
|
||||||
godot_int (*get_connection_state)(const void *);
|
|
||||||
|
|
||||||
godot_error (*initialize)(void *, const godot_dictionary *);
|
|
||||||
godot_object *(*create_data_channel)(void *, const char *p_channel_name, const godot_dictionary *);
|
|
||||||
godot_error (*create_offer)(void *);
|
|
||||||
godot_error (*create_answer)(void *); /* unused for now, should be done automatically on set_local_description */
|
|
||||||
godot_error (*set_remote_description)(void *, const char *, const char *);
|
|
||||||
godot_error (*set_local_description)(void *, const char *, const char *);
|
|
||||||
godot_error (*add_ice_candidate)(void *, const char *, int, const char *);
|
|
||||||
godot_error (*poll)(void *);
|
|
||||||
void (*close)(void *);
|
|
||||||
|
|
||||||
void *next; /* For extension? */
|
|
||||||
} godot_net_webrtc_peer_connection;
|
|
||||||
|
|
||||||
/* WebRTCDataChannel interface */
|
|
||||||
typedef struct {
|
|
||||||
godot_gdnative_api_version version; /* version of our API */
|
|
||||||
|
|
||||||
godot_object *data; /* User reference */
|
|
||||||
|
|
||||||
/* This is PacketPeer */
|
|
||||||
godot_error (*get_packet)(void *, const uint8_t **, int *);
|
|
||||||
godot_error (*put_packet)(void *, const uint8_t *, int);
|
|
||||||
godot_int (*get_available_packet_count)(const void *);
|
|
||||||
godot_int (*get_max_packet_size)(const void *);
|
|
||||||
|
|
||||||
/* This is WebRTCDataChannel */
|
|
||||||
void (*set_write_mode)(void *, godot_int);
|
|
||||||
godot_int (*get_write_mode)(const void *);
|
|
||||||
bool (*was_string_packet)(const void *);
|
|
||||||
|
|
||||||
godot_int (*get_ready_state)(const void *);
|
|
||||||
const char *(*get_label)(const void *);
|
|
||||||
bool (*is_ordered)(const void *);
|
|
||||||
int (*get_id)(const void *);
|
|
||||||
int (*get_max_packet_life_time)(const void *);
|
|
||||||
int (*get_max_retransmits)(const void *);
|
|
||||||
const char *(*get_protocol)(const void *);
|
|
||||||
bool (*is_negotiated)(const void *);
|
|
||||||
|
|
||||||
godot_error (*poll)(void *);
|
|
||||||
void (*close)(void *);
|
|
||||||
|
|
||||||
void *next; /* For extension? */
|
|
||||||
} godot_net_webrtc_data_channel;
|
|
||||||
|
|
||||||
/* Extensions to WebRTCDataChannel */
|
|
||||||
typedef struct {
|
|
||||||
int (*get_buffered_amount)(const void *);
|
|
||||||
|
|
||||||
void *next; /* For extension? */
|
|
||||||
} godot_net_webrtc_data_channel_ext;
|
|
||||||
|
|
||||||
/* Set the default GDNative library */
|
|
||||||
godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *);
|
|
||||||
/* Binds a WebRTCPeerConnectionGDNative to the provided interface */
|
|
||||||
void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *);
|
|
||||||
/* Binds a WebRTCDataChannelGDNative to the provided interface */
|
|
||||||
void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // GODOT_WEBRTC_H
|
|
@ -32,8 +32,8 @@
|
|||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
|
||||||
#include "core/class_db.h"
|
#include "core/object/class_db.h"
|
||||||
#include "core/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/global_constants.h"
|
#include "core/global_constants.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/pair.h"
|
#include "core/pair.h"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define API_GENERATOR_H
|
#define API_GENERATOR_H
|
||||||
|
|
||||||
#include "core/typedefs.h"
|
#include "core/typedefs.h"
|
||||||
#include "core/ustring.h"
|
#include "core/string/ustring.h"
|
||||||
|
|
||||||
Error generate_c_api(const String &p_path);
|
Error generate_c_api(const String &p_path);
|
||||||
|
|
||||||
|
@ -30,11 +30,11 @@
|
|||||||
|
|
||||||
#include "nativescript/godot_nativescript.h"
|
#include "nativescript/godot_nativescript.h"
|
||||||
|
|
||||||
#include "core/class_db.h"
|
#include "core/object/class_db.h"
|
||||||
#include "core/error_macros.h"
|
#include "core/error/error_macros.h"
|
||||||
#include "core/global_constants.h"
|
#include "core/global_constants.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
#include "gdnative/gdnative.h"
|
#include "gdnative/gdnative.h"
|
||||||
|
|
||||||
#include "nativescript.h"
|
#include "nativescript.h"
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "core/io/file_access_encrypted.h"
|
#include "core/io/file_access_encrypted.h"
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
|
||||||
#include "main/main.h"
|
#include "main/main.h"
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@
|
|||||||
#include "core/oa_hash_map.h"
|
#include "core/oa_hash_map.h"
|
||||||
#include "core/ordered_hash_map.h"
|
#include "core/ordered_hash_map.h"
|
||||||
#include "core/os/thread_safe.h"
|
#include "core/os/thread_safe.h"
|
||||||
#include "core/resource.h"
|
#include "core/object/resource.h"
|
||||||
#include "core/safe_refcount.h"
|
#include "core/safe_refcount.h"
|
||||||
#include "core/script_language.h"
|
#include "core/object/script_language.h"
|
||||||
#include "core/self_list.h"
|
#include "core/containers/self_list.h"
|
||||||
#include "scene/main/node.h"
|
#include "scene/main/node.h"
|
||||||
|
|
||||||
#include "modules/gdnative/gdnative.h"
|
#include "modules/gdnative/gdnative.h"
|
||||||
|
@ -5,8 +5,8 @@ Import("env_gdnative")
|
|||||||
|
|
||||||
env_net = env_gdnative.Clone()
|
env_net = env_gdnative.Clone()
|
||||||
|
|
||||||
has_webrtc = env_net["module_webrtc_enabled"]
|
#has_webrtc = env_net["module_webrtc_enabled"]
|
||||||
if has_webrtc:
|
#if has_webrtc:
|
||||||
env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
|
# env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
|
||||||
|
|
||||||
env_net.add_source_files(env.modules_sources, "*.cpp")
|
env_net.add_source_files(env.modules_sources, "*.cpp")
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
#define MULTIPLAYER_PEER_GDNATIVE_H
|
#define MULTIPLAYER_PEER_GDNATIVE_H
|
||||||
|
|
||||||
#include "core/io/networked_multiplayer_peer.h"
|
#include "core/io/networked_multiplayer_peer.h"
|
||||||
#include "modules/gdnative/gdnative.h"
|
#include "../gdnative.h"
|
||||||
#include "modules/gdnative/include/net/godot_net.h"
|
#include "../include/net/godot_net.h"
|
||||||
|
|
||||||
class MultiplayerPeerGDNative : public NetworkedMultiplayerPeer {
|
class MultiplayerPeerGDNative : public NetworkedMultiplayerPeer {
|
||||||
GDCLASS(MultiplayerPeerGDNative, NetworkedMultiplayerPeer);
|
GDCLASS(MultiplayerPeerGDNative, NetworkedMultiplayerPeer);
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
#define PACKET_PEER_GDNATIVE_H
|
#define PACKET_PEER_GDNATIVE_H
|
||||||
|
|
||||||
#include "core/io/packet_peer.h"
|
#include "core/io/packet_peer.h"
|
||||||
#include "modules/gdnative/gdnative.h"
|
#include "../gdnative.h"
|
||||||
#include "modules/gdnative/include/net/godot_net.h"
|
#include "../include/net/godot_net.h"
|
||||||
|
|
||||||
class PacketPeerGDNative : public PacketPeer {
|
class PacketPeerGDNative : public PacketPeer {
|
||||||
GDCLASS(PacketPeerGDNative, PacketPeer);
|
GDCLASS(PacketPeerGDNative, PacketPeer);
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
#define STREAM_PEER_GDNATIVE_H
|
#define STREAM_PEER_GDNATIVE_H
|
||||||
|
|
||||||
#include "core/io/stream_peer.h"
|
#include "core/io/stream_peer.h"
|
||||||
#include "modules/gdnative/gdnative.h"
|
#include "../gdnative.h"
|
||||||
#include "modules/gdnative/include/net/godot_net.h"
|
#include "../include/net/godot_net.h"
|
||||||
|
|
||||||
class StreamPeerGDNative : public StreamPeer {
|
class StreamPeerGDNative : public StreamPeer {
|
||||||
GDCLASS(StreamPeerGDNative, StreamPeer);
|
GDCLASS(StreamPeerGDNative, StreamPeer);
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include "modules/gdnative/gdnative.h"
|
#include "../gdnative.h"
|
||||||
#include "modules/gdnative/include/net/godot_net.h"
|
#include "../include/net/godot_net.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_GDNATIVE_ENABLED
|
#ifdef WEBRTC_GDNATIVE_ENABLED
|
||||||
#include "modules/webrtc/webrtc_data_channel_gdnative.h"
|
#include "webrtc/webrtc_data_channel_gdnative.h"
|
||||||
#include "modules/webrtc/webrtc_peer_connection_gdnative.h"
|
#include "webrtc/webrtc_peer_connection_gdnative.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
// Godot imports
|
// Godot imports
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/variant.h"
|
#include "core/variant/variant.h"
|
||||||
|
|
||||||
// PluginScript imports
|
// PluginScript imports
|
||||||
#include "pluginscript_language.h"
|
#include "pluginscript_language.h"
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define PLUGINSCRIPT_INSTANCE_H
|
#define PLUGINSCRIPT_INSTANCE_H
|
||||||
|
|
||||||
// Godot imports
|
// Godot imports
|
||||||
#include "core/script_language.h"
|
#include "core/object/script_language.h"
|
||||||
|
|
||||||
// PluginScript imports
|
// PluginScript imports
|
||||||
#include <pluginscript/godot_pluginscript.h>
|
#include <pluginscript/godot_pluginscript.h>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
// Godot imports
|
// Godot imports
|
||||||
#include "core/os/file_access.h"
|
#include "core/os/file_access.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
// PluginScript imports
|
// PluginScript imports
|
||||||
#include "pluginscript_language.h"
|
#include "pluginscript_language.h"
|
||||||
#include "pluginscript_script.h"
|
#include "pluginscript_script.h"
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
// Godot imports
|
// Godot imports
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/map.h"
|
#include "core/containers/rb_map.h"
|
||||||
#include "core/script_language.h"
|
#include "core/object/script_language.h"
|
||||||
#include "core/self_list.h"
|
#include "core/containers/self_list.h"
|
||||||
// PluginScript imports
|
// PluginScript imports
|
||||||
#include "pluginscript_loader.h"
|
#include "pluginscript_loader.h"
|
||||||
#include <pluginscript/godot_pluginscript.h>
|
#include <pluginscript/godot_pluginscript.h>
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
// Godot imports
|
// Godot imports
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/script_language.h"
|
#include "core/object/script_language.h"
|
||||||
|
|
||||||
class PluginScriptLanguage;
|
class PluginScriptLanguage;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#define PLUGINSCRIPT_SCRIPT_H
|
#define PLUGINSCRIPT_SCRIPT_H
|
||||||
|
|
||||||
// Godot imports
|
// Godot imports
|
||||||
#include "core/script_language.h"
|
#include "core/object/script_language.h"
|
||||||
// PluginScript imports
|
// PluginScript imports
|
||||||
#include "pluginscript_language.h"
|
#include "pluginscript_language.h"
|
||||||
#include <pluginscript/godot_pluginscript.h>
|
#include <pluginscript/godot_pluginscript.h>
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/os/dir_access.h"
|
#include "core/os/dir_access.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "scene/main/scene_tree.h"
|
#include "scene/main/scene_tree.h"
|
||||||
|
|
||||||
#include "pluginscript_language.h"
|
#include "pluginscript_language.h"
|
||||||
|
@ -30,21 +30,18 @@
|
|||||||
|
|
||||||
#include "register_types.h"
|
#include "register_types.h"
|
||||||
|
|
||||||
#include "gdnative/gdnative.h"
|
|
||||||
|
|
||||||
#include "gdnative.h"
|
#include "gdnative.h"
|
||||||
|
|
||||||
#include "arvr/register_types.h"
|
|
||||||
#include "nativescript/register_types.h"
|
#include "nativescript/register_types.h"
|
||||||
#include "net/register_types.h"
|
#include "net/register_types.h"
|
||||||
#include "pluginscript/register_types.h"
|
#include "pluginscript/register_types.h"
|
||||||
#include "videodecoder/register_types.h"
|
#include "videodecoder/register_types.h"
|
||||||
|
|
||||||
#include "core/engine.h"
|
#include "core/config/engine.h"
|
||||||
#include "core/io/resource_loader.h"
|
#include "core/io/resource_loader.h"
|
||||||
#include "core/io/resource_saver.h"
|
#include "core/io/resource_saver.h"
|
||||||
#include "core/os/os.h"
|
#include "core/os/os.h"
|
||||||
#include "core/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
|
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
#include "editor/editor_export.h"
|
#include "editor/editor_export.h"
|
||||||
@ -253,120 +250,123 @@ Vector<Ref<GDNative>> singleton_gdnatives;
|
|||||||
Ref<GDNativeLibraryResourceLoader> resource_loader_gdnlib;
|
Ref<GDNativeLibraryResourceLoader> resource_loader_gdnlib;
|
||||||
Ref<GDNativeLibraryResourceSaver> resource_saver_gdnlib;
|
Ref<GDNativeLibraryResourceSaver> resource_saver_gdnlib;
|
||||||
|
|
||||||
void register_gdnative_types() {
|
void register_gdnative_types(ModuleRegistrationLevel p_level) {
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
|
if (p_level == MODULE_REGISTRATION_LEVEL_EDITOR) {
|
||||||
EditorNode::add_init_callback(editor_init_callback);
|
EditorNode::add_init_callback(editor_init_callback);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ClassDB::register_class<GDNativeLibrary>();
|
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
|
||||||
ClassDB::register_class<GDNative>();
|
ClassDB::register_class<GDNativeLibrary>();
|
||||||
|
ClassDB::register_class<GDNative>();
|
||||||
|
|
||||||
resource_loader_gdnlib.instance();
|
resource_loader_gdnlib.instance();
|
||||||
ResourceLoader::add_resource_format_loader(resource_loader_gdnlib);
|
ResourceLoader::add_resource_format_loader(resource_loader_gdnlib);
|
||||||
|
|
||||||
resource_saver_gdnlib.instance();
|
resource_saver_gdnlib.instance();
|
||||||
ResourceSaver::add_resource_format_saver(resource_saver_gdnlib);
|
ResourceSaver::add_resource_format_saver(resource_saver_gdnlib);
|
||||||
|
|
||||||
GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
|
GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
|
||||||
|
|
||||||
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
|
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
|
||||||
|
|
||||||
register_net_types();
|
register_net_types();
|
||||||
register_arvr_types();
|
register_nativescript_types();
|
||||||
register_nativescript_types();
|
register_pluginscript_types();
|
||||||
register_pluginscript_types();
|
register_videodecoder_types();
|
||||||
register_videodecoder_types();
|
|
||||||
|
|
||||||
// run singletons
|
// run singletons
|
||||||
|
|
||||||
Array singletons = Array();
|
Array singletons = Array();
|
||||||
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
|
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
|
||||||
singletons = ProjectSettings::get_singleton()->get("gdnative/singletons");
|
singletons = ProjectSettings::get_singleton()->get("gdnative/singletons");
|
||||||
}
|
}
|
||||||
Array excluded = Array();
|
Array excluded = Array();
|
||||||
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) {
|
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) {
|
||||||
excluded = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled");
|
excluded = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled");
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < singletons.size(); i++) {
|
|
||||||
String path = singletons[i];
|
|
||||||
|
|
||||||
if (excluded.has(path)) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
|
for (int i = 0; i < singletons.size(); i++) {
|
||||||
Ref<GDNative> singleton;
|
String path = singletons[i];
|
||||||
singleton.instance();
|
|
||||||
singleton->set_library(lib);
|
|
||||||
|
|
||||||
if (!singleton->initialize()) {
|
if (excluded.has(path)) {
|
||||||
// Can't initialize. Don't make a native_call then
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void *proc_ptr;
|
Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
|
||||||
Error err = singleton->get_symbol(
|
Ref<GDNative> singleton;
|
||||||
lib->get_symbol_prefix() + "gdnative_singleton",
|
singleton.instance();
|
||||||
proc_ptr);
|
singleton->set_library(lib);
|
||||||
|
|
||||||
if (err != OK) {
|
if (!singleton->initialize()) {
|
||||||
ERR_PRINT("No " + lib->get_symbol_prefix() + "gdnative_singleton in \"" + singleton->get_library()->get_current_library_path() + "\" found");
|
// Can't initialize. Don't make a native_call then
|
||||||
} else {
|
continue;
|
||||||
singleton_gdnatives.push_back(singleton);
|
}
|
||||||
((void (*)())proc_ptr)();
|
|
||||||
|
void *proc_ptr;
|
||||||
|
Error err = singleton->get_symbol(
|
||||||
|
lib->get_symbol_prefix() + "gdnative_singleton",
|
||||||
|
proc_ptr);
|
||||||
|
|
||||||
|
if (err != OK) {
|
||||||
|
ERR_PRINT("No " + lib->get_symbol_prefix() + "gdnative_singleton in \"" + singleton->get_library()->get_current_library_path() + "\" found");
|
||||||
|
} else {
|
||||||
|
singleton_gdnatives.push_back(singleton);
|
||||||
|
((void (*)())proc_ptr)();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregister_gdnative_types() {
|
void unregister_gdnative_types(ModuleRegistrationLevel p_level) {
|
||||||
for (int i = 0; i < singleton_gdnatives.size(); i++) {
|
if (p_level == MODULE_REGISTRATION_LEVEL_SINGLETON) {
|
||||||
if (singleton_gdnatives[i].is_null()) {
|
for (int i = 0; i < singleton_gdnatives.size(); i++) {
|
||||||
continue;
|
if (singleton_gdnatives[i].is_null()) {
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!singleton_gdnatives[i]->is_initialized()) {
|
if (!singleton_gdnatives[i]->is_initialized()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
singleton_gdnatives.write[i]->terminate();
|
singleton_gdnatives.write[i]->terminate();
|
||||||
|
}
|
||||||
|
singleton_gdnatives.clear();
|
||||||
|
|
||||||
|
unregister_videodecoder_types();
|
||||||
|
unregister_pluginscript_types();
|
||||||
|
unregister_nativescript_types();
|
||||||
|
unregister_net_types();
|
||||||
|
|
||||||
|
memdelete(GDNativeCallRegistry::singleton);
|
||||||
|
|
||||||
|
ResourceLoader::remove_resource_format_loader(resource_loader_gdnlib);
|
||||||
|
resource_loader_gdnlib.unref();
|
||||||
|
|
||||||
|
ResourceSaver::remove_resource_format_saver(resource_saver_gdnlib);
|
||||||
|
resource_saver_gdnlib.unref();
|
||||||
|
|
||||||
|
// This is for printing out the sizes of the core types
|
||||||
|
|
||||||
|
/*
|
||||||
|
print_line(String("array:\t") + itos(sizeof(Array)));
|
||||||
|
print_line(String("basis:\t") + itos(sizeof(Basis)));
|
||||||
|
print_line(String("color:\t") + itos(sizeof(Color)));
|
||||||
|
print_line(String("dict:\t" ) + itos(sizeof(Dictionary)));
|
||||||
|
print_line(String("node_path:\t") + itos(sizeof(NodePath)));
|
||||||
|
print_line(String("plane:\t") + itos(sizeof(Plane)));
|
||||||
|
print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray)));
|
||||||
|
print_line(String("quat:\t") + itos(sizeof(Quat)));
|
||||||
|
print_line(String("rect2:\t") + itos(sizeof(Rect2)));
|
||||||
|
print_line(String("aabb:\t") + itos(sizeof(AABB)));
|
||||||
|
print_line(String("rid:\t") + itos(sizeof(RID)));
|
||||||
|
print_line(String("string:\t") + itos(sizeof(String)));
|
||||||
|
print_line(String("transform:\t") + itos(sizeof(Transform)));
|
||||||
|
print_line(String("transfo2D:\t") + itos(sizeof(Transform2D)));
|
||||||
|
print_line(String("variant:\t") + itos(sizeof(Variant)));
|
||||||
|
print_line(String("vector2:\t") + itos(sizeof(Vector2)));
|
||||||
|
print_line(String("vector3:\t") + itos(sizeof(Vector3)));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
singleton_gdnatives.clear();
|
|
||||||
|
|
||||||
unregister_videodecoder_types();
|
|
||||||
unregister_pluginscript_types();
|
|
||||||
unregister_nativescript_types();
|
|
||||||
unregister_arvr_types();
|
|
||||||
unregister_net_types();
|
|
||||||
|
|
||||||
memdelete(GDNativeCallRegistry::singleton);
|
|
||||||
|
|
||||||
ResourceLoader::remove_resource_format_loader(resource_loader_gdnlib);
|
|
||||||
resource_loader_gdnlib.unref();
|
|
||||||
|
|
||||||
ResourceSaver::remove_resource_format_saver(resource_saver_gdnlib);
|
|
||||||
resource_saver_gdnlib.unref();
|
|
||||||
|
|
||||||
// This is for printing out the sizes of the core types
|
|
||||||
|
|
||||||
/*
|
|
||||||
print_line(String("array:\t") + itos(sizeof(Array)));
|
|
||||||
print_line(String("basis:\t") + itos(sizeof(Basis)));
|
|
||||||
print_line(String("color:\t") + itos(sizeof(Color)));
|
|
||||||
print_line(String("dict:\t" ) + itos(sizeof(Dictionary)));
|
|
||||||
print_line(String("node_path:\t") + itos(sizeof(NodePath)));
|
|
||||||
print_line(String("plane:\t") + itos(sizeof(Plane)));
|
|
||||||
print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray)));
|
|
||||||
print_line(String("quat:\t") + itos(sizeof(Quat)));
|
|
||||||
print_line(String("rect2:\t") + itos(sizeof(Rect2)));
|
|
||||||
print_line(String("aabb:\t") + itos(sizeof(AABB)));
|
|
||||||
print_line(String("rid:\t") + itos(sizeof(RID)));
|
|
||||||
print_line(String("string:\t") + itos(sizeof(String)));
|
|
||||||
print_line(String("transform:\t") + itos(sizeof(Transform)));
|
|
||||||
print_line(String("transfo2D:\t") + itos(sizeof(Transform2D)));
|
|
||||||
print_line(String("variant:\t") + itos(sizeof(Variant)));
|
|
||||||
print_line(String("vector2:\t") + itos(sizeof(Vector2)));
|
|
||||||
print_line(String("vector3:\t") + itos(sizeof(Vector3)));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef GDNATIVE_REGISTER_TYPES_H
|
||||||
|
#define GDNATIVE_REGISTER_TYPES_H
|
||||||
|
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
/* register_types.h */
|
/* register_types.h */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
@ -28,10 +31,9 @@
|
|||||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#ifndef GDNATIVE_REGISTER_TYPES_H
|
#include "modules/register_module_types.h"
|
||||||
#define GDNATIVE_REGISTER_TYPES_H
|
|
||||||
|
|
||||||
void register_gdnative_types();
|
void register_gdnative_types(ModuleRegistrationLevel p_level);
|
||||||
void unregister_gdnative_types();
|
void unregister_gdnative_types(ModuleRegistrationLevel p_level);
|
||||||
|
|
||||||
#endif // GDNATIVE_REGISTER_TYPES_H
|
#endif // GDNATIVE_REGISTER_TYPES_H
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "register_types.h"
|
#include "register_types.h"
|
||||||
|
|
||||||
#include "core/class_db.h"
|
#include "core/object/class_db.h"
|
||||||
#include "video_stream_gdnative.h"
|
#include "video_stream_gdnative.h"
|
||||||
|
|
||||||
static Ref<ResourceFormatLoaderVideoStreamGDNative> resource_loader_vsgdnative;
|
static Ref<ResourceFormatLoaderVideoStreamGDNative> resource_loader_vsgdnative;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "video_stream_gdnative.h"
|
#include "video_stream_gdnative.h"
|
||||||
|
|
||||||
#include "core/project_settings.h"
|
#include "core/config/project_settings.h"
|
||||||
#include "servers/audio_server.h"
|
#include "servers/audio_server.h"
|
||||||
|
|
||||||
VideoDecoderServer *VideoDecoderServer::instance = nullptr;
|
VideoDecoderServer *VideoDecoderServer::instance = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user