diff --git a/src/frame.cpp b/src/frame.cpp index 398c43d..784d5c8 100644 --- a/src/frame.cpp +++ b/src/frame.cpp @@ -89,15 +89,15 @@ void UltraleapFrame::fill_frame_data(Ref ul_frame, const LEAP_TR for (size_t i = 0; i < frame->nHands; i++) { if (frame->pHands[i].type == eLeapHandType_Left) { - if (ul_frame->get_left_hand() == NULL) { - ul_frame->set_left_hand(Ref(memnew(UltraleapHand))); + if (!ul_frame->left_hand.is_valid()) { + ul_frame->left_hand.instantiate(); } UltraleapHand::fill_hand_data(ul_frame->get_left_hand(), &frame->pHands[i], rigging_transform); ul_frame->is_left_hand_visible = true; } else { - if (ul_frame->get_right_hand() == NULL) { - ul_frame->set_right_hand(Ref(memnew(UltraleapHand))); + if (!ul_frame->right_hand.is_valid()) { + ul_frame->right_hand.instantiate(); } UltraleapHand::fill_hand_data(ul_frame->get_right_hand(), &frame->pHands[i], rigging_transform); ul_frame->is_right_hand_visible = true; diff --git a/src/frame.h b/src/frame.h index ce151b9..bf9aafe 100644 --- a/src/frame.h +++ b/src/frame.h @@ -26,11 +26,11 @@ public: float framerate; - Ref get_left_hand() { return left_hand_ref; } - void set_left_hand(Ref value) { left_hand_ref = value; } + Ref get_left_hand() { return left_hand; } + void set_left_hand(Ref value) { left_hand = value; } - Ref get_right_hand() { return right_hand_ref; } - void set_right_hand(Ref value) { right_hand_ref = value; } + Ref get_right_hand() { return right_hand; } + void set_right_hand(Ref value) { right_hand = value; } bool get_is_left_hand_visible() { return is_left_hand_visible; } void set_is_left_hand_visible(bool value) { is_left_hand_visible = value; } @@ -46,8 +46,8 @@ protected: static void _bind_methods(); private: - Ref left_hand_ref; - Ref right_hand_ref; + Ref left_hand; + Ref right_hand; }; #endif \ No newline at end of file