diff options
author | reduz <reduzio@gmail.com> | 2022-03-14 15:52:03 +0100 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-03-15 18:39:31 +0100 |
commit | 8b547331bec150b682fda94da1568fbcbda689ba (patch) | |
tree | 49159fd03ccc81cbfc2b4c6a70d1b7f1ac9cc5a1 /core/object/class_db.cpp | |
parent | 41edfc88a3f82e643ad3f4613de7a787a00ee68a (diff) | |
download | redot-engine-8b547331bec150b682fda94da1568fbcbda689ba.tar.gz |
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/object/class_db.cpp')
-rw-r--r-- | core/object/class_db.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 08e12dfcaa..e09c6cb97c 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -1606,7 +1606,7 @@ Variant ClassDB::class_get_default_property_value(const StringName &p_class, con if (Engine::get_singleton()->has_singleton(p_class)) { c = Engine::get_singleton()->get_singleton_object(p_class); cleanup_c = false; - } else if (ClassDB::can_instantiate(p_class)) { + } else if (ClassDB::can_instantiate(p_class) && !ClassDB::is_virtual(p_class)) { c = ClassDB::instantiate(p_class); cleanup_c = true; } @@ -1694,6 +1694,30 @@ void ClassDB::unregister_extension_class(const StringName &p_class) { classes.erase(p_class); } +Map<StringName, ClassDB::NativeStruct> ClassDB::native_structs; +void ClassDB::register_native_struct(const StringName &p_name, const String &p_code, uint64_t p_current_size) { + NativeStruct ns; + ns.ccode = p_code; + ns.struct_size = p_current_size; + native_structs[p_name] = ns; +} + +void ClassDB::get_native_struct_list(List<StringName> *r_names) { + for (const KeyValue<StringName, NativeStruct> &E : native_structs) { + r_names->push_back(E.key); + } +} + +String ClassDB::get_native_struct_code(const StringName &p_name) { + ERR_FAIL_COND_V(!native_structs.has(p_name), String()); + return native_structs[p_name].ccode; +} + +uint64_t ClassDB::get_native_struct_size(const StringName &p_name) { + ERR_FAIL_COND_V(!native_structs.has(p_name), 0); + return native_structs[p_name].struct_size; +} + RWLock ClassDB::lock; void ClassDB::cleanup_defaults() { @@ -1717,6 +1741,7 @@ void ClassDB::cleanup() { classes.clear(); resource_base_extensions.clear(); compat_classes.clear(); + native_structs.clear(); } // |