diff --git a/data/assets/skyBrowserTargetPair.asset b/data/assets/skyBrowserTargetPair.asset index 1657e5289c..970af7c6ea 100644 --- a/data/assets/skyBrowserTargetPair.asset +++ b/data/assets/skyBrowserTargetPair.asset @@ -32,6 +32,7 @@ asset.onInitialize(function () openspace.skybrowser.addToSkyBrowserModule(targetId) openspace.skybrowser.connectBrowserTarget(browserId) openspace.skybrowser.connectBrowserTarget(targetId) + openspace.skybrowser.setSelectedBrowser(browserId) end) asset.onDeinitialize(function () diff --git a/modules/skybrowser/include/screenspaceskytarget.h b/modules/skybrowser/include/screenspaceskytarget.h index 5eba77f5a4..17446f9e88 100644 --- a/modules/skybrowser/include/screenspaceskytarget.h +++ b/modules/skybrowser/include/screenspaceskytarget.h @@ -49,6 +49,7 @@ namespace openspace { glm::dvec2 getTargetDirectionCelestial(); void unlock(); void lock(); + bool isLocked(); void animateToCoord(double deltaTime); void startAnimation(glm::dvec2 coordsEnd, float FOVEnd); bool animateFOV(float endFOV, float deltaTime); @@ -71,7 +72,7 @@ namespace openspace { ScreenSpaceSkyBrowser* _skyBrowser; glm::ivec3 _borderColor; // Locking target to a coordinate on the sky - bool isLocked; + bool _isLocked; glm::dvec2 lockedCelestialCoords; std::thread _lockTargetThread; // Animating the target diff --git a/modules/skybrowser/skybrowsermodule.cpp b/modules/skybrowser/skybrowsermodule.cpp index fe4e740e2c..4fff48375e 100644 --- a/modules/skybrowser/skybrowsermodule.cpp +++ b/modules/skybrowser/skybrowsermodule.cpp @@ -499,7 +499,7 @@ void SkyBrowserModule::addRenderable(ScreenSpaceRenderable* object) { // Sort on z coordinate, objects closer to camera are in beginning of list std::sort(renderables.begin(), renderables.end()); ScreenSpaceSkyBrowser* browser = to_browser(object); - if (browser) { + if (browser) { browsers[browser->identifier()] = browser; } } diff --git a/modules/skybrowser/skybrowsermodule_lua.inl b/modules/skybrowser/skybrowsermodule_lua.inl index 802f03d100..713ee43be2 100644 --- a/modules/skybrowser/skybrowsermodule_lua.inl +++ b/modules/skybrowser/skybrowsermodule_lua.inl @@ -410,6 +410,8 @@ namespace openspace::skybrowser::luascriptfunctions { lua_settable(L, -3); ghoul::lua::push(L, "color", colorVec); lua_settable(L, -3); + ghoul::lua::push(L, "isLocked", target->isLocked()); + lua_settable(L, -3); // Set table for the current target lua_settable(L, -3); diff --git a/modules/skybrowser/src/screenspaceskytarget.cpp b/modules/skybrowser/src/screenspaceskytarget.cpp index f992eef572..e17c3c7f34 100644 --- a/modules/skybrowser/src/screenspaceskytarget.cpp +++ b/modules/skybrowser/src/screenspaceskytarget.cpp @@ -308,28 +308,32 @@ namespace openspace { } void ScreenSpaceSkyTarget::unlock() { - isLocked = false; + _isLocked = false; if (_lockTargetThread.joinable()) { _lockTargetThread.join(); } } void ScreenSpaceSkyTarget::lock() { - if (isLocked) { + if (_isLocked) { unlock(); } - isLocked = true; + _isLocked = true; lockedCelestialCoords = getTargetDirectionCelestial(); // Start a thread to enable user interactions while locking target _lockTargetThread = std::thread([&] { - while (isLocked) { + while (_isLocked) { glm::vec3 imageCoordsScreenSpace = skybrowser::J2000SphericalToScreenSpace(lockedCelestialCoords); _cartesianPosition = imageCoordsScreenSpace; } }); } + bool ScreenSpaceSkyTarget::isLocked() { + return _isLocked; + } + glm::dvec2 ScreenSpaceSkyTarget::getTargetDirectionCelestial() { // Calculate the galactic coordinate of the target direction // with infinite radius @@ -360,7 +364,7 @@ namespace openspace { else { // Set the exact target position and lock target when it first arrives // to the position - if (!isLocked) { + if (!_isLocked) { _cartesianPosition = skybrowser::J2000CartesianToScreenSpace(_coordsToAnimateTo); lock(); }