Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/vnen/godot-cpp
url = https://github.com/godotengine/godot-cpp
2 changes: 1 addition & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ opts.Add(PathVariable("target_path", "The path where the lib is installed.", "de
opts.Add(PathVariable("target_name", "The library name.", "libgdxrreference", PathVariable.PathAccept))

# Local dependency paths, adapt them to your setup
godot_headers_path = "godot-cpp/godot-headers-temp/"
godot_headers_path = "godot-cpp/godot-headers/"
cpp_bindings_path = "godot-cpp/"
cpp_library = "libgodot-cpp"

Expand Down
22 changes: 4 additions & 18 deletions demo/Main.gd
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
extends Node3D


# Declare member variables here. Examples:
# var a = 2
# var b = "text"


# Called when the node enters the scene tree for the first time.
func _ready():
# this needs to move into our plugin but we can't access our XRServer singleton yet...
var interface : XRInterfaceReference = XRInterfaceReference.new()
if interface:
print("Adding " + str(interface.get_name()))
print("Capabilities " + str(interface.get_capabilities()))
print("Target size " + str(interface.get_render_target_size()))

XRServer.add_interface(interface)
else:
print("Couldn't instantiate interface")
return
print("Interfaces: " + str(XRServer.get_interfaces()))

# and this is our real init, but we skip find_interface due to our get_name bug
var xr_interface = XRServer.find_interface("XR Reference")
if xr_interface:
print("Found " + str(xr_interface.get_name()))
print("Capabilities " + str(xr_interface.get_capabilities()))
print("Target size " + str(xr_interface.get_render_target_size()))

if xr_interface.initialize():
get_viewport().use_xr = true

Expand Down
4 changes: 2 additions & 2 deletions demo/addons/godot_xr_reference/godot_xr_reference.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ entry_symbol = "xrreference_library_init"

[libraries]

Linux.64 = "bin/x11/libgdxrreference.so"
Windows.64 = "bin/win64/libgdxrreference.dll"
linux.64 = "bin/x11/libgdxrreference.so"
windows.64 = "bin/win64/libgdxrreference.dll"
2 changes: 1 addition & 1 deletion godot-cpp
Submodule godot-cpp updated 59 files
+16 −36 .github/workflows/ci.yml
+2 −2 CMakeLists.txt
+49 −29 README.md
+1 −1 SConstruct
+24 −28 binding_generator.py
+1 −1 godot-headers
+0 −6 godot-headers-temp/README.md
+0 −212,894 godot-headers-temp/extension_api.json
+0 −475 godot-headers-temp/godot/gdnative_interface.h
+40 −21 include/godot_cpp/classes/ref.hpp
+156 −110 include/godot_cpp/classes/wrapped.hpp
+45 −17 include/godot_cpp/core/class_db.hpp
+2 −2 include/godot_cpp/core/engine_ptrcall.hpp
+30 −1 include/godot_cpp/core/math.hpp
+20 −2 include/godot_cpp/core/memory.hpp
+1 −1 include/godot_cpp/core/method_bind.hpp
+4 −4 include/godot_cpp/core/method_ptrcall.hpp
+2 −0 include/godot_cpp/core/object.hpp
+31 −0 include/godot_cpp/godot.hpp
+30 −0 include/godot_cpp/variant/aabb.hpp
+30 −0 include/godot_cpp/variant/basis.hpp
+30 −0 include/godot_cpp/variant/color.hpp
+30 −0 include/godot_cpp/variant/color_names.inc.hpp
+31 −1 include/godot_cpp/variant/plane.hpp
+30 −0 include/godot_cpp/variant/quaternion.hpp
+30 −1 include/godot_cpp/variant/rect2.hpp
+30 −0 include/godot_cpp/variant/rect2i.hpp
+30 −0 include/godot_cpp/variant/transform2d.hpp
+31 −1 include/godot_cpp/variant/transform3d.hpp
+30 −0 include/godot_cpp/variant/vector2.hpp
+30 −0 include/godot_cpp/variant/vector2i.hpp
+30 −0 include/godot_cpp/variant/vector3.hpp
+30 −0 include/godot_cpp/variant/vector3i.hpp
+88 −91 src/core/class_db.cpp
+1 −1 src/core/error_macros.cpp
+70 −4 src/godot.cpp
+30 −0 src/variant/aabb.cpp
+30 −0 src/variant/basis.cpp
+2 −2 src/variant/char_string.cpp
+30 −0 src/variant/color.cpp
+38 −8 src/variant/packed_arrays.cpp
+31 −1 src/variant/plane.cpp
+30 −0 src/variant/quaternion.cpp
+30 −0 src/variant/rect2.cpp
+30 −0 src/variant/rect2i.cpp
+30 −0 src/variant/transform2d.cpp
+30 −0 src/variant/transform3d.cpp
+31 −1 src/variant/vector2.cpp
+31 −1 src/variant/vector2i.cpp
+31 −1 src/variant/vector3.cpp
+31 −1 src/variant/vector3i.cpp
+1 −1 test/SConstruct
+2 −2 test/demo/example.gdextension
+8 −8 test/demo/main.gd
+5 −3 test/demo/main.tscn
+47 −1 test/src/example.cpp
+42 −0 test/src/example.h
+35 −5 test/src/register_types.cpp
+30 −0 test/src/register_types.h
18 changes: 11 additions & 7 deletions src/register_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
using namespace godot;

void register_types() {
// UtilityFunctions::print("Hello register types!");

ClassDB::register_class<XRInterfaceReference>();

XRServer *xr_server = XRServer::get_singleton();
ERR_FAIL_NULL(xr_server);

Ref<XRInterfaceReference> interface;
interface.instantiate();
xr_server->add_interface(interface);
}

void unregister_types() {}
Expand All @@ -25,12 +30,11 @@ extern "C" {
// Initialization.

GDNativeBool GDN_EXPORT xrreference_library_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
GDNativeBool result = godot::GDExtensionBinding::init(p_interface, p_library, r_initialization);
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);

if (result) {
register_types();
}
init_obj.register_driver_initializer(register_types);
init_obj.register_driver_terminator(unregister_types);

return result;
return init_obj.init();
}
}
26 changes: 17 additions & 9 deletions src/xr_interface_reference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ bool XRInterfaceReference::_initialize() {
// do any initialisation here..
xr_server = XRServer::get_singleton();
if (xr_server == nullptr) {
UtilityFunctions::printerr("Couldn't obtain XRServer singleton");
return false;
ERR_FAIL_V_MSG(false, "Couldn't obtain XRServer singleton");
}

xr_server->set_primary_interface(this);
Expand Down Expand Up @@ -266,24 +265,25 @@ PackedFloat64Array XRInterfaceReference::_get_projection_for_view(int64_t p_view
}

void XRInterfaceReference::_commit_views(const RID &p_render_target, const Rect2 &p_screen_rect) {
Rect2 rect = p_screen_rect;
Rect2 src_rect(0.0f, 0.0f, 1.0f, 1.0f);
Rect2 dst_rect = p_screen_rect;

// halve our width
Vector2 size = rect.get_size();
Vector2 size = dst_rect.get_size();
size.x = size.x * 0.5;
rect.size = size;
dst_rect.size = size;

Vector2 eye_center(((-intraocular_dist / 2.0) + (display_width / 4.0)) / (display_width / 2.0), 0.0);

add_blit(p_render_target, rect, true, 0, true, eye_center, k1, k2, oversample, aspect);
add_blit(p_render_target, src_rect, dst_rect, true, 0, true, eye_center, k1, k2, oversample, aspect);

// move rect
Vector2 pos = rect.get_position();
Vector2 pos = dst_rect.get_position();
pos.x = size.x;
rect.position = pos;
dst_rect.position = pos;

eye_center.x = ((intraocular_dist / 2.0) - (display_width / 4.0)) / (display_width / 2.0);
add_blit(p_render_target, rect, true, 1, true, eye_center, k1, k2, oversample, aspect);
add_blit(p_render_target, src_rect, dst_rect, true, 1, true, eye_center, k1, k2, oversample, aspect);
}

void XRInterfaceReference::_process() {
Expand All @@ -305,3 +305,11 @@ void XRInterfaceReference::_set_anchor_detection_is_enabled(bool enabled) {
int64_t XRInterfaceReference::_get_camera_feed_id() const {
return 0;
}

XRInterfaceReference::XRInterfaceReference() {

}

XRInterfaceReference::~XRInterfaceReference() {

}
3 changes: 3 additions & 0 deletions src/xr_interface_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ class XRInterfaceReference : public XRInterfaceExtension {
virtual bool _get_anchor_detection_is_enabled() const override;
virtual void _set_anchor_detection_is_enabled(bool enabled) override;
virtual int64_t _get_camera_feed_id() const override;

XRInterfaceReference();
~XRInterfaceReference();
};
} // namespace godot

Expand Down