summaryrefslogtreecommitdiff
path: root/core/extension
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-03-14 15:52:03 +0100
committerreduz <reduzio@gmail.com>2022-03-15 18:39:31 +0100
commit8b547331bec150b682fda94da1568fbcbda689ba (patch)
tree49159fd03ccc81cbfc2b4c6a70d1b7f1ac9cc5a1 /core/extension
parent41edfc88a3f82e643ad3f4613de7a787a00ee68a (diff)
Create GDExtension clases for PhysicsServer3D
* Allows creating a GDExtension based 3D Physics Server (for Bullet, PhysX, etc. support) * Some changes on native struct binding for PhysicsServer This allows a 3D Physics server created entirely from GDExtension. Once it works, the idea is to port the 2D one to it.
Diffstat (limited to 'core/extension')
-rw-r--r--core/extension/extension_api_dump.cpp25
-rw-r--r--core/extension/gdnative_interface.cpp6
-rw-r--r--core/extension/gdnative_interface.h2
3 files changed, 15 insertions, 18 deletions
diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp
index 3687e4f7e5..31af28b783 100644
--- a/core/extension/extension_api_dump.cpp
+++ b/core/extension/extension_api_dump.cpp
@@ -841,27 +841,16 @@ Dictionary NativeExtensionAPIDump::generate_extension_api() {
{
Array native_structures;
- // AudioStream structures
- {
- Dictionary d;
- d["name"] = "AudioFrame";
- d["format"] = "float left,float right";
+ List<StringName> native_structs;
+ ClassDB::get_native_struct_list(&native_structs);
+ native_structs.sort_custom<StringName::AlphCompare>();
- native_structures.push_back(d);
- }
+ for (const StringName &E : native_structs) {
+ String code = ClassDB::get_native_struct_code(E);
- // TextServer structures
- {
- Dictionary d;
- d["name"] = "Glyph";
- d["format"] = "int start,int end,uint8_t count,uint8_t repeat,uint16_t flags,float x_off,float y_off,float advance,RID font_rid,int font_size,int32_t index";
-
- native_structures.push_back(d);
- }
- {
Dictionary d;
- d["name"] = "CaretInfo";
- d["format"] = "Rect2 leading_caret,Rect2 trailing_caret,TextServer::Direction leading_direction,TextServer::Direction trailing_direction";
+ d["name"] = String(E);
+ d["format"] = code;
native_structures.push_back(d);
}
diff --git a/core/extension/gdnative_interface.cpp b/core/extension/gdnative_interface.cpp
index d9ec42dc9d..d0461611ec 100644
--- a/core/extension/gdnative_interface.cpp
+++ b/core/extension/gdnative_interface.cpp
@@ -60,6 +60,10 @@ static void gdnative_print_script_error(const char *p_description, const char *p
_err_print_error(p_function, p_file, p_line, p_description, false, ERR_HANDLER_SCRIPT);
}
+uint64_t gdnative_get_native_struct_size(const char *p_name) {
+ return ClassDB::get_native_struct_size(p_name);
+}
+
// Variant functions
static void gdnative_variant_new_copy(GDNativeVariantPtr r_dest, const GDNativeVariantPtr p_src) {
@@ -902,6 +906,8 @@ void gdnative_setup_interface(GDNativeInterface *p_interface) {
gdni.print_warning = gdnative_print_warning;
gdni.print_script_error = gdnative_print_script_error;
+ gdni.get_native_struct_size = gdnative_get_native_struct_size;
+
/* GODOT VARIANT */
// variant general
diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h
index 76e87eaf23..cc2957ec56 100644
--- a/core/extension/gdnative_interface.h
+++ b/core/extension/gdnative_interface.h
@@ -306,6 +306,8 @@ typedef struct {
void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
+ uint64_t (*get_native_struct_size)(const char *p_name);
+
/* GODOT VARIANT */
/* variant general */