From fd58f9508ed975730014d91e11f46f5c08dcc65c Mon Sep 17 00:00:00 2001 From: sylvass Date: Wed, 1 Dec 2021 14:24:25 -0500 Subject: [PATCH] Make renderable sky browser not need to know about ImageData --- modules/skybrowser/include/renderableskybrowser.h | 9 +-------- modules/skybrowser/skybrowsermodule.cpp | 2 +- modules/skybrowser/src/renderableskybrowser.cpp | 13 +++++-------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/modules/skybrowser/include/renderableskybrowser.h b/modules/skybrowser/include/renderableskybrowser.h index 448326d61b..f8664bf6f3 100644 --- a/modules/skybrowser/include/renderableskybrowser.h +++ b/modules/skybrowser/include/renderableskybrowser.h @@ -1,13 +1,9 @@ #ifndef __OPENSPACE_MODULE_SKYBROWSER___RENDERABLESKYBROWSER___H__ #define __OPENSPACE_MODULE_SKYBROWSER___RENDERABLESKYBROWSER___H__ -#include #include #include #include -#include -#include -#include #ifdef _MSC_VER #pragma warning (push) @@ -33,8 +29,6 @@ namespace ghoul::opengl { class Texture; } namespace openspace::documentation { struct Documentation; } -#pragma optimize("", off) - namespace openspace { class RenderableSkyBrowser : public RenderablePlane, public WwtCommunicator @@ -51,11 +45,10 @@ namespace openspace { void update(const UpdateData& data) override; // Set up initialization with wwt - void stopSyncingWwtView(); void setIdInBrowser(); // Place - void placeAt3dPosition(const ImageData& image); + void placeAt3dPosition(const glm::dvec3& positionSpeck, float verticalFov); private: diff --git a/modules/skybrowser/skybrowsermodule.cpp b/modules/skybrowser/skybrowsermodule.cpp index 5935ef7991..02e2d62e12 100644 --- a/modules/skybrowser/skybrowsermodule.cpp +++ b/modules/skybrowser/skybrowsermodule.cpp @@ -712,7 +712,7 @@ void SkyBrowserModule::place3dBrowser(const ImageData& image, const int i) // If the image has a 3D position, add it to the scene graph if (image.has3dCoords && get3dBrowser()) { get3dBrowser()->displayImage(image.imageUrl, i); - get3dBrowser()->placeAt3dPosition(image); + get3dBrowser()->placeAt3dPosition(image.position3d, image.fov); } else { LINFO("Image has no 3D coordinate!"); diff --git a/modules/skybrowser/src/renderableskybrowser.cpp b/modules/skybrowser/src/renderableskybrowser.cpp index 71e6fc21aa..88d6a4411b 100644 --- a/modules/skybrowser/src/renderableskybrowser.cpp +++ b/modules/skybrowser/src/renderableskybrowser.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -98,17 +99,13 @@ namespace openspace { RenderablePlane::update(data); } - void RenderableSkyBrowser::stopSyncingWwtView() - { - - } - void RenderableSkyBrowser::setIdInBrowser() { WwtCommunicator::setIdInBrowser(identifier()); } - void RenderableSkyBrowser::placeAt3dPosition(const ImageData& image) + void RenderableSkyBrowser::placeAt3dPosition( + const glm::dvec3& positionSpeck, float verticalFov) { std::string renderableId = dynamic_cast( this)->renderable()->identifier(); @@ -117,7 +114,7 @@ namespace openspace { std::string positionUri = "Scene." + _identifier + ".Translation.Position"; std::string rotationUri = "Scene." + _identifier + ".Rotation.Rotation"; std::string cameraAim = "NavigationHandler.OrbitalNavigator.Aim"; - glm::dvec3 position = image.position3d * distanceconstants::Parsec; + glm::dvec3 position = positionSpeck * distanceconstants::Parsec; // Calculate the size of the plane with trigonometry // Calculate in equatorial coordinate system since the FOV is from Earth // /| @@ -126,7 +123,7 @@ namespace openspace { // \| glm::dvec3 j2000 = skybrowser::galacticToEquatorial(position); double adjacent = glm::length(j2000); - double opposite = 2 * adjacent * glm::tan(glm::radians(image.fov * 0.5)); + double opposite = 2 * adjacent * glm::tan(glm::radians(verticalFov * 0.5)); // Calculate rotation to make the plane face the solar system barycenter glm::dvec3 normal = glm::normalize(-position);