diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-11-05 09:35:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-05 09:35:23 +0100 |
commit | 2b46e2e1d4bd4b062a379b8adb791ffd9444934c (patch) | |
tree | 998ad37a2615b7baa868aec5ba05d4bd06e3b044 /editor/plugins | |
parent | 578460f7fb7b694f4601e8e6fdc4a5ee67de4067 (diff) | |
parent | ac24070056871442b0559e7875372f40aadf8d02 (diff) |
Merge pull request #54620 from briansemrau/request-frame-callable
Use Callable in RenderingServer `request_frame_drawn_callback`
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/editor_preview_plugins.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/editor_preview_plugins.h | 20 | ||||
-rw-r--r-- | editor/plugins/tiles/tiles_editor_plugin.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/tiles/tiles_editor_plugin.h | 3 |
4 files changed, 13 insertions, 42 deletions
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 4cb2c0a76b..15c15ae6b2 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -297,14 +297,10 @@ EditorPackedScenePreviewPlugin::EditorPackedScenePreviewPlugin() { ////////////////////////////////////////////////////////////////// -void EditorMaterialPreviewPlugin::_preview_done(const Variant &p_udata) { +void EditorMaterialPreviewPlugin::_preview_done() { preview_done.set(); } -void EditorMaterialPreviewPlugin::_bind_methods() { - ClassDB::bind_method("_preview_done", &EditorMaterialPreviewPlugin::_preview_done); -} - bool EditorMaterialPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "Material"); //any material } @@ -323,7 +319,7 @@ Ref<Texture2D> EditorMaterialPreviewPlugin::generate(const RES &p_from, const Si RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture preview_done.clear(); - RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMaterialPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<EditorMaterialPreviewPlugin *>(this), &EditorMaterialPreviewPlugin::_preview_done)); while (!preview_done.is_set()) { OS::get_singleton()->delay_usec(10); @@ -699,14 +695,10 @@ EditorAudioStreamPreviewPlugin::EditorAudioStreamPreviewPlugin() { /////////////////////////////////////////////////////////////////////////// -void EditorMeshPreviewPlugin::_preview_done(const Variant &p_udata) { +void EditorMeshPreviewPlugin::_preview_done() { preview_done.set(); } -void EditorMeshPreviewPlugin::_bind_methods() { - ClassDB::bind_method("_preview_done", &EditorMeshPreviewPlugin::_preview_done); -} - bool EditorMeshPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "Mesh"); //any Mesh } @@ -738,7 +730,7 @@ Ref<Texture2D> EditorMeshPreviewPlugin::generate(const RES &p_from, const Size2 RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture preview_done.clear(); - RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorMeshPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<EditorMeshPreviewPlugin *>(this), &EditorMeshPreviewPlugin::_preview_done)); while (!preview_done.is_set()) { OS::get_singleton()->delay_usec(10); @@ -814,14 +806,10 @@ EditorMeshPreviewPlugin::~EditorMeshPreviewPlugin() { /////////////////////////////////////////////////////////////////////////// -void EditorFontPreviewPlugin::_preview_done(const Variant &p_udata) { +void EditorFontPreviewPlugin::_preview_done() { preview_done.set(); } -void EditorFontPreviewPlugin::_bind_methods() { - ClassDB::bind_method("_preview_done", &EditorFontPreviewPlugin::_preview_done); -} - bool EditorFontPreviewPlugin::handles(const String &p_type) const { return ClassDB::is_parent_class(p_type, "FontData") || ClassDB::is_parent_class(p_type, "Font"); } @@ -859,7 +847,7 @@ Ref<Texture2D> EditorFontPreviewPlugin::generate_from_path(const String &p_path, preview_done.clear(); RS::get_singleton()->viewport_set_update_mode(viewport, RS::VIEWPORT_UPDATE_ONCE); //once used for capture - RS::get_singleton()->request_frame_drawn_callback(const_cast<EditorFontPreviewPlugin *>(this), "_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<EditorFontPreviewPlugin *>(this), &EditorFontPreviewPlugin::_preview_done)); while (!preview_done.is_set()) { OS::get_singleton()->delay_usec(10); diff --git a/editor/plugins/editor_preview_plugins.h b/editor/plugins/editor_preview_plugins.h index 091feae5fb..c24dabf679 100644 --- a/editor/plugins/editor_preview_plugins.h +++ b/editor/plugins/editor_preview_plugins.h @@ -94,10 +94,7 @@ class EditorMaterialPreviewPlugin : public EditorResourcePreviewGenerator { RID camera; mutable SafeFlag preview_done; - void _preview_done(const Variant &p_udata); - -protected: - static void _bind_methods(); + void _preview_done(); public: virtual bool handles(const String &p_type) const override; @@ -138,10 +135,7 @@ class EditorMeshPreviewPlugin : public EditorResourcePreviewGenerator { RID camera; mutable SafeFlag preview_done; - void _preview_done(const Variant &p_udata); - -protected: - static void _bind_methods(); + void _preview_done(); public: virtual bool handles(const String &p_type) const override; @@ -160,10 +154,7 @@ class EditorFontPreviewPlugin : public EditorResourcePreviewGenerator { RID canvas_item; mutable SafeFlag preview_done; - void _preview_done(const Variant &p_udata); - -protected: - static void _bind_methods(); + void _preview_done(); public: virtual bool handles(const String &p_type) const override; @@ -179,10 +170,7 @@ class EditorTileMapPatternPreviewPlugin : public EditorResourcePreviewGenerator mutable SafeFlag preview_done; - void _preview_done(const Variant &p_udata); - -protected: - static void _bind_methods(); + void _preview_done(); public: virtual bool handles(const String &p_type) const override; diff --git a/editor/plugins/tiles/tiles_editor_plugin.cpp b/editor/plugins/tiles/tiles_editor_plugin.cpp index f1918073fb..8e2c16906d 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.cpp +++ b/editor/plugins/tiles/tiles_editor_plugin.cpp @@ -47,7 +47,7 @@ TilesEditorPlugin *TilesEditorPlugin::singleton = nullptr; -void TilesEditorPlugin::_pattern_preview_done(const Variant &p_udata) { +void TilesEditorPlugin::_pattern_preview_done() { pattern_preview_done.set(); } @@ -113,7 +113,7 @@ void TilesEditorPlugin::_thread() { EditorNode::get_singleton()->add_child(viewport); pattern_preview_done.clear(); - RS::get_singleton()->request_frame_drawn_callback(const_cast<TilesEditorPlugin *>(this), "_pattern_preview_done", Variant()); + RS::get_singleton()->request_frame_drawn_callback(callable_mp(const_cast<TilesEditorPlugin *>(this), &TilesEditorPlugin::_pattern_preview_done)); while (!pattern_preview_done.is_set()) { OS::get_singleton()->delay_usec(10); @@ -274,10 +274,6 @@ bool TilesEditorPlugin::handles(Object *p_object) const { return p_object->is_class("TileMap") || p_object->is_class("TileSet"); } -void TilesEditorPlugin::_bind_methods() { - ClassDB::bind_method(D_METHOD("_pattern_preview_done", "pattern"), &TilesEditorPlugin::_pattern_preview_done); -} - TilesEditorPlugin::TilesEditorPlugin(EditorNode *p_node) { set_process_internal(true); diff --git a/editor/plugins/tiles/tiles_editor_plugin.h b/editor/plugins/tiles/tiles_editor_plugin.h index dd52bdc31a..34feee965f 100644 --- a/editor/plugins/tiles/tiles_editor_plugin.h +++ b/editor/plugins/tiles/tiles_editor_plugin.h @@ -78,13 +78,12 @@ private: SafeFlag pattern_thread_exit; SafeFlag pattern_thread_exited; mutable SafeFlag pattern_preview_done; - void _pattern_preview_done(const Variant &p_udata); + void _pattern_preview_done(); static void _thread_func(void *ud); void _thread(); protected: void _notification(int p_what); - static void _bind_methods(); public: _FORCE_INLINE_ static TilesEditorPlugin *get_singleton() { return singleton; } |