summaryrefslogtreecommitdiff
path: root/servers/rendering/rendering_server_default.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-11-05 09:35:23 +0100
committerGitHub <noreply@github.com>2021-11-05 09:35:23 +0100
commit2b46e2e1d4bd4b062a379b8adb791ffd9444934c (patch)
tree998ad37a2615b7baa868aec5ba05d4bd06e3b044 /servers/rendering/rendering_server_default.cpp
parent578460f7fb7b694f4601e8e6fdc4a5ee67de4067 (diff)
parentac24070056871442b0559e7875372f40aadf8d02 (diff)
Merge pull request #54620 from briansemrau/request-frame-callable
Use Callable in RenderingServer `request_frame_drawn_callback`
Diffstat (limited to 'servers/rendering/rendering_server_default.cpp')
-rw-r--r--servers/rendering/rendering_server_default.cpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp
index 107c9f8040..2ce9a20b6b 100644
--- a/servers/rendering/rendering_server_default.cpp
+++ b/servers/rendering/rendering_server_default.cpp
@@ -64,14 +64,8 @@ void RenderingServerDefault::_free(RID p_rid) {
/* EVENT QUEUING */
-void RenderingServerDefault::request_frame_drawn_callback(Object *p_where, const StringName &p_method, const Variant &p_userdata) {
- ERR_FAIL_NULL(p_where);
- FrameDrawnCallbacks fdc;
- fdc.object = p_where->get_instance_id();
- fdc.method = p_method;
- fdc.param = p_userdata;
-
- frame_drawn_callbacks.push_back(fdc);
+void RenderingServerDefault::request_frame_drawn_callback(const Callable &p_callable) {
+ frame_drawn_callbacks.push_back(p_callable);
}
void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
@@ -103,15 +97,13 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) {
RSG::scene->update_visibility_notifiers();
while (frame_drawn_callbacks.front()) {
- Object *obj = ObjectDB::get_instance(frame_drawn_callbacks.front()->get().object);
- if (obj) {
- Callable::CallError ce;
- const Variant *v = &frame_drawn_callbacks.front()->get().param;
- obj->call(frame_drawn_callbacks.front()->get().method, &v, 1, ce);
- if (ce.error != Callable::CallError::CALL_OK) {
- String err = Variant::get_call_error_text(obj, frame_drawn_callbacks.front()->get().method, &v, 1, ce);
- ERR_PRINT("Error calling frame drawn function: " + err);
- }
+ Callable c = frame_drawn_callbacks.front()->get();
+ Variant result;
+ Callable::CallError ce;
+ c.call(nullptr, 0, result, ce);
+ if (ce.error != Callable::CallError::CALL_OK) {
+ String err = Variant::get_callable_error_text(c, nullptr, 0, ce);
+ ERR_PRINT("Error calling frame drawn function: " + err);
}
frame_drawn_callbacks.pop_front();