From d655ee5130893e0b7d88c5523393eee72f153203 Mon Sep 17 00:00:00 2001 From: Jason Kuo Date: Sat, 28 Sep 2024 13:02:09 +0800 Subject: [PATCH] Add `activate_feed` and `deactivate_feed` virtual bind to CameraFeed --- doc/classes/CameraFeed.xml | 12 ++++++++++++ servers/camera/camera_feed.cpp | 10 +++++++--- servers/camera/camera_feed.h | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/classes/CameraFeed.xml b/doc/classes/CameraFeed.xml index 8033c0880b5..95b68fce8e1 100644 --- a/doc/classes/CameraFeed.xml +++ b/doc/classes/CameraFeed.xml @@ -10,6 +10,18 @@ + + + + Called when the camera feed is activated. + + + + + + Called when the camera feed is deactivated. + + diff --git a/servers/camera/camera_feed.cpp b/servers/camera/camera_feed.cpp index 8f6a40481d7..a20b4241a6e 100644 --- a/servers/camera/camera_feed.cpp +++ b/servers/camera/camera_feed.cpp @@ -59,6 +59,9 @@ void CameraFeed::_bind_methods() { ClassDB::bind_method(D_METHOD("get_formats"), &CameraFeed::get_formats); ClassDB::bind_method(D_METHOD("set_format", "index", "parameters"), &CameraFeed::set_format); + GDVIRTUAL_BIND(_activate_feed); + GDVIRTUAL_BIND(_deactivate_feed); + ADD_SIGNAL(MethodInfo("frame_changed")); ADD_SIGNAL(MethodInfo("format_changed")); @@ -256,12 +259,13 @@ void CameraFeed::set_YCbCr_imgs(const Ref &p_y_img, const Ref &p_c } bool CameraFeed::activate_feed() { - // nothing to do here - return true; + bool ret = true; + GDVIRTUAL_CALL(_activate_feed, ret); + return ret; } void CameraFeed::deactivate_feed() { - // nothing to do here + GDVIRTUAL_CALL(_deactivate_feed); } bool CameraFeed::set_format(int p_index, const Dictionary &p_parameters) { diff --git a/servers/camera/camera_feed.h b/servers/camera/camera_feed.h index 5d1f54be07e..0267097b3db 100644 --- a/servers/camera/camera_feed.h +++ b/servers/camera/camera_feed.h @@ -120,6 +120,9 @@ public: virtual bool activate_feed(); virtual void deactivate_feed(); + + GDVIRTUAL0R(bool, _activate_feed) + GDVIRTUAL0(_deactivate_feed) }; VARIANT_ENUM_CAST(CameraFeed::FeedDataType);