From 6f51eca1e3045571ccc68414a922e8b0229111f0 Mon Sep 17 00:00:00 2001 From: reduz Date: Thu, 10 Mar 2022 08:17:38 +0100 Subject: [PATCH] Discern between virtual and abstract class bindings * Previous "virtual" classes (which can't be instantiated) are not corretly named "abstract". * Added a new "virtual" category for classes, they can't be instantiated from the editor, but can be inherited from script and extensions. * Converted a large amount of classes from "abstract" to "virtual" where it makes sense. Most classes that make sense have been converted. Missing: * Physics servers * VideoStream * Script* classes. which will go in a separate PR due to the complexity involved. --- .github/workflows/linux_builds.yml | 4 +- core/extension/gdnative_interface.h | 2 + core/extension/native_extension.cpp | 1 + core/io/resource.cpp | 20 ++ core/object/class_db.cpp | 13 ++ core/object/class_db.h | 17 +- core/object/make_virtuals.py | 5 + core/object/object.h | 9 +- core/register_core_types.cpp | 32 ++-- doc/classes/AudioEffect.xml | 7 + doc/classes/AudioEffectInstance.xml | 15 ++ doc/classes/AudioStreamPlaybackResampled.xml | 19 ++ doc/classes/Material.xml | 22 ++- doc/classes/Mesh.xml | 83 +++++++++ doc/classes/PrimitiveMesh.xml | 5 + doc/classes/Range.xml | 6 + doc/classes/Resource.xml | 5 + doc/classes/StyleBox.xml | 31 +++ doc/classes/Texture2D.xml | 52 ++++++ doc/classes/Texture3D.xml | 30 +++ doc/classes/TextureLayered.xml | 36 ++++ doc/classes/VisualInstance3D.xml | 5 + editor/create_dialog.cpp | 4 +- editor/editor_audio_buses.cpp | 2 +- editor/editor_node.cpp | 14 +- .../gpu_particles_3d_editor_plugin.cpp | 8 +- editor/plugins/multimesh_editor_plugin.cpp | 6 +- editor/property_editor.cpp | 2 +- modules/csg/csg_shape.cpp | 4 - modules/csg/csg_shape.h | 1 - modules/csg/register_types.cpp | 4 +- modules/enet/register_types.cpp | 2 +- modules/minimp3/audio_stream_mp3.cpp | 2 +- modules/visual_script/register_types.cpp | 4 +- modules/vorbis/audio_stream_ogg_vorbis.cpp | 2 +- modules/webrtc/register_types.cpp | 2 +- modules/websocket/register_types.cpp | 2 +- modules/webxr/register_types.cpp | 2 +- platform/javascript/api/api.cpp | 4 +- scene/3d/cpu_particles_3d.cpp | 4 - scene/3d/cpu_particles_3d.h | 1 - scene/3d/decal.cpp | 4 - scene/3d/decal.h | 1 - scene/3d/fog_volume.h | 1 - scene/3d/gpu_particles_3d.cpp | 4 - scene/3d/gpu_particles_3d.h | 1 - scene/3d/gpu_particles_collision_3d.h | 4 - scene/3d/light_3d.cpp | 4 - scene/3d/light_3d.h | 1 - scene/3d/lightmap_gi.cpp | 4 - scene/3d/lightmap_gi.h | 1 - scene/3d/mesh_instance_3d.cpp | 12 -- scene/3d/mesh_instance_3d.h | 1 - scene/3d/multimesh_instance_3d.cpp | 4 - scene/3d/multimesh_instance_3d.h | 2 - scene/3d/occluder_instance_3d.cpp | 4 - scene/3d/occluder_instance_3d.h | 1 - scene/3d/reflection_probe.cpp | 4 - scene/3d/reflection_probe.h | 1 - scene/3d/sprite_3d.cpp | 4 - scene/3d/sprite_3d.h | 2 +- scene/3d/visible_on_screen_notifier_3d.cpp | 4 - scene/3d/visible_on_screen_notifier_3d.h | 2 - scene/3d/visual_instance_3d.cpp | 9 + scene/3d/visual_instance_3d.h | 4 +- scene/3d/voxel_gi.cpp | 4 - scene/3d/voxel_gi.h | 1 - scene/animation/root_motion_view.cpp | 4 - scene/animation/root_motion_view.h | 1 - scene/gui/range.cpp | 5 + scene/gui/range.h | 4 +- scene/gui/spin_box.cpp | 3 +- scene/gui/spin_box.h | 2 +- scene/register_scene_types.cpp | 94 +++++----- scene/resources/material.cpp | 36 ++++ scene/resources/material.h | 13 +- scene/resources/mesh.cpp | 131 +++++++++++++ scene/resources/mesh.h | 63 ++++--- scene/resources/primitive_meshes.cpp | 12 +- scene/resources/primitive_meshes.h | 3 +- scene/resources/style_box.cpp | 33 ++++ scene/resources/style_box.h | 10 +- scene/resources/texture.cpp | 176 +++++++++++++++++- scene/resources/texture.h | 58 ++++-- servers/audio/audio_effect.cpp | 31 +++ servers/audio/audio_effect.h | 18 +- servers/audio/audio_stream.cpp | 32 +++- servers/audio/audio_stream.h | 11 +- .../audio/effects/audio_stream_generator.cpp | 2 +- servers/register_server_types.cpp | 32 ++-- 90 files changed, 1075 insertions(+), 272 deletions(-) diff --git a/.github/workflows/linux_builds.yml b/.github/workflows/linux_builds.yml index bb3416743ba..d75680b4b51 100644 --- a/.github/workflows/linux_builds.yml +++ b/.github/workflows/linux_builds.yml @@ -36,7 +36,9 @@ jobs: tests: true sconsflags: float=64 use_asan=yes use_ubsan=yes proj-test: true - godot-cpp-test: true + # Can be turned off for PRs that intentionally break compat with godot-cpp, + # until both the upstream PR and the matching godot-cpp changes are merged. + godot-cpp-test: false bin: "./bin/godot.linuxbsd.double.tools.64.san" build-mono: false # Skip 2GiB artifact speeding up action. diff --git a/core/extension/gdnative_interface.h b/core/extension/gdnative_interface.h index 62934d1d733..76e87eaf233 100644 --- a/core/extension/gdnative_interface.h +++ b/core/extension/gdnative_interface.h @@ -194,6 +194,7 @@ typedef void *GDExtensionClassInstancePtr; typedef GDNativeBool (*GDNativeExtensionClassSet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, const GDNativeVariantPtr p_value); typedef GDNativeBool (*GDNativeExtensionClassGet)(GDExtensionClassInstancePtr p_instance, const GDNativeStringNamePtr p_name, GDNativeVariantPtr r_ret); +typedef uint64_t (*GDNativeExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance); typedef struct { uint32_t type; @@ -228,6 +229,7 @@ typedef struct { GDNativeExtensionClassCreateInstance create_instance_func; /* this one is mandatory */ GDNativeExtensionClassFreeInstance free_instance_func; /* this one is mandatory */ GDNativeExtensionClassGetVirtual get_virtual_func; + GDNativeExtensionClassGetRID get_rid_func; void *class_userdata; } GDNativeExtensionClassCreationInfo; diff --git a/core/extension/native_extension.cpp b/core/extension/native_extension.cpp index 325ccec6c4f..1a39c937e86 100644 --- a/core/extension/native_extension.cpp +++ b/core/extension/native_extension.cpp @@ -158,6 +158,7 @@ void NativeExtension::_register_extension_class(const GDNativeExtensionClassLibr extension->native_extension.create_instance = p_extension_funcs->create_instance_func; extension->native_extension.free_instance = p_extension_funcs->free_instance_func; extension->native_extension.get_virtual = p_extension_funcs->get_virtual_func; + extension->native_extension.get_rid = p_extension_funcs->get_rid_func; ClassDB::register_extension_class(&extension->native_extension); } diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 66d5c54b53a..f90a6e93047 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -290,6 +290,21 @@ void Resource::_take_over_path(const String &p_path) { } RID Resource::get_rid() const { + if (get_script_instance()) { + Callable::CallError ce; + RID ret = get_script_instance()->callp(SNAME("_get_rid"), nullptr, 0, ce); + if (ce.error == Callable::CallError::CALL_OK && ret.is_valid()) { + return ret; + } + } + if (_get_extension() && _get_extension()->get_rid) { + RID ret; + ret.from_uint64(_get_extension()->get_rid(_get_extension_instance())); + if (ret.is_valid()) { + return ret; + } + } + return RID(); } @@ -428,6 +443,11 @@ void Resource::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "resource_local_to_scene"), "set_local_to_scene", "is_local_to_scene"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "resource_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_path", "get_path"); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "resource_name"), "set_name", "get_name"); + + MethodInfo get_rid_bind("_get_rid"); + get_rid_bind.return_val.type = Variant::RID; + + ::ClassDB::add_virtual_method(get_class_static(), get_rid_bind, true, Vector(), true); } Resource::Resource() : diff --git a/core/object/class_db.cpp b/core/object/class_db.cpp index 4a71597f84f..08e12dfcaa5 100644 --- a/core/object/class_db.cpp +++ b/core/object/class_db.cpp @@ -557,6 +557,19 @@ bool ClassDB::can_instantiate(const StringName &p_class) { return (!ti->disabled && ti->creation_func != nullptr && !(ti->native_extension && !ti->native_extension->create_instance)); } +bool ClassDB::is_virtual(const StringName &p_class) { + OBJTYPE_RLOCK; + + ClassInfo *ti = classes.getptr(p_class); + ERR_FAIL_COND_V_MSG(!ti, false, "Cannot get class '" + String(p_class) + "'."); +#ifdef TOOLS_ENABLED + if (ti->api == API_EDITOR && !Engine::get_singleton()->is_editor_hint()) { + return false; + } +#endif + return (!ti->disabled && ti->creation_func != nullptr && !(ti->native_extension && !ti->native_extension->create_instance) && ti->is_virtual); +} + void ClassDB::_add_class2(const StringName &p_class, const StringName &p_inherits) { OBJTYPE_WLOCK; diff --git a/core/object/class_db.h b/core/object/class_db.h index 5d258a29bff..580ae3582f8 100644 --- a/core/object/class_db.h +++ b/core/object/class_db.h @@ -118,6 +118,7 @@ public: StringName name; bool disabled = false; bool exposed = false; + bool is_virtual = false; Object *(*creation_func)() = nullptr; ClassInfo() {} @@ -156,20 +157,21 @@ public: } template - static void register_class() { + static void register_class(bool p_virtual = false) { GLOBAL_LOCK_FUNCTION; T::initialize_class(); ClassInfo *t = classes.getptr(T::get_class_static()); ERR_FAIL_COND(!t); t->creation_func = &creator; t->exposed = true; + t->is_virtual = p_virtual; t->class_ptr = T::get_class_ptr_static(); t->api = current_api; T::register_custom_data_to_otdb(); } template - static void register_virtual_class() { + static void register_abstract_class() { GLOBAL_LOCK_FUNCTION; T::initialize_class(); ClassInfo *t = classes.getptr(T::get_class_static()); @@ -210,6 +212,7 @@ public: static bool class_exists(const StringName &p_class); static bool is_parent_class(const StringName &p_class, const StringName &p_inherits); static bool can_instantiate(const StringName &p_class); + static bool is_virtual(const StringName &p_class); static Object *instantiate(const StringName &p_class); static void set_object_extension_instance(Object *p_object, const StringName &p_class, GDExtensionClassInstancePtr p_instance); @@ -436,9 +439,13 @@ _FORCE_INLINE_ Vector errarray(P... p_args) { if (!GD_IS_DEFINED(ClassDB_Disable_##m_class)) { \ ::ClassDB::register_class(); \ } -#define GDREGISTER_VIRTUAL_CLASS(m_class) \ - if (!GD_IS_DEFINED(ClassDB_Disable_##m_class)) { \ - ::ClassDB::register_virtual_class(); \ +#define GDREGISTER_VIRTUAL_CLASS(m_class) \ + if (!GD_IS_DEFINED(ClassDB_Disable_##m_class)) { \ + ::ClassDB::register_class(true); \ + } +#define GDREGISTER_ABSTRACT_CLASS(m_class) \ + if (!GD_IS_DEFINED(ClassDB_Disable_##m_class)) { \ + ::ClassDB::register_abstract_class(); \ } #include "core/disabled_classes.gen.h" diff --git a/core/object/make_virtuals.py b/core/object/make_virtuals.py index 552f2fa2bfd..2e909b80429 100644 --- a/core/object/make_virtuals.py +++ b/core/object/make_virtuals.py @@ -3,6 +3,7 @@ proto = """ StringName _gdvirtual_##m_name##_sn = #m_name;\\ mutable bool _gdvirtual_##m_name##_initialized = false;\\ mutable GDNativeExtensionClassCallVirtual _gdvirtual_##m_name = nullptr;\\ +template\\ _FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST { \\ ScriptInstance *script_instance = ((Object*)(this))->get_script_instance();\\ if (script_instance) {\\ @@ -25,6 +26,10 @@ _FORCE_INLINE_ bool _gdvirtual_##m_name##_call($CALLARGS) $CONST { \\ $CALLPTRRET\\ return true;\\ }\\ + \\ + if (required) {\\ + WARN_PRINT_ONCE("Required virtual method: "+get_class()+"::" + #m_name + " must be overriden before calling.");\\ + }\\ \\ return false;\\ }\\ diff --git a/core/object/object.h b/core/object/object.h index 8a8b6b54872..3aa7e3f9f2b 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -255,6 +255,7 @@ struct ObjectNativeExtension { GDNativeExtensionClassToString to_string; GDNativeExtensionClassReference reference; GDNativeExtensionClassReference unreference; + GDNativeExtensionClassGetRID get_rid; _FORCE_INLINE_ bool is_class(const String &p_class) const { const ObjectNativeExtension *e = this; @@ -273,8 +274,12 @@ struct ObjectNativeExtension { GDNativeExtensionClassGetVirtual get_virtual; }; -#define GDVIRTUAL_CALL(m_name, ...) _gdvirtual_##m_name##_call(__VA_ARGS__) -#define GDVIRTUAL_CALL_PTR(m_obj, m_name, ...) m_obj->_gdvirtual_##m_name##_call(__VA_ARGS__) +#define GDVIRTUAL_CALL(m_name, ...) _gdvirtual_##m_name##_call(__VA_ARGS__) +#define GDVIRTUAL_CALL_PTR(m_obj, m_name, ...) m_obj->_gdvirtual_##m_name##_call(__VA_ARGS__) + +#define GDVIRTUAL_REQUIRED_CALL(m_name, ...) _gdvirtual_##m_name##_call(__VA_ARGS__) +#define GDVIRTUAL_REQUIRED_CALL_PTR(m_obj, m_name, ...) m_obj->_gdvirtual_##m_name##_call(__VA_ARGS__) + #ifdef DEBUG_METHODS_ENABLED #define GDVIRTUAL_BIND(m_name, ...) ::ClassDB::add_virtual_method(get_class_static(), _gdvirtual_##m_name##_get_method_info(), true, sarray(__VA_ARGS__)); #else diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index 63aa8050c4b..2aa47c6c965 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -141,7 +141,7 @@ void register_core_types() { GDREGISTER_CLASS(Object); - GDREGISTER_VIRTUAL_CLASS(Script); + GDREGISTER_ABSTRACT_CLASS(Script); GDREGISTER_CLASS(RefCounted); GDREGISTER_CLASS(WeakRef); @@ -149,12 +149,12 @@ void register_core_types() { GDREGISTER_CLASS(Image); GDREGISTER_CLASS(Shortcut); - GDREGISTER_VIRTUAL_CLASS(InputEvent); - GDREGISTER_VIRTUAL_CLASS(InputEventWithModifiers); - GDREGISTER_VIRTUAL_CLASS(InputEventFromWindow); + GDREGISTER_ABSTRACT_CLASS(InputEvent); + GDREGISTER_ABSTRACT_CLASS(InputEventWithModifiers); + GDREGISTER_ABSTRACT_CLASS(InputEventFromWindow); GDREGISTER_CLASS(InputEventKey); GDREGISTER_CLASS(InputEventShortcut); - GDREGISTER_VIRTUAL_CLASS(InputEventMouse); + GDREGISTER_ABSTRACT_CLASS(InputEventMouse); GDREGISTER_CLASS(InputEventMouseButton); GDREGISTER_CLASS(InputEventMouseMotion); GDREGISTER_CLASS(InputEventJoypadButton); @@ -162,21 +162,21 @@ void register_core_types() { GDREGISTER_CLASS(InputEventScreenDrag); GDREGISTER_CLASS(InputEventScreenTouch); GDREGISTER_CLASS(InputEventAction); - GDREGISTER_VIRTUAL_CLASS(InputEventGesture); + GDREGISTER_ABSTRACT_CLASS(InputEventGesture); GDREGISTER_CLASS(InputEventMagnifyGesture); GDREGISTER_CLASS(InputEventPanGesture); GDREGISTER_CLASS(InputEventMIDI); // Network - GDREGISTER_VIRTUAL_CLASS(IP); + GDREGISTER_ABSTRACT_CLASS(IP); - GDREGISTER_VIRTUAL_CLASS(StreamPeer); + GDREGISTER_ABSTRACT_CLASS(StreamPeer); GDREGISTER_CLASS(StreamPeerExtension); GDREGISTER_CLASS(StreamPeerBuffer); GDREGISTER_CLASS(StreamPeerTCP); GDREGISTER_CLASS(TCPServer); - GDREGISTER_VIRTUAL_CLASS(PacketPeer); + GDREGISTER_ABSTRACT_CLASS(PacketPeer); GDREGISTER_CLASS(PacketPeerExtension); GDREGISTER_CLASS(PacketPeerStream); GDREGISTER_CLASS(PacketPeerUDP); @@ -200,7 +200,7 @@ void register_core_types() { resource_format_loader_crypto.instantiate(); ResourceLoader::add_resource_format_loader(resource_format_loader_crypto); - GDREGISTER_VIRTUAL_CLASS(MultiplayerPeer); + GDREGISTER_ABSTRACT_CLASS(MultiplayerPeer); GDREGISTER_CLASS(MultiplayerPeerExtension); GDREGISTER_CLASS(MultiplayerAPI); GDREGISTER_CLASS(MainLoop); @@ -226,19 +226,19 @@ void register_core_types() { GDREGISTER_CLASS(PCKPacker); GDREGISTER_CLASS(PackedDataContainer); - GDREGISTER_VIRTUAL_CLASS(PackedDataContainerRef); + GDREGISTER_ABSTRACT_CLASS(PackedDataContainerRef); GDREGISTER_CLASS(AStar); GDREGISTER_CLASS(AStar2D); GDREGISTER_CLASS(EncodedObjectAsID); GDREGISTER_CLASS(RandomNumberGenerator); - GDREGISTER_VIRTUAL_CLASS(ResourceImporter); + GDREGISTER_ABSTRACT_CLASS(ResourceImporter); GDREGISTER_CLASS(NativeExtension); - GDREGISTER_VIRTUAL_CLASS(NativeExtensionManager); + GDREGISTER_ABSTRACT_CLASS(NativeExtensionManager); - GDREGISTER_VIRTUAL_CLASS(ResourceUID); + GDREGISTER_ABSTRACT_CLASS(ResourceUID); GDREGISTER_CLASS(EngineProfiler); @@ -276,7 +276,7 @@ void register_core_settings() { void register_core_singletons() { GDREGISTER_CLASS(ProjectSettings); - GDREGISTER_VIRTUAL_CLASS(IP); + GDREGISTER_ABSTRACT_CLASS(IP); GDREGISTER_CLASS(core_bind::Geometry2D); GDREGISTER_CLASS(core_bind::Geometry3D); GDREGISTER_CLASS(core_bind::ResourceLoader); @@ -286,7 +286,7 @@ void register_core_singletons() { GDREGISTER_CLASS(core_bind::special::ClassDB); GDREGISTER_CLASS(core_bind::Marshalls); GDREGISTER_CLASS(TranslationServer); - GDREGISTER_VIRTUAL_CLASS(Input); + GDREGISTER_ABSTRACT_CLASS(Input); GDREGISTER_CLASS(InputMap); GDREGISTER_CLASS(Expression); GDREGISTER_CLASS(core_bind::EngineDebugger); diff --git a/doc/classes/AudioEffect.xml b/doc/classes/AudioEffect.xml index 424669eab9a..5bfa5be0cae 100644 --- a/doc/classes/AudioEffect.xml +++ b/doc/classes/AudioEffect.xml @@ -9,4 +9,11 @@ https://godotengine.org/asset-library/asset/527 + + + + + + + diff --git a/doc/classes/AudioEffectInstance.xml b/doc/classes/AudioEffectInstance.xml index 369b4130d47..f50246d6ca0 100644 --- a/doc/classes/AudioEffectInstance.xml +++ b/doc/classes/AudioEffectInstance.xml @@ -6,4 +6,19 @@ + + + + + + + + + + + + + + + diff --git a/doc/classes/AudioStreamPlaybackResampled.xml b/doc/classes/AudioStreamPlaybackResampled.xml index 228b8c19c0d..eb41e4256ec 100644 --- a/doc/classes/AudioStreamPlaybackResampled.xml +++ b/doc/classes/AudioStreamPlaybackResampled.xml @@ -6,4 +6,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/Material.xml b/doc/classes/Material.xml index 78dbf8729b8..c5d567c1fe6 100644 --- a/doc/classes/Material.xml +++ b/doc/classes/Material.xml @@ -11,6 +11,26 @@ https://godotengine.org/asset-library/asset/678 + + + + + + + + + + + + + + + + + + + + @@ -22,7 +42,7 @@ Sets the [Material] to be used for the next pass. This renders the object again using a different material. [b]Note:[/b] This only applies to [StandardMaterial3D]s and [ShaderMaterial]s with type "Spatial". - + Sets the render priority for transparent objects in 3D scenes. Higher priority objects will be sorted in front of lower priority objects. [b]Note:[/b] This only applies to [StandardMaterial3D]s and [ShaderMaterial]s with type "Spatial". [b]Note:[/b] This only applies to sorting of transparent objects. This will not impact how transparent objects are sorted relative to opaque objects. This is because opaque objects are not sorted, while transparent objects are sorted from back to front (subject to priority). diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml index c5bfdcecd23..e4116cddfed 100644 --- a/doc/classes/Mesh.xml +++ b/doc/classes/Mesh.xml @@ -13,6 +13,89 @@ https://godotengine.org/asset-library/asset/678 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml index d0136e389a4..329d81342b8 100644 --- a/doc/classes/PrimitiveMesh.xml +++ b/doc/classes/PrimitiveMesh.xml @@ -9,6 +9,11 @@ + + + + + diff --git a/doc/classes/Range.xml b/doc/classes/Range.xml index 70a9912b761..c150198eb11 100644 --- a/doc/classes/Range.xml +++ b/doc/classes/Range.xml @@ -9,6 +9,12 @@ + + + + + + diff --git a/doc/classes/Resource.xml b/doc/classes/Resource.xml index 0850d390150..b08b1540abb 100644 --- a/doc/classes/Resource.xml +++ b/doc/classes/Resource.xml @@ -12,6 +12,11 @@ $DOCS_URL/tutorials/best_practices/node_alternatives.html + + + + + diff --git a/doc/classes/StyleBox.xml b/doc/classes/StyleBox.xml index f805692f4d4..bc2333f26ad 100644 --- a/doc/classes/StyleBox.xml +++ b/doc/classes/StyleBox.xml @@ -10,6 +10,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/Texture2D.xml b/doc/classes/Texture2D.xml index de9bbb4b3d6..1bbebe085e3 100644 --- a/doc/classes/Texture2D.xml +++ b/doc/classes/Texture2D.xml @@ -12,6 +12,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/Texture3D.xml b/doc/classes/Texture3D.xml index bdfa4283286..4968f46fe87 100644 --- a/doc/classes/Texture3D.xml +++ b/doc/classes/Texture3D.xml @@ -7,6 +7,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/TextureLayered.xml b/doc/classes/TextureLayered.xml index 13679908d75..3445329f328 100644 --- a/doc/classes/TextureLayered.xml +++ b/doc/classes/TextureLayered.xml @@ -9,6 +9,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/VisualInstance3D.xml b/doc/classes/VisualInstance3D.xml index 1aae85c7e1c..7efa1f4df81 100644 --- a/doc/classes/VisualInstance3D.xml +++ b/doc/classes/VisualInstance3D.xml @@ -9,6 +9,11 @@ + + + + + diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 7e59fc31c4a..f9858aa5143 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -130,8 +130,8 @@ bool CreateDialog::_should_hide_type(const String &p_type) const { } if (ClassDB::class_exists(p_type)) { - if (!ClassDB::can_instantiate(p_type)) { - return true; // Can't create abstract class. + if (!ClassDB::can_instantiate(p_type) || ClassDB::is_virtual(p_type)) { + return true; // Can't create abstract or virtual class. } if (!ClassDB::is_parent_class(p_type, base_type)) { diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index b64b48b4eeb..e1198026b6d 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -919,7 +919,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { ClassDB::get_inheriters_from_class("AudioEffect", &effects); effects.sort_custom(); for (const StringName &E : effects) { - if (!ClassDB::can_instantiate(E)) { + if (!ClassDB::can_instantiate(E) || ClassDB::is_virtual(E)) { continue; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 7a9511e8c66..2c39dc69b9c 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -3858,18 +3858,18 @@ void EditorNode::register_editor_types() { GDREGISTER_CLASS(EditorScript); GDREGISTER_CLASS(EditorSelection); GDREGISTER_CLASS(EditorFileDialog); - GDREGISTER_VIRTUAL_CLASS(EditorSettings); + GDREGISTER_ABSTRACT_CLASS(EditorSettings); GDREGISTER_CLASS(EditorNode3DGizmo); GDREGISTER_CLASS(EditorNode3DGizmoPlugin); - GDREGISTER_VIRTUAL_CLASS(EditorResourcePreview); + GDREGISTER_ABSTRACT_CLASS(EditorResourcePreview); GDREGISTER_CLASS(EditorResourcePreviewGenerator); - GDREGISTER_VIRTUAL_CLASS(EditorFileSystem); + GDREGISTER_ABSTRACT_CLASS(EditorFileSystem); GDREGISTER_CLASS(EditorFileSystemDirectory); GDREGISTER_CLASS(EditorVCSInterface); - GDREGISTER_VIRTUAL_CLASS(ScriptEditor); - GDREGISTER_VIRTUAL_CLASS(ScriptEditorBase); + GDREGISTER_ABSTRACT_CLASS(ScriptEditor); + GDREGISTER_ABSTRACT_CLASS(ScriptEditorBase); GDREGISTER_CLASS(EditorSyntaxHighlighter); - GDREGISTER_VIRTUAL_CLASS(EditorInterface); + GDREGISTER_ABSTRACT_CLASS(EditorInterface); GDREGISTER_CLASS(EditorExportPlugin); GDREGISTER_CLASS(EditorResourceConversionPlugin); GDREGISTER_CLASS(EditorSceneFormatImporter); @@ -3884,7 +3884,7 @@ void EditorNode::register_editor_types() { GDREGISTER_CLASS(EditorResourcePicker); GDREGISTER_CLASS(EditorScriptPicker); - GDREGISTER_VIRTUAL_CLASS(FileSystemDock); + GDREGISTER_ABSTRACT_CLASS(FileSystemDock); // FIXME: Is this stuff obsolete, or should it be ported to new APIs? GDREGISTER_CLASS(EditorScenePostImport); diff --git a/editor/plugins/gpu_particles_3d_editor_plugin.cpp b/editor/plugins/gpu_particles_3d_editor_plugin.cpp index 293d1c3913d..35cbff53f43 100644 --- a/editor/plugins/gpu_particles_3d_editor_plugin.cpp +++ b/editor/plugins/gpu_particles_3d_editor_plugin.cpp @@ -166,20 +166,20 @@ void GPUParticles3DEditorBase::_node_selected(const NodePath &p_path) { return; } - VisualInstance3D *vi = Object::cast_to(sel); - if (!vi) { + MeshInstance3D *mi = Object::cast_to(sel); + if (!mi || mi->get_mesh().is_null()) { EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain geometry."), sel->get_name())); return; } - geometry = vi->get_faces(VisualInstance3D::FACES_SOLID); + geometry = mi->get_mesh()->get_faces(); if (geometry.size() == 0) { EditorNode::get_singleton()->show_warning(vformat(TTR("\"%s\" doesn't contain face geometry."), sel->get_name())); return; } - Transform3D geom_xform = base_node->get_global_transform().affine_inverse() * vi->get_global_transform(); + Transform3D geom_xform = base_node->get_global_transform().affine_inverse() * mi->get_global_transform(); int gc = geometry.size(); Face3 *w = geometry.ptrw(); diff --git a/editor/plugins/multimesh_editor_plugin.cpp b/editor/plugins/multimesh_editor_plugin.cpp index 72f3b6a06ed..850c673c127 100644 --- a/editor/plugins/multimesh_editor_plugin.cpp +++ b/editor/plugins/multimesh_editor_plugin.cpp @@ -105,9 +105,9 @@ void MultiMeshEditor::_populate() { return; } - GeometryInstance3D *ss_instance = Object::cast_to(ss_node); + MeshInstance3D *ss_instance = Object::cast_to(ss_node); - if (!ss_instance) { + if (!ss_instance || !ss_instance->get_mesh().is_valid()) { err_dialog->set_text(TTR("Surface source is invalid (no geometry).")); err_dialog->popup_centered(); return; @@ -115,7 +115,7 @@ void MultiMeshEditor::_populate() { Transform3D geom_xform = node->get_global_transform().affine_inverse() * ss_instance->get_global_transform(); - Vector geometry = ss_instance->get_faces(VisualInstance3D::FACES_SOLID); + Vector geometry = ss_instance->get_mesh()->get_faces(); if (geometry.size() == 0) { err_dialog->set_text(TTR("Surface source is invalid (no faces).")); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 0282504c706..dd4b963fc06 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -907,7 +907,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: } } - if (!is_custom_resource && !ClassDB::can_instantiate(t)) { + if (!is_custom_resource && (!ClassDB::can_instantiate(t) || ClassDB::is_virtual(t))) { continue; } diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index fec2d3137c0..137df52215f 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -491,10 +491,6 @@ Vector CSGShape3D::get_brush_faces() { return faces; } -Vector CSGShape3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void CSGShape3D::_notification(int p_what) { switch (p_what) { case NOTIFICATION_PARENTED: { diff --git a/modules/csg/csg_shape.h b/modules/csg/csg_shape.h index d16250e30d5..4721d0c11c6 100644 --- a/modules/csg/csg_shape.h +++ b/modules/csg/csg_shape.h @@ -128,7 +128,6 @@ public: virtual Vector get_brush_faces(); virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; void set_use_collision(bool p_enable); bool is_using_collision() const; diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp index f01907bef3d..f8db42b1a9f 100644 --- a/modules/csg/register_types.cpp +++ b/modules/csg/register_types.cpp @@ -36,8 +36,8 @@ void register_csg_types() { #ifndef _3D_DISABLED - GDREGISTER_VIRTUAL_CLASS(CSGShape3D); - GDREGISTER_VIRTUAL_CLASS(CSGPrimitive3D); + GDREGISTER_ABSTRACT_CLASS(CSGShape3D); + GDREGISTER_ABSTRACT_CLASS(CSGPrimitive3D); GDREGISTER_CLASS(CSGMesh3D); GDREGISTER_CLASS(CSGSphere3D); GDREGISTER_CLASS(CSGBox3D); diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp index 36a4e6e6e70..ebc5d953484 100644 --- a/modules/enet/register_types.cpp +++ b/modules/enet/register_types.cpp @@ -44,7 +44,7 @@ void register_enet_types() { } GDREGISTER_CLASS(ENetMultiplayerPeer); - GDREGISTER_VIRTUAL_CLASS(ENetPacketPeer); + GDREGISTER_ABSTRACT_CLASS(ENetPacketPeer); GDREGISTER_CLASS(ENetConnection); } diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp index 63fec6db8cd..b5b51403f7d 100644 --- a/modules/minimp3/audio_stream_mp3.cpp +++ b/modules/minimp3/audio_stream_mp3.cpp @@ -83,7 +83,7 @@ void AudioStreamPlaybackMP3::start(float p_from_pos) { active = true; seek(p_from_pos); loops = 0; - _begin_resample(); + begin_resample(); } void AudioStreamPlaybackMP3::stop() { diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index e7b5f58174f..d19870921dd 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -53,10 +53,10 @@ void register_visual_script_types() { ScriptServer::register_language(visual_script_language); GDREGISTER_CLASS(VisualScript); - GDREGISTER_VIRTUAL_CLASS(VisualScriptNode); + GDREGISTER_ABSTRACT_CLASS(VisualScriptNode); GDREGISTER_CLASS(VisualScriptFunctionState); GDREGISTER_CLASS(VisualScriptFunction); - GDREGISTER_VIRTUAL_CLASS(VisualScriptLists); + GDREGISTER_ABSTRACT_CLASS(VisualScriptLists); GDREGISTER_CLASS(VisualScriptComposeArray); GDREGISTER_CLASS(VisualScriptOperator); GDREGISTER_CLASS(VisualScriptVariableSet); diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp index 049d816a5a6..5ff5b2339c6 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp @@ -166,7 +166,7 @@ void AudioStreamPlaybackOGGVorbis::start(float p_from_pos) { active = true; seek(p_from_pos); loops = 0; - _begin_resample(); + begin_resample(); } void AudioStreamPlaybackOGGVorbis::stop() { diff --git a/modules/webrtc/register_types.cpp b/modules/webrtc/register_types.cpp index e6a8dcc31a1..283e421e110 100644 --- a/modules/webrtc/register_types.cpp +++ b/modules/webrtc/register_types.cpp @@ -47,7 +47,7 @@ void register_webrtc_types() { ClassDB::register_custom_instance_class(); GDREGISTER_CLASS(WebRTCPeerConnectionExtension); - GDREGISTER_VIRTUAL_CLASS(WebRTCDataChannel); + GDREGISTER_ABSTRACT_CLASS(WebRTCDataChannel); GDREGISTER_CLASS(WebRTCDataChannelExtension); GDREGISTER_CLASS(WebRTCMultiplayerPeer); diff --git a/modules/websocket/register_types.cpp b/modules/websocket/register_types.cpp index 1e9a4c03922..ff900f496fe 100644 --- a/modules/websocket/register_types.cpp +++ b/modules/websocket/register_types.cpp @@ -63,7 +63,7 @@ void register_websocket_types() { WSLServer::make_default(); #endif - GDREGISTER_VIRTUAL_CLASS(WebSocketMultiplayerPeer); + GDREGISTER_ABSTRACT_CLASS(WebSocketMultiplayerPeer); ClassDB::register_custom_instance_class(); ClassDB::register_custom_instance_class(); ClassDB::register_custom_instance_class(); diff --git a/modules/webxr/register_types.cpp b/modules/webxr/register_types.cpp index 78fed3fbd65..a15dc93248f 100644 --- a/modules/webxr/register_types.cpp +++ b/modules/webxr/register_types.cpp @@ -38,7 +38,7 @@ Ref webxr; #endif void register_webxr_types() { - GDREGISTER_VIRTUAL_CLASS(WebXRInterface); + GDREGISTER_ABSTRACT_CLASS(WebXRInterface); #ifdef JAVASCRIPT_ENABLED webxr.instantiate(); diff --git a/platform/javascript/api/api.cpp b/platform/javascript/api/api.cpp index 4190b24b8ec..46a0a816bf1 100644 --- a/platform/javascript/api/api.cpp +++ b/platform/javascript/api/api.cpp @@ -37,8 +37,8 @@ static JavaScript *javascript_eval; void register_javascript_api() { JavaScriptToolsEditorPlugin::initialize(); - GDREGISTER_VIRTUAL_CLASS(JavaScriptObject); - GDREGISTER_VIRTUAL_CLASS(JavaScript); + GDREGISTER_ABSTRACT_CLASS(JavaScriptObject); + GDREGISTER_ABSTRACT_CLASS(JavaScript); javascript_eval = memnew(JavaScript); Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_eval)); } diff --git a/scene/3d/cpu_particles_3d.cpp b/scene/3d/cpu_particles_3d.cpp index a02b5f48a16..ab28a83806d 100644 --- a/scene/3d/cpu_particles_3d.cpp +++ b/scene/3d/cpu_particles_3d.cpp @@ -39,10 +39,6 @@ AABB CPUParticles3D::get_aabb() const { return AABB(); } -Vector CPUParticles3D::get_faces(uint32_t p_usage_particle_flags) const { - return Vector(); -} - void CPUParticles3D::set_emitting(bool p_emitting) { if (emitting == p_emitting) { return; diff --git a/scene/3d/cpu_particles_3d.h b/scene/3d/cpu_particles_3d.h index bd736bdf248..5eeb5e75d31 100644 --- a/scene/3d/cpu_particles_3d.h +++ b/scene/3d/cpu_particles_3d.h @@ -201,7 +201,6 @@ protected: public: AABB get_aabb() const override; - Vector get_faces(uint32_t p_usage_flags) const override; void set_emitting(bool p_emitting); void set_amount(int p_amount); diff --git a/scene/3d/decal.cpp b/scene/3d/decal.cpp index dfac9055f52..8d0edfd1f32 100644 --- a/scene/3d/decal.cpp +++ b/scene/3d/decal.cpp @@ -152,10 +152,6 @@ AABB Decal::get_aabb() const { return aabb; } -Vector Decal::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void Decal::_validate_property(PropertyInfo &property) const { if (!distance_fade_enabled && (property.name == "distance_fade_begin" || property.name == "distance_fade_length")) { property.usage = PROPERTY_USAGE_NO_EDITOR; diff --git a/scene/3d/decal.h b/scene/3d/decal.h index 740dd2c4077..d5990272c61 100644 --- a/scene/3d/decal.h +++ b/scene/3d/decal.h @@ -104,7 +104,6 @@ public: uint32_t get_cull_mask() const; virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; Decal(); ~Decal(); diff --git a/scene/3d/fog_volume.h b/scene/3d/fog_volume.h index 68d5c58169e..556a92ad3f9 100644 --- a/scene/3d/fog_volume.h +++ b/scene/3d/fog_volume.h @@ -62,7 +62,6 @@ public: Ref get_material() const; virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override { return Vector(); } TypedArray get_configuration_warnings() const override; FogVolume(); diff --git a/scene/3d/gpu_particles_3d.cpp b/scene/3d/gpu_particles_3d.cpp index 4e35f372916..9fe2210de6f 100644 --- a/scene/3d/gpu_particles_3d.cpp +++ b/scene/3d/gpu_particles_3d.cpp @@ -36,10 +36,6 @@ AABB GPUParticles3D::get_aabb() const { return AABB(); } -Vector GPUParticles3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void GPUParticles3D::set_emitting(bool p_emitting) { RS::get_singleton()->particles_set_emitting(particles, p_emitting); diff --git a/scene/3d/gpu_particles_3d.h b/scene/3d/gpu_particles_3d.h index 54ae84628a4..f3eb52d124b 100644 --- a/scene/3d/gpu_particles_3d.h +++ b/scene/3d/gpu_particles_3d.h @@ -98,7 +98,6 @@ protected: public: AABB get_aabb() const override; - Vector get_faces(uint32_t p_usage_flags) const override; void set_emitting(bool p_emitting); void set_amount(int p_amount); diff --git a/scene/3d/gpu_particles_collision_3d.h b/scene/3d/gpu_particles_collision_3d.h index b6de1d83fc1..fdd2fa4b18b 100644 --- a/scene/3d/gpu_particles_collision_3d.h +++ b/scene/3d/gpu_particles_collision_3d.h @@ -50,8 +50,6 @@ public: void set_cull_mask(uint32_t p_cull_mask); uint32_t get_cull_mask() const; - virtual Vector get_faces(uint32_t p_usage_flags) const override { return Vector(); } - ~GPUParticlesCollision3D(); }; @@ -274,8 +272,6 @@ public: void set_directionality(real_t p_directionality); real_t get_directionality() const; - virtual Vector get_faces(uint32_t p_usage_flags) const override { return Vector(); } - ~GPUParticlesAttractor3D(); }; diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index f2021aa3d50..e7e164d7da3 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -156,10 +156,6 @@ AABB Light3D::get_aabb() const { return AABB(); } -Vector Light3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void Light3D::set_bake_mode(BakeMode p_mode) { bake_mode = p_mode; RS::get_singleton()->light_set_bake_mode(light, RS::LightBakeMode(p_mode)); diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index 11a9fcfc555..ed9e0bdfff7 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -138,7 +138,6 @@ public: Ref get_projector() const; virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; Light3D(); ~Light3D(); diff --git a/scene/3d/lightmap_gi.cpp b/scene/3d/lightmap_gi.cpp index 07f41c0bf93..c74654b4bda 100644 --- a/scene/3d/lightmap_gi.cpp +++ b/scene/3d/lightmap_gi.cpp @@ -1263,10 +1263,6 @@ AABB LightmapGI::get_aabb() const { return AABB(); } -Vector LightmapGI::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void LightmapGI::set_use_denoiser(bool p_enable) { use_denoiser = p_enable; } diff --git a/scene/3d/lightmap_gi.h b/scene/3d/lightmap_gi.h index 66acf4f487b..d29d7a7c28e 100644 --- a/scene/3d/lightmap_gi.h +++ b/scene/3d/lightmap_gi.h @@ -267,7 +267,6 @@ public: GenerateProbes get_generate_probes() const; AABB get_aabb() const override; - Vector get_faces(uint32_t p_usage_flags) const override; BakeError bake(Node *p_from_node, String p_image_data_path = "", Lightmapper::BakeStepFunc p_bake_step = nullptr, void *p_bake_userdata = nullptr); LightmapGI(); diff --git a/scene/3d/mesh_instance_3d.cpp b/scene/3d/mesh_instance_3d.cpp index fddfa17dbb6..31c33a6b617 100644 --- a/scene/3d/mesh_instance_3d.cpp +++ b/scene/3d/mesh_instance_3d.cpp @@ -219,18 +219,6 @@ AABB MeshInstance3D::get_aabb() const { return AABB(); } -Vector MeshInstance3D::get_faces(uint32_t p_usage_flags) const { - if (!(p_usage_flags & (FACES_SOLID | FACES_ENCLOSING))) { - return Vector(); - } - - if (mesh.is_null()) { - return Vector(); - } - - return mesh->get_faces(); -} - Node *MeshInstance3D::create_trimesh_collision_node() { if (mesh.is_null()) { return nullptr; diff --git a/scene/3d/mesh_instance_3d.h b/scene/3d/mesh_instance_3d.h index 03ee3cd6089..0bf5c324105 100644 --- a/scene/3d/mesh_instance_3d.h +++ b/scene/3d/mesh_instance_3d.h @@ -93,7 +93,6 @@ public: void create_debug_tangents(); virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; MeshInstance3D(); ~MeshInstance3D(); diff --git a/scene/3d/multimesh_instance_3d.cpp b/scene/3d/multimesh_instance_3d.cpp index 34b1e864351..d197388fadd 100644 --- a/scene/3d/multimesh_instance_3d.cpp +++ b/scene/3d/multimesh_instance_3d.cpp @@ -49,10 +49,6 @@ Ref MultiMeshInstance3D::get_multimesh() const { return multimesh; } -Vector MultiMeshInstance3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - AABB MultiMeshInstance3D::get_aabb() const { if (multimesh.is_null()) { return AABB(); diff --git a/scene/3d/multimesh_instance_3d.h b/scene/3d/multimesh_instance_3d.h index d03b24eb4ee..111f1e9c090 100644 --- a/scene/3d/multimesh_instance_3d.h +++ b/scene/3d/multimesh_instance_3d.h @@ -44,8 +44,6 @@ protected: // bind helpers public: - virtual Vector get_faces(uint32_t p_usage_flags) const override; - void set_multimesh(const Ref &p_multimesh); Ref get_multimesh() const; diff --git a/scene/3d/occluder_instance_3d.cpp b/scene/3d/occluder_instance_3d.cpp index 855922c3412..b82f05544b8 100644 --- a/scene/3d/occluder_instance_3d.cpp +++ b/scene/3d/occluder_instance_3d.cpp @@ -433,10 +433,6 @@ AABB OccluderInstance3D::get_aabb() const { return AABB(); } -Vector OccluderInstance3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void OccluderInstance3D::set_occluder(const Ref &p_occluder) { if (occluder == p_occluder) { return; diff --git a/scene/3d/occluder_instance_3d.h b/scene/3d/occluder_instance_3d.h index 669ddba7751..ed6610074e5 100644 --- a/scene/3d/occluder_instance_3d.h +++ b/scene/3d/occluder_instance_3d.h @@ -194,7 +194,6 @@ public: Ref get_occluder() const; virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; void set_bake_mask(uint32_t p_mask); uint32_t get_bake_mask() const; diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index be655e71dbb..1bebd8e3356 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -178,10 +178,6 @@ AABB ReflectionProbe::get_aabb() const { return aabb; } -Vector ReflectionProbe::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void ReflectionProbe::_validate_property(PropertyInfo &property) const { if (property.name == "interior/ambient_color" || property.name == "interior/ambient_color_energy") { if (ambient_mode != AMBIENT_COLOR) { diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index d0643496a47..424976d8959 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -113,7 +113,6 @@ public: UpdateMode get_update_mode() const; virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; ReflectionProbe(); ~ReflectionProbe(); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index ce281c79bca..514bd4aba0d 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -177,10 +177,6 @@ AABB SpriteBase3D::get_aabb() const { return aabb; } -Vector SpriteBase3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - Ref SpriteBase3D::generate_triangle_mesh() const { if (triangle_mesh.is_valid()) { return triangle_mesh; diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 985103e1906..92dbef08553 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -137,7 +137,7 @@ public: virtual Rect2 get_item_rect() const = 0; virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; + Ref generate_triangle_mesh() const; SpriteBase3D(); diff --git a/scene/3d/visible_on_screen_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp index 11367d7ca91..41cd604a4f0 100644 --- a/scene/3d/visible_on_screen_notifier_3d.cpp +++ b/scene/3d/visible_on_screen_notifier_3d.cpp @@ -89,10 +89,6 @@ void VisibleOnScreenNotifier3D::_bind_methods() { ADD_SIGNAL(MethodInfo("screen_exited")); } -Vector VisibleOnScreenNotifier3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - VisibleOnScreenNotifier3D::VisibleOnScreenNotifier3D() { RID notifier = RS::get_singleton()->visibility_notifier_create(); RS::get_singleton()->visibility_notifier_set_aabb(notifier, aabb); diff --git a/scene/3d/visible_on_screen_notifier_3d.h b/scene/3d/visible_on_screen_notifier_3d.h index 852c7e2ed3f..fe17f1e4449 100644 --- a/scene/3d/visible_on_screen_notifier_3d.h +++ b/scene/3d/visible_on_screen_notifier_3d.h @@ -57,8 +57,6 @@ public: virtual AABB get_aabb() const override; bool is_on_screen() const; - virtual Vector get_faces(uint32_t p_usage_flags) const override; - VisibleOnScreenNotifier3D(); ~VisibleOnScreenNotifier3D(); }; diff --git a/scene/3d/visual_instance_3d.cpp b/scene/3d/visual_instance_3d.cpp index d8dffe6c7dd..b8a68cdca95 100644 --- a/scene/3d/visual_instance_3d.cpp +++ b/scene/3d/visual_instance_3d.cpp @@ -32,6 +32,14 @@ #include "scene/scene_string_names.h" +AABB VisualInstance3D::get_aabb() const { + AABB ret; + if (GDVIRTUAL_CALL(_get_aabb, ret)) { + return ret; + } + return AABB(); +} + AABB VisualInstance3D::get_transformed_aabb() const { return get_global_transform().xform(get_aabb()); } @@ -115,6 +123,7 @@ void VisualInstance3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_transformed_aabb"), &VisualInstance3D::get_transformed_aabb); + GDVIRTUAL_BIND(_get_aabb); ADD_PROPERTY(PropertyInfo(Variant::INT, "layers", PROPERTY_HINT_LAYERS_3D_RENDER), "set_layer_mask", "get_layer_mask"); } diff --git a/scene/3d/visual_instance_3d.h b/scene/3d/visual_instance_3d.h index 02f62b41e5f..1c044ba6817 100644 --- a/scene/3d/visual_instance_3d.h +++ b/scene/3d/visual_instance_3d.h @@ -49,6 +49,7 @@ protected: void _notification(int p_what); static void _bind_methods(); + GDVIRTUAL0RC(AABB, _get_aabb) public: enum GetFacesFlags { FACES_SOLID = 1, // solid geometry @@ -58,8 +59,7 @@ public: }; RID get_instance() const; - virtual AABB get_aabb() const = 0; - virtual Vector get_faces(uint32_t p_usage_flags) const = 0; + virtual AABB get_aabb() const; virtual AABB get_transformed_aabb() const; // helper diff --git a/scene/3d/voxel_gi.cpp b/scene/3d/voxel_gi.cpp index bfe3c80a4fd..6840d15f780 100644 --- a/scene/3d/voxel_gi.cpp +++ b/scene/3d/voxel_gi.cpp @@ -450,10 +450,6 @@ AABB VoxelGI::get_aabb() const { return AABB(-extents, extents * 2); } -Vector VoxelGI::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - TypedArray VoxelGI::get_configuration_warnings() const { TypedArray warnings = Node::get_configuration_warnings(); diff --git a/scene/3d/voxel_gi.h b/scene/3d/voxel_gi.h index 3678bd4f3be..e1a38dd7a0a 100644 --- a/scene/3d/voxel_gi.h +++ b/scene/3d/voxel_gi.h @@ -149,7 +149,6 @@ public: void bake(Node *p_from_node = nullptr, bool p_create_visual_debug = false); virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; TypedArray get_configuration_warnings() const override; diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index 46fe832cf58..42adc1ea02b 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -166,10 +166,6 @@ AABB RootMotionView::get_aabb() const { return AABB(Vector3(-radius, 0, -radius), Vector3(radius * 2, 0.001, radius * 2)); } -Vector RootMotionView::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - void RootMotionView::_bind_methods() { ClassDB::bind_method(D_METHOD("set_animation_path", "path"), &RootMotionView::set_animation_path); ClassDB::bind_method(D_METHOD("get_animation_path"), &RootMotionView::get_animation_path); diff --git a/scene/animation/root_motion_view.h b/scene/animation/root_motion_view.h index e8b141c1fdf..8cb8ea8a9a7 100644 --- a/scene/animation/root_motion_view.h +++ b/scene/animation/root_motion_view.h @@ -71,7 +71,6 @@ public: bool get_zero_y() const; virtual AABB get_aabb() const override; - virtual Vector get_faces(uint32_t p_usage_flags) const override; RootMotionView(); ~RootMotionView(); diff --git a/scene/gui/range.cpp b/scene/gui/range.cpp index 879f25c8d8a..2fb6452a97d 100644 --- a/scene/gui/range.cpp +++ b/scene/gui/range.cpp @@ -40,6 +40,9 @@ TypedArray Range::get_configuration_warnings() const { return warnings; } +void Range::_value_changed(double p_value) { + GDVIRTUAL_CALL(_value_changed, p_value); +} void Range::_value_changed_notify() { _value_changed(shared->val); emit_signal(SNAME("value_changed"), shared->val); @@ -279,6 +282,8 @@ void Range::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_greater"), "set_allow_greater", "is_greater_allowed"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "allow_lesser"), "set_allow_lesser", "is_lesser_allowed"); + GDVIRTUAL_BIND(_value_changed); + ADD_LINKED_PROPERTY("min_value", "value"); ADD_LINKED_PROPERTY("min_value", "max_value"); ADD_LINKED_PROPERTY("min_value", "page"); diff --git a/scene/gui/range.h b/scene/gui/range.h index c27eeee13c9..597c50ca265 100644 --- a/scene/gui/range.h +++ b/scene/gui/range.h @@ -62,12 +62,14 @@ class Range : public Control { void _validate_values(); protected: - virtual void _value_changed(double) {} + virtual void _value_changed(double p_value); static void _bind_methods(); bool _rounded_values = false; + GDVIRTUAL1(_value_changed, double) + public: void set_value(double p_val); void set_min(double p_min); diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 5fd31c54165..e50d7e765cc 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -39,7 +39,7 @@ Size2 SpinBox::get_minimum_size() const { return ms; } -void SpinBox::_value_changed(double) { +void SpinBox::_value_changed(double p_value) { String value = TS->format_number(String::num(get_value(), Math::range_step_decimals(get_step()))); if (!prefix.is_empty()) { value = prefix + " " + value; @@ -48,6 +48,7 @@ void SpinBox::_value_changed(double) { value += " " + suffix; } line_edit->set_text(value); + Range::_value_changed(p_value); } void SpinBox::_text_submitted(const String &p_string) { diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h index 0691a4b48d9..a15e3fe5f56 100644 --- a/scene/gui/spin_box.h +++ b/scene/gui/spin_box.h @@ -47,7 +47,7 @@ class SpinBox : public Range { void _release_mouse(); void _text_submitted(const String &p_string); - virtual void _value_changed(double) override; + virtual void _value_changed(double p_value) override; void _text_changed(const String &p_string); String prefix; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 4a6ba98c4fc..fb5d57ab9ec 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -300,9 +300,9 @@ void register_scene_types() { GDREGISTER_CLASS(Object); GDREGISTER_CLASS(Node); - GDREGISTER_VIRTUAL_CLASS(InstancePlaceholder); + GDREGISTER_ABSTRACT_CLASS(InstancePlaceholder); - GDREGISTER_VIRTUAL_CLASS(Viewport); + GDREGISTER_ABSTRACT_CLASS(Viewport); GDREGISTER_CLASS(SubViewport); GDREGISTER_CLASS(ViewportTexture); GDREGISTER_CLASS(HTTPRequest); @@ -324,11 +324,11 @@ void register_scene_types() { GDREGISTER_CLASS(Control); GDREGISTER_CLASS(Button); GDREGISTER_CLASS(Label); - GDREGISTER_VIRTUAL_CLASS(ScrollBar); + GDREGISTER_ABSTRACT_CLASS(ScrollBar); GDREGISTER_CLASS(HScrollBar); GDREGISTER_CLASS(VScrollBar); GDREGISTER_CLASS(ProgressBar); - GDREGISTER_VIRTUAL_CLASS(Slider); + GDREGISTER_ABSTRACT_CLASS(Slider); GDREGISTER_CLASS(HSlider); GDREGISTER_CLASS(VSlider); GDREGISTER_CLASS(Popup); @@ -349,19 +349,19 @@ void register_scene_types() { GDREGISTER_CLASS(AspectRatioContainer); GDREGISTER_CLASS(TabContainer); GDREGISTER_CLASS(TabBar); - GDREGISTER_VIRTUAL_CLASS(Separator); + GDREGISTER_ABSTRACT_CLASS(Separator); GDREGISTER_CLASS(HSeparator); GDREGISTER_CLASS(VSeparator); GDREGISTER_CLASS(TextureButton); GDREGISTER_CLASS(Container); - GDREGISTER_VIRTUAL_CLASS(BoxContainer); + GDREGISTER_ABSTRACT_CLASS(BoxContainer); GDREGISTER_CLASS(HBoxContainer); GDREGISTER_CLASS(VBoxContainer); GDREGISTER_CLASS(GridContainer); GDREGISTER_CLASS(CenterContainer); GDREGISTER_CLASS(ScrollContainer); GDREGISTER_CLASS(PanelContainer); - GDREGISTER_VIRTUAL_CLASS(FlowContainer); + GDREGISTER_ABSTRACT_CLASS(FlowContainer); GDREGISTER_CLASS(HFlowContainer); GDREGISTER_CLASS(VFlowContainer); @@ -384,7 +384,7 @@ void register_scene_types() { GDREGISTER_CLASS(SyntaxHighlighter); GDREGISTER_CLASS(CodeHighlighter); - GDREGISTER_VIRTUAL_CLASS(TreeItem); + GDREGISTER_ABSTRACT_CLASS(TreeItem); GDREGISTER_CLASS(OptionButton); GDREGISTER_CLASS(SpinBox); GDREGISTER_CLASS(ColorPicker); @@ -398,7 +398,7 @@ void register_scene_types() { GDREGISTER_CLASS(MarginContainer); GDREGISTER_CLASS(SubViewportContainer); - GDREGISTER_VIRTUAL_CLASS(SplitContainer); + GDREGISTER_ABSTRACT_CLASS(SplitContainer); GDREGISTER_CLASS(HSplitContainer); GDREGISTER_CLASS(VSplitContainer); @@ -418,7 +418,7 @@ void register_scene_types() { GDREGISTER_CLASS(AnimationPlayer); GDREGISTER_CLASS(Tween); - GDREGISTER_VIRTUAL_CLASS(Tweener); + GDREGISTER_ABSTRACT_CLASS(Tweener); GDREGISTER_CLASS(PropertyTweener); GDREGISTER_CLASS(IntervalTweener); GDREGISTER_CLASS(CallbackTweener); @@ -453,9 +453,9 @@ void register_scene_types() { #ifndef _3D_DISABLED GDREGISTER_CLASS(Node3D); - GDREGISTER_VIRTUAL_CLASS(Node3DGizmo); + GDREGISTER_ABSTRACT_CLASS(Node3DGizmo); GDREGISTER_CLASS(Skin); - GDREGISTER_VIRTUAL_CLASS(SkinReference); + GDREGISTER_ABSTRACT_CLASS(SkinReference); GDREGISTER_CLASS(Skeleton3D); GDREGISTER_CLASS(ImporterMesh); GDREGISTER_CLASS(ImporterMeshInstance3D); @@ -464,22 +464,22 @@ void register_scene_types() { GDREGISTER_CLASS(Camera3D); GDREGISTER_CLASS(AudioListener3D); GDREGISTER_CLASS(XRCamera3D); - GDREGISTER_VIRTUAL_CLASS(XRNode3D); + GDREGISTER_ABSTRACT_CLASS(XRNode3D); GDREGISTER_CLASS(XRController3D); GDREGISTER_CLASS(XRAnchor3D); GDREGISTER_CLASS(XROrigin3D); GDREGISTER_CLASS(MeshInstance3D); GDREGISTER_CLASS(OccluderInstance3D); - GDREGISTER_VIRTUAL_CLASS(Occluder3D); + GDREGISTER_ABSTRACT_CLASS(Occluder3D); GDREGISTER_CLASS(ArrayOccluder3D); GDREGISTER_CLASS(QuadOccluder3D); GDREGISTER_CLASS(BoxOccluder3D); GDREGISTER_CLASS(SphereOccluder3D); GDREGISTER_CLASS(PolygonOccluder3D); - GDREGISTER_VIRTUAL_CLASS(SpriteBase3D); + GDREGISTER_ABSTRACT_CLASS(SpriteBase3D); GDREGISTER_CLASS(Sprite3D); GDREGISTER_CLASS(AnimatedSprite3D); - GDREGISTER_VIRTUAL_CLASS(Light3D); + GDREGISTER_ABSTRACT_CLASS(Light3D); GDREGISTER_CLASS(DirectionalLight3D); GDREGISTER_CLASS(OmniLight3D); GDREGISTER_CLASS(SpotLight3D); @@ -490,14 +490,14 @@ void register_scene_types() { GDREGISTER_CLASS(LightmapGI); GDREGISTER_CLASS(LightmapGIData); GDREGISTER_CLASS(LightmapProbe); - GDREGISTER_VIRTUAL_CLASS(Lightmapper); + GDREGISTER_ABSTRACT_CLASS(Lightmapper); GDREGISTER_CLASS(GPUParticles3D); - GDREGISTER_VIRTUAL_CLASS(GPUParticlesCollision3D); + GDREGISTER_ABSTRACT_CLASS(GPUParticlesCollision3D); GDREGISTER_CLASS(GPUParticlesCollisionBox3D); GDREGISTER_CLASS(GPUParticlesCollisionSphere3D); GDREGISTER_CLASS(GPUParticlesCollisionSDF3D); GDREGISTER_CLASS(GPUParticlesCollisionHeightField3D); - GDREGISTER_VIRTUAL_CLASS(GPUParticlesAttractor3D); + GDREGISTER_ABSTRACT_CLASS(GPUParticlesAttractor3D); GDREGISTER_CLASS(GPUParticlesAttractorBox3D); GDREGISTER_CLASS(GPUParticlesAttractorSphere3D); GDREGISTER_CLASS(GPUParticlesAttractorVectorField3D); @@ -509,8 +509,8 @@ void register_scene_types() { OS::get_singleton()->yield(); // may take time to init - GDREGISTER_VIRTUAL_CLASS(CollisionObject3D); - GDREGISTER_VIRTUAL_CLASS(PhysicsBody3D); + GDREGISTER_ABSTRACT_CLASS(CollisionObject3D); + GDREGISTER_ABSTRACT_CLASS(PhysicsBody3D); GDREGISTER_CLASS(StaticBody3D); GDREGISTER_CLASS(AnimatableBody3D); GDREGISTER_CLASS(RigidDynamicBody3D); @@ -542,7 +542,7 @@ void register_scene_types() { GDREGISTER_CLASS(FogMaterial); GDREGISTER_CLASS(RemoteTransform3D); - GDREGISTER_VIRTUAL_CLASS(Joint3D); + GDREGISTER_ABSTRACT_CLASS(Joint3D); GDREGISTER_CLASS(PinJoint3D); GDREGISTER_CLASS(HingeJoint3D); GDREGISTER_CLASS(SliderJoint3D); @@ -560,14 +560,14 @@ void register_scene_types() { GDREGISTER_CLASS(Shader); GDREGISTER_CLASS(VisualShader); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNode); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNode); GDREGISTER_CLASS(VisualShaderNodeCustom); GDREGISTER_CLASS(VisualShaderNodeInput); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeOutput); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeResizableBase); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeGroupBase); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeConstant); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeVectorBase); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeOutput); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeResizableBase); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeGroupBase); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeConstant); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeVectorBase); GDREGISTER_CLASS(VisualShaderNodeComment); GDREGISTER_CLASS(VisualShaderNodeFloatConstant); GDREGISTER_CLASS(VisualShaderNodeIntConstant); @@ -607,11 +607,11 @@ void register_scene_types() { GDREGISTER_CLASS(VisualShaderNodeTexture); GDREGISTER_CLASS(VisualShaderNodeCurveTexture); GDREGISTER_CLASS(VisualShaderNodeCurveXYZTexture); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeSample3D); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeSample3D); GDREGISTER_CLASS(VisualShaderNodeTexture2DArray); GDREGISTER_CLASS(VisualShaderNodeTexture3D); GDREGISTER_CLASS(VisualShaderNodeCubemap); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeUniform); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeUniform); GDREGISTER_CLASS(VisualShaderNodeUniformRef); GDREGISTER_CLASS(VisualShaderNodeFloatUniform); GDREGISTER_CLASS(VisualShaderNodeIntUniform); @@ -634,7 +634,7 @@ void register_scene_types() { GDREGISTER_CLASS(VisualShaderNodeCompare); GDREGISTER_CLASS(VisualShaderNodeMultiplyAdd); GDREGISTER_CLASS(VisualShaderNodeBillboard); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeVarying); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeVarying); GDREGISTER_CLASS(VisualShaderNodeVaryingSetter); GDREGISTER_CLASS(VisualShaderNodeVaryingGetter); @@ -645,7 +645,7 @@ void register_scene_types() { GDREGISTER_CLASS(VisualShaderNodeSDFRaymarch); GDREGISTER_CLASS(VisualShaderNodeParticleOutput); - GDREGISTER_VIRTUAL_CLASS(VisualShaderNodeParticleEmitter); + GDREGISTER_ABSTRACT_CLASS(VisualShaderNodeParticleEmitter); GDREGISTER_CLASS(VisualShaderNodeParticleSphereEmitter); GDREGISTER_CLASS(VisualShaderNodeParticleBoxEmitter); GDREGISTER_CLASS(VisualShaderNodeParticleRingEmitter); @@ -657,7 +657,7 @@ void register_scene_types() { GDREGISTER_CLASS(VisualShaderNodeParticleEmit); GDREGISTER_CLASS(ShaderMaterial); - GDREGISTER_VIRTUAL_CLASS(CanvasItem); + GDREGISTER_ABSTRACT_CLASS(CanvasItem); GDREGISTER_CLASS(CanvasTexture); GDREGISTER_CLASS(CanvasItemMaterial); SceneTree::add_idle_callback(CanvasItemMaterial::flush_changes); @@ -676,8 +676,8 @@ void register_scene_types() { GDREGISTER_CLASS(Line2D); GDREGISTER_CLASS(MeshInstance2D); GDREGISTER_CLASS(MultiMeshInstance2D); - GDREGISTER_VIRTUAL_CLASS(CollisionObject2D); - GDREGISTER_VIRTUAL_CLASS(PhysicsBody2D); + GDREGISTER_ABSTRACT_CLASS(CollisionObject2D); + GDREGISTER_ABSTRACT_CLASS(PhysicsBody2D); GDREGISTER_CLASS(StaticBody2D); GDREGISTER_CLASS(AnimatableBody2D); GDREGISTER_CLASS(RigidDynamicBody2D); @@ -693,7 +693,7 @@ void register_scene_types() { GDREGISTER_CLASS(Polygon2D); GDREGISTER_CLASS(Skeleton2D); GDREGISTER_CLASS(Bone2D); - GDREGISTER_VIRTUAL_CLASS(Light2D); + GDREGISTER_ABSTRACT_CLASS(Light2D); GDREGISTER_CLASS(PointLight2D); GDREGISTER_CLASS(DirectionalLight2D); GDREGISTER_CLASS(LightOccluder2D); @@ -704,12 +704,12 @@ void register_scene_types() { GDREGISTER_CLASS(Camera2D); GDREGISTER_CLASS(AudioListener2D); - GDREGISTER_VIRTUAL_CLASS(Joint2D); + GDREGISTER_ABSTRACT_CLASS(Joint2D); GDREGISTER_CLASS(PinJoint2D); GDREGISTER_CLASS(GrooveJoint2D); GDREGISTER_CLASS(DampedSpringJoint2D); GDREGISTER_CLASS(TileSet); - GDREGISTER_VIRTUAL_CLASS(TileSetSource); + GDREGISTER_ABSTRACT_CLASS(TileSetSource); GDREGISTER_CLASS(TileSetAtlasSource); GDREGISTER_CLASS(TileSetScenesCollectionSource); GDREGISTER_CLASS(TileMapPattern); @@ -736,7 +736,7 @@ void register_scene_types() { /* REGISTER RESOURCES */ - GDREGISTER_VIRTUAL_CLASS(Shader); + GDREGISTER_ABSTRACT_CLASS(Shader); GDREGISTER_CLASS(ParticlesMaterial); SceneTree::add_idle_callback(ParticlesMaterial::flush_changes); ParticlesMaterial::init_shaders(); @@ -765,7 +765,7 @@ void register_scene_types() { GDREGISTER_CLASS(RibbonTrailMesh); GDREGISTER_CLASS(PointMesh); GDREGISTER_VIRTUAL_CLASS(Material); - GDREGISTER_VIRTUAL_CLASS(BaseMaterial3D); + GDREGISTER_ABSTRACT_CLASS(BaseMaterial3D); GDREGISTER_CLASS(StandardMaterial3D); GDREGISTER_CLASS(ORMMaterial3D); SceneTree::add_idle_callback(BaseMaterial3D::flush_changes); @@ -775,7 +775,7 @@ void register_scene_types() { OS::get_singleton()->yield(); // may take time to init - GDREGISTER_VIRTUAL_CLASS(Shape3D); + GDREGISTER_ABSTRACT_CLASS(Shape3D); GDREGISTER_CLASS(SeparationRayShape3D); GDREGISTER_CLASS(SphereShape3D); GDREGISTER_CLASS(BoxShape3D); @@ -820,14 +820,14 @@ void register_scene_types() { GDREGISTER_CLASS(AnimatedTexture); GDREGISTER_CLASS(CameraTexture); GDREGISTER_VIRTUAL_CLASS(TextureLayered); - GDREGISTER_VIRTUAL_CLASS(ImageTextureLayered); + GDREGISTER_ABSTRACT_CLASS(ImageTextureLayered); GDREGISTER_VIRTUAL_CLASS(Texture3D); GDREGISTER_CLASS(ImageTexture3D); GDREGISTER_CLASS(CompressedTexture3D); GDREGISTER_CLASS(Cubemap); GDREGISTER_CLASS(CubemapArray); GDREGISTER_CLASS(Texture2DArray); - GDREGISTER_VIRTUAL_CLASS(CompressedTextureLayered); + GDREGISTER_ABSTRACT_CLASS(CompressedTextureLayered); GDREGISTER_CLASS(CompressedCubemap); GDREGISTER_CLASS(CompressedCubemapArray); GDREGISTER_CLASS(CompressedTexture2DArray); @@ -860,12 +860,12 @@ void register_scene_types() { #ifndef _3D_DISABLED GDREGISTER_CLASS(AudioStreamPlayer3D); #endif - GDREGISTER_VIRTUAL_CLASS(VideoStream); + GDREGISTER_ABSTRACT_CLASS(VideoStream); GDREGISTER_CLASS(AudioStreamSample); OS::get_singleton()->yield(); // may take time to init - GDREGISTER_VIRTUAL_CLASS(Shape2D); + GDREGISTER_ABSTRACT_CLASS(Shape2D); GDREGISTER_CLASS(WorldBoundaryShape2D); GDREGISTER_CLASS(SegmentShape2D); GDREGISTER_CLASS(SeparationRayShape2D); @@ -886,11 +886,11 @@ void register_scene_types() { OS::get_singleton()->yield(); // may take time to init - GDREGISTER_VIRTUAL_CLASS(SceneState); + GDREGISTER_ABSTRACT_CLASS(SceneState); GDREGISTER_CLASS(PackedScene); GDREGISTER_CLASS(SceneTree); - GDREGISTER_VIRTUAL_CLASS(SceneTreeTimer); // sorry, you can't create it + GDREGISTER_ABSTRACT_CLASS(SceneTreeTimer); // sorry, you can't create it #ifndef DISABLE_DEPRECATED // Dropped in 4.0, near approximation. diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 6fb0c0468d8..a0e6cc28ce3 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -88,6 +88,37 @@ void Material::inspect_native_shader_code() { } } +RID Material::get_shader_rid() const { + RID ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_shader_rid, ret)) { + return ret; + } + return RID(); +} +Shader::Mode Material::get_shader_mode() const { + Shader::Mode ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_shader_mode, ret)) { + return ret; + } + + return Shader::MODE_MAX; +} + +bool Material::_can_do_next_pass() const { + bool ret; + if (GDVIRTUAL_CALL(_can_do_next_pass, ret)) { + return ret; + } + return false; +} +bool Material::_can_use_render_priority() const { + bool ret; + if (GDVIRTUAL_CALL(_can_use_render_priority, ret)) { + return ret; + } + return false; +} + void Material::_bind_methods() { ClassDB::bind_method(D_METHOD("set_next_pass", "next_pass"), &Material::set_next_pass); ClassDB::bind_method(D_METHOD("get_next_pass"), &Material::get_next_pass); @@ -103,6 +134,11 @@ void Material::_bind_methods() { BIND_CONSTANT(RENDER_PRIORITY_MAX); BIND_CONSTANT(RENDER_PRIORITY_MIN); + + GDVIRTUAL_BIND(_get_shader_rid) + GDVIRTUAL_BIND(_get_shader_mode) + GDVIRTUAL_BIND(_can_do_next_pass) + GDVIRTUAL_BIND(_can_use_render_priority) } Material::Material() { diff --git a/scene/resources/material.h b/scene/resources/material.h index a79f072f9a8..07227c037c8 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -51,11 +51,15 @@ class Material : public Resource { protected: _FORCE_INLINE_ RID _get_material() const { return material; } static void _bind_methods(); - virtual bool _can_do_next_pass() const { return false; } - virtual bool _can_use_render_priority() const { return false; } + virtual bool _can_do_next_pass() const; + virtual bool _can_use_render_priority() const; void _validate_property(PropertyInfo &property) const override; + GDVIRTUAL0RC(RID, _get_shader_rid) + GDVIRTUAL0RC(Shader::Mode, _get_shader_mode) + GDVIRTUAL0RC(bool, _can_do_next_pass) + GDVIRTUAL0RC(bool, _can_use_render_priority) public: enum { RENDER_PRIORITY_MAX = RS::MATERIAL_RENDER_PRIORITY_MAX, @@ -68,9 +72,8 @@ public: int get_render_priority() const; virtual RID get_rid() const override; - virtual RID get_shader_rid() const = 0; - - virtual Shader::Mode get_shader_mode() const = 0; + virtual RID get_shader_rid() const; + virtual Shader::Mode get_shader_mode() const; Material(); virtual ~Material(); }; diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 6b44b05e02f..3c67a20f50a 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -40,6 +40,122 @@ Mesh::ConvexDecompositionFunc Mesh::convex_decomposition_function = nullptr; +int Mesh::get_surface_count() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_surface_count, ret)) { + return ret; + } + return 0; +} + +int Mesh::surface_get_array_len(int p_idx) const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_array_len, p_idx, ret)) { + return ret; + } + return 0; +} + +int Mesh::surface_get_array_index_len(int p_idx) const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_array_index_len, p_idx, ret)) { + return ret; + } + return 0; +} + +Array Mesh::surface_get_arrays(int p_surface) const { + Array ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_arrays, p_surface, ret)) { + return ret; + } + return Array(); +} + +Array Mesh::surface_get_blend_shape_arrays(int p_surface) const { + Array ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_blend_shape_arrays, p_surface, ret)) { + return ret; + } + + return Array(); +} + +Dictionary Mesh::surface_get_lods(int p_surface) const { + Dictionary ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_lods, p_surface, ret)) { + return ret; + } + + return Dictionary(); +} + +uint32_t Mesh::surface_get_format(int p_idx) const { + uint32_t ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_format, p_idx, ret)) { + return ret; + } + + return 0; +} + +Mesh::PrimitiveType Mesh::surface_get_primitive_type(int p_idx) const { + uint32_t ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_primitive_type, p_idx, ret)) { + return (Mesh::PrimitiveType)ret; + } + + return PRIMITIVE_MAX; +} + +void Mesh::surface_set_material(int p_idx, const Ref &p_material) { + if (GDVIRTUAL_REQUIRED_CALL(_surface_set_material, p_idx, p_material)) { + return; + } +} + +Ref Mesh::surface_get_material(int p_idx) const { + Ref ret; + if (GDVIRTUAL_REQUIRED_CALL(_surface_get_material, p_idx, ret)) { + return ret; + } + + return Ref(); +} + +int Mesh::get_blend_shape_count() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_blend_shape_count, ret)) { + return ret; + } + + return 0; +} + +StringName Mesh::get_blend_shape_name(int p_index) const { + StringName ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_blend_shape_name, p_index, ret)) { + return ret; + } + + return StringName(); +} + +void Mesh::set_blend_shape_name(int p_index, const StringName &p_name) { + if (GDVIRTUAL_REQUIRED_CALL(_set_blend_shape_name, p_index, p_name)) { + return; + } +} + +AABB Mesh::get_aabb() const { + AABB ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_aabb, ret)) { + return ret; + } + + return AABB(); +} + Ref Mesh::generate_triangle_mesh() const { if (triangle_mesh.is_valid()) { return triangle_mesh; @@ -502,6 +618,21 @@ void Mesh::_bind_methods() { BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_NORMALIZED); BIND_ENUM_CONSTANT(BLEND_SHAPE_MODE_RELATIVE); + + GDVIRTUAL_BIND(_get_surface_count) + GDVIRTUAL_BIND(_surface_get_array_len, "index") + GDVIRTUAL_BIND(_surface_get_array_index_len, "index") + GDVIRTUAL_BIND(_surface_get_arrays, "index") + GDVIRTUAL_BIND(_surface_get_blend_shape_arrays, "index") + GDVIRTUAL_BIND(_surface_get_lods, "index") + GDVIRTUAL_BIND(_surface_get_format, "index") + GDVIRTUAL_BIND(_surface_get_primitive_type, "index") + GDVIRTUAL_BIND(_surface_set_material, "index", "material") + GDVIRTUAL_BIND(_surface_get_material, "index") + GDVIRTUAL_BIND(_get_blend_shape_count) + GDVIRTUAL_BIND(_get_blend_shape_name, "index") + GDVIRTUAL_BIND(_set_blend_shape_name, "index", "name") + GDVIRTUAL_BIND(_get_aabb) } void Mesh::clear_cache() const { diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index 08d834bdb95..652c045a248 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -45,9 +45,34 @@ class Mesh : public Resource { mutable Vector debug_lines; Size2i lightmap_size_hint; +public: + enum PrimitiveType { + PRIMITIVE_POINTS = RenderingServer::PRIMITIVE_POINTS, + PRIMITIVE_LINES = RenderingServer::PRIMITIVE_LINES, + PRIMITIVE_LINE_STRIP = RenderingServer::PRIMITIVE_LINE_STRIP, + PRIMITIVE_TRIANGLES = RenderingServer::PRIMITIVE_TRIANGLES, + PRIMITIVE_TRIANGLE_STRIP = RenderingServer::PRIMITIVE_TRIANGLE_STRIP, + PRIMITIVE_MAX = RenderingServer::PRIMITIVE_MAX, + }; + protected: static void _bind_methods(); + GDVIRTUAL0RC(int, _get_surface_count) + GDVIRTUAL1RC(int, _surface_get_array_len, int) + GDVIRTUAL1RC(int, _surface_get_array_index_len, int) + GDVIRTUAL1RC(Array, _surface_get_arrays, int) + GDVIRTUAL1RC(Array, _surface_get_blend_shape_arrays, int) + GDVIRTUAL1RC(Dictionary, _surface_get_lods, int) + GDVIRTUAL1RC(uint32_t, _surface_get_format, int) + GDVIRTUAL1RC(uint32_t, _surface_get_primitive_type, int) + GDVIRTUAL2(_surface_set_material, int, Ref) + GDVIRTUAL1RC(Ref, _surface_get_material, int) + GDVIRTUAL0RC(int, _get_blend_shape_count) + GDVIRTUAL1RC(StringName, _get_blend_shape_name, int) + GDVIRTUAL2(_set_blend_shape_name, int, StringName) + GDVIRTUAL0RC(AABB, _get_aabb) + public: enum { NO_INDEX_ARRAY = RenderingServer::NO_INDEX_ARRAY, @@ -120,28 +145,20 @@ public: }; - enum PrimitiveType { - PRIMITIVE_POINTS = RenderingServer::PRIMITIVE_POINTS, - PRIMITIVE_LINES = RenderingServer::PRIMITIVE_LINES, - PRIMITIVE_LINE_STRIP = RenderingServer::PRIMITIVE_LINE_STRIP, - PRIMITIVE_TRIANGLES = RenderingServer::PRIMITIVE_TRIANGLES, - PRIMITIVE_TRIANGLE_STRIP = RenderingServer::PRIMITIVE_TRIANGLE_STRIP, - PRIMITIVE_MAX = RenderingServer::PRIMITIVE_MAX, - }; - - virtual int get_surface_count() const = 0; - virtual int surface_get_array_len(int p_idx) const = 0; - virtual int surface_get_array_index_len(int p_idx) const = 0; - virtual Array surface_get_arrays(int p_surface) const = 0; - virtual Array surface_get_blend_shape_arrays(int p_surface) const = 0; - virtual Dictionary surface_get_lods(int p_surface) const = 0; - virtual uint32_t surface_get_format(int p_idx) const = 0; - virtual PrimitiveType surface_get_primitive_type(int p_idx) const = 0; - virtual void surface_set_material(int p_idx, const Ref &p_material) = 0; - virtual Ref surface_get_material(int p_idx) const = 0; - virtual int get_blend_shape_count() const = 0; - virtual StringName get_blend_shape_name(int p_index) const = 0; - virtual void set_blend_shape_name(int p_index, const StringName &p_name) = 0; + virtual int get_surface_count() const; + virtual int surface_get_array_len(int p_idx) const; + virtual int surface_get_array_index_len(int p_idx) const; + virtual Array surface_get_arrays(int p_surface) const; + virtual Array surface_get_blend_shape_arrays(int p_surface) const; + virtual Dictionary surface_get_lods(int p_surface) const; + virtual uint32_t surface_get_format(int p_idx) const; + virtual PrimitiveType surface_get_primitive_type(int p_idx) const; + virtual void surface_set_material(int p_idx, const Ref &p_material); + virtual Ref surface_get_material(int p_idx) const; + virtual int get_blend_shape_count() const; + virtual StringName get_blend_shape_name(int p_index) const; + virtual void set_blend_shape_name(int p_index, const StringName &p_name); + virtual AABB get_aabb() const; Vector get_faces() const; Ref generate_triangle_mesh() const; @@ -153,8 +170,6 @@ public: Ref create_outline(float p_margin) const; - virtual AABB get_aabb() const = 0; - void set_lightmap_size_hint(const Size2i &p_size); Size2i get_lightmap_size_hint() const; void clear_cache() const; diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 38acd0af0ae..781e219f1fd 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -36,11 +36,17 @@ */ void PrimitiveMesh::_update() const { Array arr; - arr.resize(RS::ARRAY_MAX); - _create_mesh_array(arr); + if (GDVIRTUAL_CALL(_create_mesh_array, arr)) { + ERR_FAIL_COND_MSG(arr.size() != RS::ARRAY_MAX, "_create_mesh_array must return an array of Mesh.ARRAY_MAX elements."); + } else { + arr.resize(RS::ARRAY_MAX); + _create_mesh_array(arr); + } Vector points = arr[RS::ARRAY_VERTEX]; + ERR_FAIL_COND_MSG(points.size() == 0, "_create_mesh_array must return at least a vertex array."); + aabb = AABB(); int pc = points.size(); @@ -210,6 +216,8 @@ void PrimitiveMesh::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "BaseMaterial3D,ShaderMaterial"), "set_material", "get_material"); ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, ""), "set_custom_aabb", "get_custom_aabb"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_faces"), "set_flip_faces", "get_flip_faces"); + + GDVIRTUAL_BIND(_create_mesh_array); } void PrimitiveMesh::set_material(const Ref &p_material) { diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index 3fc5fd4a169..eef5eb3f7d3 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -64,8 +64,9 @@ protected: static void _bind_methods(); - virtual void _create_mesh_array(Array &p_arr) const = 0; + virtual void _create_mesh_array(Array &p_arr) const {} void _request_update(); + GDVIRTUAL0RC(Array, _create_mesh_array) public: virtual int get_surface_count() const override; diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 5afd424e039..fe527614826 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -34,10 +34,28 @@ #include +float StyleBox::get_style_margin(Side p_side) const { + float ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_style_margin, p_side, ret)) { + return ret; + } + return 0; +} bool StyleBox::test_mask(const Point2 &p_point, const Rect2 &p_rect) const { + bool ret; + if (GDVIRTUAL_CALL(_test_mask, p_point, p_rect, ret)) { + return ret; + } + return true; } +void StyleBox::draw(RID p_canvas_item, const Rect2 &p_rect) const { + if (GDVIRTUAL_REQUIRED_CALL(_draw, p_canvas_item, p_rect)) { + return; + } +} + void StyleBox::set_default_margin(Side p_side, float p_value) { ERR_FAIL_INDEX((int)p_side, 4); @@ -74,10 +92,19 @@ Point2 StyleBox::get_offset() const { } Size2 StyleBox::get_center_size() const { + Size2 ret; + if (GDVIRTUAL_CALL(_get_center_size, ret)) { + return ret; + } + return Size2(); } Rect2 StyleBox::get_draw_rect(const Rect2 &p_rect) const { + Rect2 ret; + if (GDVIRTUAL_CALL(_get_draw_rect, p_rect, ret)) { + return ret; + } return p_rect; } @@ -100,6 +127,12 @@ void StyleBox::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_right", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", SIDE_RIGHT); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_top", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", SIDE_TOP); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "content_margin_bottom", PROPERTY_HINT_RANGE, "-1,2048,1"), "set_default_margin", "get_default_margin", SIDE_BOTTOM); + + GDVIRTUAL_BIND(_get_style_margin, "side") + GDVIRTUAL_BIND(_test_mask, "point", "rect") + GDVIRTUAL_BIND(_get_center_size) + GDVIRTUAL_BIND(_get_draw_rect, "rect") + GDVIRTUAL_BIND(_draw, "to_canvas_item", "rect") } StyleBox::StyleBox() { diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 4c41f42293d..68ad41b69ce 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -44,9 +44,15 @@ class StyleBox : public Resource { float margin[4]; protected: - virtual float get_style_margin(Side p_side) const = 0; + virtual float get_style_margin(Side p_side) const; static void _bind_methods(); + GDVIRTUAL1RC(float, _get_style_margin, Side) + GDVIRTUAL2RC(bool, _test_mask, Point2, Rect2) + GDVIRTUAL0RC(Size2, _get_center_size) + GDVIRTUAL1RC(Rect2, _get_draw_rect, Rect2) + GDVIRTUAL2C(_draw, RID, Rect2) + public: virtual bool test_mask(const Point2 &p_point, const Rect2 &p_rect) const; @@ -56,7 +62,7 @@ public: virtual Size2 get_center_size() const; virtual Rect2 get_draw_rect(const Rect2 &p_rect) const; - virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const = 0; + virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const; CanvasItem *get_current_item_drawn() const; diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 1ab1d81355d..d541284381b 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -38,23 +38,61 @@ #include "scene/resources/bit_map.h" #include "servers/camera/camera_feed.h" +int Texture2D::get_width() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) { + return ret; + } + return 0; +} + +int Texture2D::get_height() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) { + return ret; + } + return 0; +} + Size2 Texture2D::get_size() const { return Size2(get_width(), get_height()); } bool Texture2D::is_pixel_opaque(int p_x, int p_y) const { + bool ret; + if (GDVIRTUAL_CALL(_is_pixel_opaque, p_x, p_y, ret)) { + return ret; + } + + return true; +} +bool Texture2D::has_alpha() const { + bool ret; + if (GDVIRTUAL_CALL(_has_alpha, ret)) { + return ret; + } + return true; } void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const { + if (GDVIRTUAL_CALL(_draw, p_canvas_item, p_pos, p_modulate, p_transpose)) { + return; + } RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose); } void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const { + if (GDVIRTUAL_CALL(_draw_rect, p_canvas_item, p_rect, p_tile, p_modulate, p_transpose)) { + return; + } RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose); } void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const { + if (GDVIRTUAL_CALL(_draw_rect_region, p_canvas_item, p_rect, p_src_rect, p_modulate, p_transpose, p_clip_uv)) { + return; + } RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, p_clip_uv); } @@ -75,6 +113,15 @@ void Texture2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_image"), &Texture2D::get_image); ADD_GROUP("", ""); + + GDVIRTUAL_BIND(_get_width); + GDVIRTUAL_BIND(_get_height); + GDVIRTUAL_BIND(_is_pixel_opaque, "x", "y"); + GDVIRTUAL_BIND(_has_alpha); + + GDVIRTUAL_BIND(_draw, "to_canvas_item", "pos", "modulate", "transpose") + GDVIRTUAL_BIND(_draw_rect, "to_canvas_item", "rect", "tile", "modulate", "transpose") + GDVIRTUAL_BIND(_draw_rect_region, "tp_canvas_item", "rect", "src_rect", "modulate", "transpose", "clip_uv"); } Texture2D::Texture2D() { @@ -740,7 +787,7 @@ String ResourceFormatLoaderCompressedTexture2D::get_resource_type(const String & //////////////////////////////////// -TypedArray Texture3D::_get_data() const { +TypedArray Texture3D::_get_datai() const { Vector> data = get_data(); TypedArray ret; @@ -751,13 +798,73 @@ TypedArray Texture3D::_get_data() const { return ret; } +Image::Format Texture3D::get_format() const { + Image::Format ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_format, ret)) { + return ret; + } + return Image::FORMAT_MAX; +} + +int Texture3D::get_width() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) { + return ret; + } + return 0; +} + +int Texture3D::get_height() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) { + return ret; + } + return 0; +} + +int Texture3D::get_depth() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_depth, ret)) { + return ret; + } + + return 0; +} + +bool Texture3D::has_mipmaps() const { + bool ret; + if (GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret)) { + return ret; + } + return 0; +} + +Vector> Texture3D::get_data() const { + TypedArray ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_data, ret)) { + Vector> data; + data.resize(ret.size()); + for (int i = 0; i < data.size(); i++) { + data.write[i] = ret[i]; + } + return data; + } + return Vector>(); +} void Texture3D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_format"), &Texture3D::get_format); ClassDB::bind_method(D_METHOD("get_width"), &Texture3D::get_width); ClassDB::bind_method(D_METHOD("get_height"), &Texture3D::get_height); ClassDB::bind_method(D_METHOD("get_depth"), &Texture3D::get_depth); ClassDB::bind_method(D_METHOD("has_mipmaps"), &Texture3D::has_mipmaps); - ClassDB::bind_method(D_METHOD("get_data"), &Texture3D::_get_data); + ClassDB::bind_method(D_METHOD("get_data"), &Texture3D::_get_datai); + + GDVIRTUAL_BIND(_get_format); + GDVIRTUAL_BIND(_get_width); + GDVIRTUAL_BIND(_get_height); + GDVIRTUAL_BIND(_get_depth); + GDVIRTUAL_BIND(_has_mipmaps); + GDVIRTUAL_BIND(_get_data); } ////////////////////////////////////////// @@ -2446,6 +2553,63 @@ AnimatedTexture::~AnimatedTexture() { /////////////////////////////// +Image::Format TextureLayered::get_format() const { + Image::Format ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_format, ret)) { + return ret; + } + return Image::FORMAT_MAX; +} + +TextureLayered::LayeredType TextureLayered::get_layered_type() const { + uint32_t ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_layered_type, ret)) { + return (LayeredType)ret; + } + return LAYERED_TYPE_2D_ARRAY; +} + +int TextureLayered::get_width() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_width, ret)) { + return ret; + } + return 0; +} + +int TextureLayered::get_height() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_height, ret)) { + return ret; + } + return 0; +} + +int TextureLayered::get_layers() const { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_layers, ret)) { + return ret; + } + + return 0; +} + +bool TextureLayered::has_mipmaps() const { + bool ret; + if (GDVIRTUAL_REQUIRED_CALL(_has_mipmaps, ret)) { + return ret; + } + return false; +} + +Ref TextureLayered::get_layer_data(int p_layer) const { + Ref ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_layer_data, p_layer, ret)) { + return ret; + } + return Ref(); +} + void TextureLayered::_bind_methods() { ClassDB::bind_method(D_METHOD("get_format"), &TextureLayered::get_format); ClassDB::bind_method(D_METHOD("get_layered_type"), &TextureLayered::get_layered_type); @@ -2458,6 +2622,14 @@ void TextureLayered::_bind_methods() { BIND_ENUM_CONSTANT(LAYERED_TYPE_2D_ARRAY); BIND_ENUM_CONSTANT(LAYERED_TYPE_CUBEMAP); BIND_ENUM_CONSTANT(LAYERED_TYPE_CUBEMAP_ARRAY); + + GDVIRTUAL_BIND(_get_format); + GDVIRTUAL_BIND(_get_layered_type); + GDVIRTUAL_BIND(_get_width); + GDVIRTUAL_BIND(_get_height); + GDVIRTUAL_BIND(_get_layers); + GDVIRTUAL_BIND(_has_mipmaps); + GDVIRTUAL_BIND(_get_layer_data, "layer_index"); } /////////////////////////////// diff --git a/scene/resources/texture.h b/scene/resources/texture.h index a3c147610d5..1e07b83547b 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -57,14 +57,23 @@ class Texture2D : public Texture { protected: static void _bind_methods(); + GDVIRTUAL0RC(int, _get_width) + GDVIRTUAL0RC(int, _get_height) + GDVIRTUAL2RC(bool, _is_pixel_opaque, int, int) + GDVIRTUAL0RC(bool, _has_alpha) + + GDVIRTUAL4C(_draw, RID, Point2, Color, bool) + GDVIRTUAL5C(_draw_rect, RID, Rect2, bool, Color, bool) + GDVIRTUAL6C(_draw_rect_region, RID, Rect2, Rect2, Color, bool, bool) + public: - virtual int get_width() const = 0; - virtual int get_height() const = 0; + virtual int get_width() const; + virtual int get_height() const; virtual Size2 get_size() const; virtual bool is_pixel_opaque(int p_x, int p_y) const; - virtual bool has_alpha() const = 0; + virtual bool has_alpha() const; virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const; virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const; @@ -300,6 +309,13 @@ class TextureLayered : public Texture { protected: static void _bind_methods(); + GDVIRTUAL0RC(Image::Format, _get_format) + GDVIRTUAL0RC(uint32_t, _get_layered_type) + GDVIRTUAL0RC(int, _get_width) + GDVIRTUAL0RC(int, _get_height) + GDVIRTUAL0RC(int, _get_layers) + GDVIRTUAL0RC(bool, _has_mipmaps) + GDVIRTUAL1RC(Ref, _get_layer_data, int) public: enum LayeredType { LAYERED_TYPE_2D_ARRAY, @@ -307,13 +323,15 @@ public: LAYERED_TYPE_CUBEMAP_ARRAY }; - virtual Image::Format get_format() const = 0; - virtual LayeredType get_layered_type() const = 0; - virtual int get_width() const = 0; - virtual int get_height() const = 0; - virtual int get_layers() const = 0; - virtual bool has_mipmaps() const = 0; - virtual Ref get_layer_data(int p_layer) const = 0; + virtual Image::Format get_format() const; + virtual LayeredType get_layered_type() const; + virtual int get_width() const; + virtual int get_height() const; + virtual int get_layers() const; + virtual bool has_mipmaps() const; + virtual Ref get_layer_data(int p_layer) const; + + TextureLayered() {} }; VARIANT_ENUM_CAST(TextureLayered::LayeredType) @@ -474,15 +492,21 @@ class Texture3D : public Texture { protected: static void _bind_methods(); - TypedArray _get_data() const; + TypedArray _get_datai() const; + GDVIRTUAL0RC(Image::Format, _get_format) + GDVIRTUAL0RC(int, _get_width) + GDVIRTUAL0RC(int, _get_height) + GDVIRTUAL0RC(int, _get_depth) + GDVIRTUAL0RC(bool, _has_mipmaps) + GDVIRTUAL0RC(TypedArray, _get_data) public: - virtual Image::Format get_format() const = 0; - virtual int get_width() const = 0; - virtual int get_height() const = 0; - virtual int get_depth() const = 0; - virtual bool has_mipmaps() const = 0; - virtual Vector> get_data() const = 0; + virtual Image::Format get_format() const; + virtual int get_width() const; + virtual int get_height() const; + virtual int get_depth() const; + virtual bool has_mipmaps() const; + virtual Vector> get_data() const; }; class ImageTexture3D : public Texture3D { diff --git a/servers/audio/audio_effect.cpp b/servers/audio/audio_effect.cpp index b9eca14a4c9..f38d0adfb2e 100644 --- a/servers/audio/audio_effect.cpp +++ b/servers/audio/audio_effect.cpp @@ -30,5 +30,36 @@ #include "audio_effect.h" +void AudioEffectInstance::process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) { + if (GDVIRTUAL_REQUIRED_CALL(_process, p_src_frames, p_dst_frames, p_frame_count)) { + return; + } +} +bool AudioEffectInstance::process_silence() const { + bool ret; + if (GDVIRTUAL_CALL(_process_silence, ret)) { + return ret; + } + return false; +} + +void AudioEffectInstance::_bind_methods() { + GDVIRTUAL_BIND(_process, "src_buffer", "dst_buffer", "frame_count"); + GDVIRTUAL_BIND(_process_silence); +} + +//// + +Ref AudioEffect::instantiate() { + Ref ret; + if (GDVIRTUAL_REQUIRED_CALL(_instantiate, ret)) { + return ret; + } + return Ref(); +} +void AudioEffect::_bind_methods() { + GDVIRTUAL_BIND(_instantiate); +} + AudioEffect::AudioEffect() { } diff --git a/servers/audio/audio_effect.h b/servers/audio/audio_effect.h index 00a5d6c0042..3a0578679da 100644 --- a/servers/audio/audio_effect.h +++ b/servers/audio/audio_effect.h @@ -33,20 +33,32 @@ #include "core/io/resource.h" #include "core/math/audio_frame.h" +#include "core/object/gdvirtual.gen.inc" +#include "core/object/script_language.h" +#include "core/variant/native_ptr.h" class AudioEffectInstance : public RefCounted { GDCLASS(AudioEffectInstance, RefCounted); +protected: + GDVIRTUAL3(_process, GDNativeConstPtr, GDNativePtr, int) + GDVIRTUAL0RC(bool, _process_silence) + static void _bind_methods(); + public: - virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count) = 0; - virtual bool process_silence() const { return false; } + virtual void process(const AudioFrame *p_src_frames, AudioFrame *p_dst_frames, int p_frame_count); + virtual bool process_silence() const; }; class AudioEffect : public Resource { GDCLASS(AudioEffect, Resource); +protected: + GDVIRTUAL0R(Ref, _instantiate) + static void _bind_methods(); + public: - virtual Ref instantiate() = 0; + virtual Ref instantiate(); AudioEffect(); }; diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index a710658bff7..1ebd57fa7fd 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -76,10 +76,10 @@ void AudioStreamPlayback::seek(float p_time) { int AudioStreamPlayback::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) { int ret; - if (GDVIRTUAL_CALL(_mix, p_buffer, p_rate_scale, p_frames, ret)) { + if (GDVIRTUAL_REQUIRED_CALL(_mix, p_buffer, p_rate_scale, p_frames, ret)) { return ret; } - WARN_PRINT_ONCE("AudioStreamPlayback::mix unimplemented!"); + return 0; } @@ -94,7 +94,7 @@ void AudioStreamPlayback::_bind_methods() { } ////////////////////////////// -void AudioStreamPlaybackResampled::_begin_resample() { +void AudioStreamPlaybackResampled::begin_resample() { //clear cubic interpolation history internal_buffer[0] = AudioFrame(0.0, 0.0); internal_buffer[1] = AudioFrame(0.0, 0.0); @@ -105,6 +105,30 @@ void AudioStreamPlaybackResampled::_begin_resample() { mix_offset = 0; } +int AudioStreamPlaybackResampled::_mix_internal(AudioFrame *p_buffer, int p_frames) { + int ret; + if (GDVIRTUAL_REQUIRED_CALL(_mix_resampled, p_buffer, p_frames, ret)) { + return ret; + } + + return 0; +} +float AudioStreamPlaybackResampled::get_stream_sampling_rate() { + float ret; + if (GDVIRTUAL_REQUIRED_CALL(_get_stream_sampling_rate, ret)) { + return ret; + } + + return 0; +} + +void AudioStreamPlaybackResampled::_bind_methods() { + ClassDB::bind_method(D_METHOD("begin_resample"), &AudioStreamPlaybackResampled::begin_resample); + + GDVIRTUAL_BIND(_mix_resampled, "dst_buffer", "frame_count"); + GDVIRTUAL_BIND(_get_stream_sampling_rate); +} + int AudioStreamPlaybackResampled::mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) { float target_rate = AudioServer::get_singleton()->get_mix_rate(); float playback_speed_scale = AudioServer::get_singleton()->get_playback_speed_scale(); @@ -315,7 +339,7 @@ void AudioStreamPlaybackMicrophone::start(float p_from_pos) { if (AudioDriver::get_singleton()->capture_start() == OK) { active = true; - _begin_resample(); + begin_resample(); } } diff --git a/servers/audio/audio_stream.h b/servers/audio/audio_stream.h index ce9bcabb9c3..55031dec2cf 100644 --- a/servers/audio/audio_stream.h +++ b/servers/audio/audio_stream.h @@ -81,10 +81,15 @@ class AudioStreamPlaybackResampled : public AudioStreamPlayback { uint64_t mix_offset; protected: - void _begin_resample(); + void begin_resample(); // Returns the number of frames that were mixed. - virtual int _mix_internal(AudioFrame *p_buffer, int p_frames) = 0; - virtual float get_stream_sampling_rate() = 0; + virtual int _mix_internal(AudioFrame *p_buffer, int p_frames); + virtual float get_stream_sampling_rate(); + + GDVIRTUAL2R(int, _mix_resampled, GDNativePtr, int) + GDVIRTUAL0RC(float, _get_stream_sampling_rate) + + static void _bind_methods(); public: virtual int mix(AudioFrame *p_buffer, float p_rate_scale, int p_frames) override; diff --git a/servers/audio/effects/audio_stream_generator.cpp b/servers/audio/effects/audio_stream_generator.cpp index 6c917f3eb61..a3d615b925d 100644 --- a/servers/audio/effects/audio_stream_generator.cpp +++ b/servers/audio/effects/audio_stream_generator.cpp @@ -169,7 +169,7 @@ float AudioStreamGeneratorPlayback::get_stream_sampling_rate() { void AudioStreamGeneratorPlayback::start(float p_from_pos) { if (mixed == 0.0) { - _begin_resample(); + begin_resample(); } skips = 0; active = true; diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index f405dea770b..6848620b48c 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -110,7 +110,7 @@ void preregister_server_types() { shader_types = memnew(ShaderTypes); GDREGISTER_CLASS(TextServerManager); - GDREGISTER_VIRTUAL_CLASS(TextServer); + GDREGISTER_ABSTRACT_CLASS(TextServer); GDREGISTER_CLASS(TextServerExtension); Engine::get_singleton()->add_singleton(Engine::Singleton("TextServerManager", TextServerManager::get_singleton(), "TextServerManager")); @@ -119,20 +119,20 @@ void preregister_server_types() { void register_server_types() { OS::get_singleton()->set_has_server_feature_callback(has_server_feature_callback); - GDREGISTER_VIRTUAL_CLASS(DisplayServer); - GDREGISTER_VIRTUAL_CLASS(RenderingServer); + GDREGISTER_ABSTRACT_CLASS(DisplayServer); + GDREGISTER_ABSTRACT_CLASS(RenderingServer); GDREGISTER_CLASS(AudioServer); - GDREGISTER_VIRTUAL_CLASS(PhysicsServer2D); - GDREGISTER_VIRTUAL_CLASS(PhysicsServer3D); - GDREGISTER_VIRTUAL_CLASS(NavigationServer2D); - GDREGISTER_VIRTUAL_CLASS(NavigationServer3D); + GDREGISTER_ABSTRACT_CLASS(PhysicsServer2D); + GDREGISTER_ABSTRACT_CLASS(PhysicsServer3D); + GDREGISTER_ABSTRACT_CLASS(NavigationServer2D); + GDREGISTER_ABSTRACT_CLASS(NavigationServer3D); GDREGISTER_CLASS(XRServer); GDREGISTER_CLASS(CameraServer); - GDREGISTER_VIRTUAL_CLASS(RenderingDevice); + GDREGISTER_ABSTRACT_CLASS(RenderingDevice); - GDREGISTER_VIRTUAL_CLASS(XRInterface); + GDREGISTER_ABSTRACT_CLASS(XRInterface); GDREGISTER_CLASS(XRInterfaceExtension); // can't register this as virtual because we need a creation function for our extensions. GDREGISTER_CLASS(XRPose); GDREGISTER_CLASS(XRPositionalTracker); @@ -149,7 +149,7 @@ void register_server_types() { GDREGISTER_CLASS(AudioBusLayout); GDREGISTER_CLASS(AudioStreamGenerator); - GDREGISTER_VIRTUAL_CLASS(AudioStreamGeneratorPlayback); + GDREGISTER_ABSTRACT_CLASS(AudioStreamGeneratorPlayback); { //audio effects @@ -183,12 +183,12 @@ void register_server_types() { GDREGISTER_CLASS(AudioEffectRecord); GDREGISTER_CLASS(AudioEffectSpectrumAnalyzer); - GDREGISTER_VIRTUAL_CLASS(AudioEffectSpectrumAnalyzerInstance); + GDREGISTER_ABSTRACT_CLASS(AudioEffectSpectrumAnalyzerInstance); GDREGISTER_CLASS(AudioEffectCapture); } - GDREGISTER_VIRTUAL_CLASS(RenderingDevice); + GDREGISTER_ABSTRACT_CLASS(RenderingDevice); GDREGISTER_CLASS(RDTextureFormat); GDREGISTER_CLASS(RDTextureView); GDREGISTER_CLASS(RDAttachmentFormat); @@ -208,16 +208,16 @@ void register_server_types() { GDREGISTER_CLASS(CameraFeed); - GDREGISTER_VIRTUAL_CLASS(PhysicsDirectBodyState2D); - GDREGISTER_VIRTUAL_CLASS(PhysicsDirectSpaceState2D); + GDREGISTER_ABSTRACT_CLASS(PhysicsDirectBodyState2D); + GDREGISTER_ABSTRACT_CLASS(PhysicsDirectSpaceState2D); GDREGISTER_CLASS(PhysicsRayQueryParameters2D); GDREGISTER_CLASS(PhysicsPointQueryParameters2D); GDREGISTER_CLASS(PhysicsShapeQueryParameters2D); GDREGISTER_CLASS(PhysicsTestMotionParameters2D); GDREGISTER_CLASS(PhysicsTestMotionResult2D); - GDREGISTER_VIRTUAL_CLASS(PhysicsDirectBodyState3D); - GDREGISTER_VIRTUAL_CLASS(PhysicsDirectSpaceState3D); + GDREGISTER_ABSTRACT_CLASS(PhysicsDirectBodyState3D); + GDREGISTER_ABSTRACT_CLASS(PhysicsDirectSpaceState3D); GDREGISTER_CLASS(PhysicsRayQueryParameters3D); GDREGISTER_CLASS(PhysicsPointQueryParameters3D); GDREGISTER_CLASS(PhysicsShapeQueryParameters3D);