Use Ref<> instead of Variant in device

This commit is contained in:
rodolpheh 2023-11-13 22:13:23 +00:00
parent f7d5486734
commit 3e426d2375
4 changed files with 22 additions and 22 deletions

View File

@ -171,22 +171,22 @@ void UltraleapDevice::on_image_received(const LEAP_IMAGE* image) {
image_mutex.unlock();
}
Variant UltraleapDevice::get_last_frame() {
Ref<UltraleapFrame> UltraleapDevice::get_last_frame() {
std::lock_guard<std::mutex> guard(frame_mutex);
return last_frame_ref;
}
Variant UltraleapDevice::get_left_image() {
Ref<UltraleapImage> UltraleapDevice::get_left_image() {
std::lock_guard<std::mutex> guard(image_mutex);
return left_image_ref;
}
Variant UltraleapDevice::get_right_image() {
Ref<UltraleapImage> UltraleapDevice::get_right_image() {
std::lock_guard<std::mutex> guard(image_mutex);
return right_image_ref;
}
Variant UltraleapDevice::get_interpolated_frame(int64_t time) {
Ref<UltraleapFrame> UltraleapDevice::get_interpolated_frame(int64_t time) {
int64_t cpu_time = Time::get_singleton()->get_ticks_usec();
LeapUpdateRebase(rebaser, cpu_time, LeapGetNow());
LeapRebaseClock(rebaser, cpu_time, &time);
@ -207,5 +207,5 @@ Variant UltraleapDevice::get_interpolated_frame(int64_t time) {
}
}
return Variant();
return NULL;
}

View File

@ -33,15 +33,14 @@ public:
Ref<UltraleapImage> left_image_ref;
Ref<UltraleapImage> right_image_ref;
Variant get_last_frame();
Variant get_interpolated_frame(int64_t time);
Ref<UltraleapFrame> get_last_frame();
Ref<UltraleapFrame> get_interpolated_frame(int64_t time);
UltraleapTypes::TrackingMode get_tracking_mode() { return tracking_mode; }
void set_tracking_mode(UltraleapTypes::TrackingMode value);
Variant get_left_image();
Variant get_right_image();
Ref<UltraleapImage> get_left_image();
Ref<UltraleapImage> get_right_image();
uint32_t get_baseline() { return baseline; }
void set_baseline(uint32_t value) { baseline = value; }

View File

@ -269,13 +269,13 @@ UltraleapHandTracking* UltraleapDeviceNode::get_tracking() {
return Object::cast_to<UltraleapHandTracking>(get_node_or_null(tracker));
}
Variant UltraleapDeviceNode::get_last_frame() {
Ref<UltraleapFrame> UltraleapDeviceNode::get_last_frame() {
return last_frame;
}
Variant UltraleapDeviceNode::get_interpolated_frame(int64_t time) {
Ref<UltraleapFrame> UltraleapDeviceNode::get_interpolated_frame(int64_t time) {
if (current_device == NULL) {
return Variant::NIL;
return NULL;
}
return current_device->get_interpolated_frame(time);
}
@ -293,16 +293,16 @@ void UltraleapDeviceNode::set_tracking_mode(UltraleapTypes::TrackingMode value)
}
}
Variant UltraleapDeviceNode::get_left_image() {
Ref<UltraleapImage> UltraleapDeviceNode::get_left_image() {
if (current_device == NULL) {
return Variant::NIL;
return NULL;
}
return current_device->get_left_image();
}
Variant UltraleapDeviceNode::get_right_image() {
Ref<UltraleapImage> UltraleapDeviceNode::get_right_image() {
if (current_device == NULL) {
return Variant::NIL;
return NULL;
}
return current_device->get_right_image();
}

View File

@ -40,13 +40,14 @@ public:
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
Variant get_last_frame();
Variant get_interpolated_frame(int64_t time);
Variant get_left_image();
Variant get_right_image();
Ref<UltraleapFrame> get_last_frame();
Ref<UltraleapFrame> get_interpolated_frame(int64_t time);
Ref<UltraleapImage> get_left_image();
Ref<UltraleapImage> get_right_image();
void set_run_in_editor(bool value);
Variant get_run_in_editor() { return run_in_editor; }
bool get_run_in_editor() { return run_in_editor; }
protected:
static void _bind_methods();