mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-02 00:44:43 -05:00
Cleanup
This commit is contained in:
@@ -37,8 +37,8 @@ class ImageData;
|
||||
class Pair {
|
||||
public:
|
||||
|
||||
constexpr static const float AcceptableDiff = 0.01f;
|
||||
constexpr static const double epsilon = std::numeric_limits<double>::epsilon();
|
||||
constexpr static const float FadeThreshold = 0.01f;
|
||||
constexpr static const double AnimationThreshold = 0.0001f;;
|
||||
|
||||
Pair(ScreenSpaceSkyBrowser* browser, ScreenSpaceSkyTarget* target);
|
||||
Pair(Pair const&) = default;
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
void setImageOrder(int i, int order);
|
||||
void removeHighlight(glm::ivec3 color);
|
||||
void highlight(glm::ivec3 color);
|
||||
void enable();
|
||||
void setEnabled(bool enable);
|
||||
void disable();
|
||||
|
||||
void startAnimation(glm::dvec3 coordsEnd, float fovEnd, bool shouldLockAfter = true);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace openspace {
|
||||
|
||||
// Target directions
|
||||
glm::dvec3 directionGalactic() const;
|
||||
glm::dvec3 directionEquatorial() const;
|
||||
glm::dvec3 equatorialAim() const;
|
||||
|
||||
// Locking functionality
|
||||
bool isLocked() const;
|
||||
|
||||
@@ -59,7 +59,7 @@ public:
|
||||
float verticalFov() const;
|
||||
glm::dvec2 fieldsOfView();
|
||||
bool hasLoadedImages() const;
|
||||
glm::dvec3 equatorialAimCartesian() const;
|
||||
glm::dvec3 equatorialAim() const;
|
||||
|
||||
// Setters
|
||||
void setHasLoadedImages(bool isLoaded);
|
||||
|
||||
@@ -801,7 +801,7 @@ void SkyBrowserModule::incrementallyFadeBrowserTargets(Transparency goal, float
|
||||
pair->incrementallyFade(transparency, _fadingTime, deltaTime);
|
||||
}
|
||||
else if (isPairFinished && goal == Transparency::Transparent) {
|
||||
pair->disable();
|
||||
pair->setEnabled(false);
|
||||
}
|
||||
isAllFinished &= isPairFinished;
|
||||
}
|
||||
|
||||
@@ -195,16 +195,16 @@ int getListOfImages(lua_State* L) {
|
||||
std::string directory = absPath("${MODULE_SKYBROWSER}/WWTimagedata/").string();
|
||||
|
||||
// 3D images
|
||||
std::string http = "${BASE}/sync/http/";
|
||||
std::string http = "${SYNC}/http/";
|
||||
std::string globular = "digitaluniverse_globularclusters_speck/2/gc.speck";
|
||||
std::string open = "digitaluniverse_openclusters_speck/2/oc.speck";
|
||||
// Load speck files for 3D positions
|
||||
std::filesystem::path globularClusters = absPath(http + globular);
|
||||
std::filesystem::path openClusters = absPath(http + open);
|
||||
std::vector<std::filesystem::path> specks; // = {
|
||||
//openClusters,
|
||||
//globularClusters
|
||||
//};
|
||||
std::vector<std::filesystem::path> specks = {
|
||||
openClusters,
|
||||
globularClusters
|
||||
};
|
||||
|
||||
module->loadImages(root, directory, specks);
|
||||
}
|
||||
|
||||
@@ -43,13 +43,16 @@ namespace openspace {
|
||||
{
|
||||
ghoul_assert(browser != nullptr, "Sky browser is null pointer!");
|
||||
ghoul_assert(target != nullptr, "Sky target is null pointer!");
|
||||
|
||||
|
||||
// Set browser callback functions
|
||||
// Set callback functions so that the target and the browser update each other
|
||||
_browser->setCallbackEquatorialAim(
|
||||
[&](const glm::dvec3& equatorialAim, bool) {
|
||||
double diff = glm::length(equatorialAim - _target->directionEquatorial());
|
||||
if ( diff > epsilon) {
|
||||
_target->startAnimation(equatorialAim, false);
|
||||
double diff = glm::length(equatorialAim - _target->equatorialAim());
|
||||
if ( diff > AnimationThreshold) {
|
||||
_target->setCartesianPosition(
|
||||
skybrowser::equatorialToScreenSpace3d(equatorialAim)
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -74,6 +77,8 @@ namespace openspace {
|
||||
_target->setEnabled(enabled);
|
||||
}
|
||||
);
|
||||
|
||||
// Set target callback functions
|
||||
_target->setCallbackEnabled(
|
||||
[&](bool enabled) {
|
||||
_browser->setEnabled(enabled);
|
||||
@@ -82,9 +87,9 @@ namespace openspace {
|
||||
_target->setCallbackPosition(
|
||||
[&](glm::vec3 localCameraPosition) {
|
||||
double diff = glm::length(
|
||||
_browser->equatorialAimCartesian() - _target->directionEquatorial()
|
||||
_browser->equatorialAim() - _target->equatorialAim()
|
||||
);
|
||||
if (diff > epsilon) {
|
||||
if (diff > AnimationThreshold) {
|
||||
_browser->setEquatorialAim(
|
||||
skybrowser::localCameraToEquatorial(localCameraPosition)
|
||||
);
|
||||
@@ -130,13 +135,13 @@ namespace openspace {
|
||||
// Is fading finished?
|
||||
float targetDiff = abs(_target->opacity() - goalState);
|
||||
|
||||
return targetDiff < AcceptableDiff;
|
||||
return targetDiff < FadeThreshold;
|
||||
}
|
||||
|
||||
bool Pair::isBrowserFadeFinished(float goalState)
|
||||
{
|
||||
float browserDiff = abs(_browser->opacity() - goalState);
|
||||
return browserDiff < AcceptableDiff;
|
||||
return browserDiff < FadeThreshold;
|
||||
}
|
||||
|
||||
bool Pair::isCoordOnPair(glm::vec2 mousePosition)
|
||||
@@ -153,16 +158,10 @@ namespace openspace {
|
||||
return onBrowser || onTarget;
|
||||
}
|
||||
|
||||
void Pair::enable()
|
||||
void Pair::setEnabled(bool enable)
|
||||
{
|
||||
_browser->property("Enabled")->set(true);
|
||||
_target->property("Enabled")->set(true);
|
||||
}
|
||||
|
||||
void Pair::disable()
|
||||
{
|
||||
_browser->property("Enabled")->set(false);
|
||||
_target->property("Enabled")->set(false);
|
||||
_browser->setEnabled(enable);
|
||||
_target->setEnabled(enable);
|
||||
}
|
||||
|
||||
bool Pair::isEnabled()
|
||||
@@ -190,7 +189,7 @@ namespace openspace {
|
||||
|
||||
glm::dvec3 Pair::targetDirectionEquatorial()
|
||||
{
|
||||
return _target->directionEquatorial();
|
||||
return _target->equatorialAim();
|
||||
}
|
||||
|
||||
glm::dvec3 Pair::targetDirectionGalactic()
|
||||
@@ -233,7 +232,7 @@ namespace openspace {
|
||||
|
||||
// Animate the target to the image coordinate position
|
||||
unlock();
|
||||
startAnimation(image.equatorialCartesian, image.fov);
|
||||
startAnimation(image.equatorialCartesian, image.fov, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,9 +276,9 @@ namespace openspace {
|
||||
}
|
||||
}
|
||||
|
||||
void Pair::startAnimation(glm::dvec3 coordsEnd, float fovEnd, bool shouldLockAfter)
|
||||
void Pair::startAnimation(glm::dvec3 equatorialCoords, float fovEnd, bool shouldLockAfter)
|
||||
{
|
||||
_target->startAnimation(coordsEnd, shouldLockAfter);
|
||||
_target->startAnimation(equatorialCoords, shouldLockAfter);
|
||||
_browser->startFovAnimation(fovEnd);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace openspace {
|
||||
: ScreenSpaceRenderable(dictionary)
|
||||
, _showCrosshairThreshold(CrosshairThresholdInfo, 2.0f, 0.1f, 70.f)
|
||||
, _showRectangleThreshold(RectangleThresholdInfo, 0.6f, 0.1f, 70.f)
|
||||
, _stopAnimationThreshold(AnimationThresholdInfo, 0.0005, 0.0, 1.0)
|
||||
, _stopAnimationThreshold(AnimationThresholdInfo, 0.0005, 0.0, 0.005)
|
||||
, _animationSpeed(AnimationSpeedInfo, 5.0, 0.1, 10.0)
|
||||
, _color(220, 220, 220)
|
||||
{
|
||||
@@ -250,10 +250,10 @@ namespace openspace {
|
||||
return _isAnimated;
|
||||
}
|
||||
|
||||
void ScreenSpaceSkyTarget::startAnimation(glm::dvec3 end, bool shouldLockAfter)
|
||||
void ScreenSpaceSkyTarget::startAnimation(glm::dvec3 equatorialCoordsEnd, bool shouldLockAfter)
|
||||
{
|
||||
_animationStart = glm::normalize(directionEquatorial());
|
||||
_animationEnd = glm::normalize(end);
|
||||
_animationStart = glm::normalize(equatorialAim());
|
||||
_animationEnd = glm::normalize(equatorialCoordsEnd);
|
||||
_shouldLockAfterAnimation = shouldLockAfter;
|
||||
_isAnimated = true;
|
||||
_isLocked = false;
|
||||
@@ -282,21 +282,18 @@ namespace openspace {
|
||||
_cartesianPosition = skybrowser::equatorialToScreenSpace3d(newDir);
|
||||
|
||||
// Update position
|
||||
_animationStart = glm::normalize(newDir);
|
||||
_animationStart = glm::normalize(equatorialAim());
|
||||
}
|
||||
else {
|
||||
// Set the exact target position
|
||||
_cartesianPosition = skybrowser::equatorialToScreenSpace3d(_animationEnd);
|
||||
_cartesianPosition = glm::vec3(skybrowser::equatorialToScreenSpace3d(_animationEnd));
|
||||
_isAnimated = false;
|
||||
|
||||
// Lock target when it first arrives to the position
|
||||
if (!_isLocked && _shouldLockAfterAnimation) {
|
||||
_isLocked = true;
|
||||
}
|
||||
setLock(_shouldLockAfterAnimation);
|
||||
}
|
||||
}
|
||||
|
||||
glm::dvec3 ScreenSpaceSkyTarget::directionEquatorial() const {
|
||||
glm::dvec3 ScreenSpaceSkyTarget::equatorialAim() const {
|
||||
// Calculate the galactic coordinate of the target direction
|
||||
// projected onto the celestial sphere
|
||||
return skybrowser::localCameraToEquatorial(_cartesianPosition.value());
|
||||
@@ -324,7 +321,7 @@ namespace openspace {
|
||||
{
|
||||
_isLocked = isLocked;
|
||||
if (_isLocked) {
|
||||
_lockedCoordinates = directionEquatorial();
|
||||
_lockedCoordinates = equatorialAim();
|
||||
}
|
||||
}
|
||||
void ScreenSpaceSkyTarget::setCallbackEnabled(std::function<void(bool)> function)
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace openspace {
|
||||
return _hasLoadedImages;
|
||||
}
|
||||
|
||||
glm::dvec3 WwtCommunicator::equatorialAimCartesian() const
|
||||
glm::dvec3 WwtCommunicator::equatorialAim() const
|
||||
{
|
||||
return skybrowser::sphericalToCartesian(_equatorialAim);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace {
|
||||
constexpr const char* _loggerCat = "WWTDataHandler";
|
||||
constexpr const char* _loggerCat = "WwtDataHandler";
|
||||
} //namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
Reference in New Issue
Block a user