From 4b7e5be9b24fd760707f5d5be0da964ee511af82 Mon Sep 17 00:00:00 2001 From: avaer Date: Mon, 3 Sep 2018 12:57:29 -0400 Subject: [PATCH] Add initial magic leap found object tracking binding --- .../magicleap/include/magicleap.h | 1 + deps/exokit-bindings/magicleap/src/magicleap.cc | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/deps/exokit-bindings/magicleap/include/magicleap.h b/deps/exokit-bindings/magicleap/include/magicleap.h index 7691d5f108..94e1141a1e 100644 --- a/deps/exokit-bindings/magicleap/include/magicleap.h +++ b/deps/exokit-bindings/magicleap/include/magicleap.h @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/deps/exokit-bindings/magicleap/src/magicleap.cc b/deps/exokit-bindings/magicleap/src/magicleap.cc index a51ef2a1b0..db13e2d06c 100644 --- a/deps/exokit-bindings/magicleap/src/magicleap.cc +++ b/deps/exokit-bindings/magicleap/src/magicleap.cc @@ -67,6 +67,8 @@ std::vector eyeRequests; MLEyeTrackingState eyeState; MLEyeTrackingStaticData eyeStaticData; +MLHandle objectTracker; + bool isPresent() { return lifecycle_status == MLResult_Ok; } @@ -1020,6 +1022,12 @@ NAN_METHOD(MLContext::Present) { info.GetReturnValue().Set(Nan::Null()); return; } + + if (MLFoundObjectTrackerCreate(&objectTracker) != MLResult_Ok) { + ML_LOG(Error, "%s: failed to create object tracker handle", application_name); + info.GetReturnValue().Set(Nan::Null()); + return; + } // Now that graphics is connected, the app is ready to go if (MLLifecycleSetReadyIndication() != MLResult_Ok) { @@ -1154,7 +1162,13 @@ NAN_METHOD(MLContext::Exit) { } if (MLEyeTrackingDestroy(eyeTracker) != MLResult_Ok) { - ML_LOG(Error, "%s: failed to create eye handle", application_name); + ML_LOG(Error, "%s: failed to destroy eye handle", application_name); + info.GetReturnValue().Set(Nan::Null()); + return; + } + + if (MLFoundObjectTrackerDestroy(objectTracker) != MLResult_Ok) { + ML_LOG(Error, "%s: failed to destroy object tracker handle", application_name); info.GetReturnValue().Set(Nan::Null()); return; }