mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-27 22:40:41 -05:00
Merge branch 'master' into feature/session-recording-improvements
# Conflicts: # include/openspace/network/messagestructures.h # src/interaction/sessionrecording.cpp
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
|
||||
namespace openspace::distanceconstants {
|
||||
constexpr double EarthRadius = 6371;
|
||||
constexpr double JupiterRadius = 7.1492E7;
|
||||
constexpr double SolarRadius = 6.95700E8;
|
||||
constexpr double LightYear = 9.4607304725808E15;
|
||||
constexpr double LightMonth = LightYear / 12;
|
||||
constexpr double LightDay = LightYear / 365;
|
||||
|
||||
@@ -28,13 +28,9 @@
|
||||
#include <openspace/documentation/documentationgenerator.h>
|
||||
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <ghoul/misc/templatefactory.h>
|
||||
#include <memory>
|
||||
|
||||
namespace ghoul {
|
||||
template <class T> class TemplateFactory;
|
||||
class TemplateFactoryBase;
|
||||
} // namespace ghoul
|
||||
|
||||
namespace openspace {
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___MEMORYMANAGER___H__
|
||||
#define __OPENSPACE_CORE___MEMORYMANAGER___H__
|
||||
|
||||
#include <ghoul/misc/memorypool.h>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
class MemoryManager {
|
||||
public:
|
||||
ghoul::MemoryPool<8 * 1024 * 1024, false> PersistentMemory;
|
||||
|
||||
// This should be replaced with a std::pmr::memory_resource wrapper around our own
|
||||
// Memory pool so that we can get a high-water mark out of it
|
||||
ghoul::MemoryPool<100 * 4096, false> TemporaryMemory;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___MEMORYMANAGER___H__
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
@@ -91,8 +92,8 @@ public:
|
||||
* \param category The category of the log message
|
||||
* \param message The actual log message that was transmitted
|
||||
*/
|
||||
void log(ghoul::logging::LogLevel level, const std::string& category,
|
||||
const std::string& message) override;
|
||||
void log(ghoul::logging::LogLevel level, std::string_view category,
|
||||
std::string_view message) override;
|
||||
|
||||
/**
|
||||
* This method removes all the stored LogEntry%s that have expired, calculated by
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#ifndef __OPENSPACE_CORE___SPICEMANAGER___H__
|
||||
#define __OPENSPACE_CORE___SPICEMANAGER___H__
|
||||
|
||||
#include <ghoul/fmt.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/misc/assert.h>
|
||||
#include <ghoul/misc/boolean.h>
|
||||
#include <ghoul/misc/exception.h>
|
||||
#include <array>
|
||||
@@ -33,11 +35,15 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include "SpiceUsr.h"
|
||||
#include "SpiceZpr.h"
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace scripting { struct LuaLibrary; }
|
||||
|
||||
void throwSpiceError(const std::string& errorMessage);
|
||||
|
||||
class SpiceManager {
|
||||
public:
|
||||
BooleanType(UseException);
|
||||
@@ -462,6 +468,7 @@ public:
|
||||
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html
|
||||
*/
|
||||
double ephemerisTimeFromDate(const std::string& timeString) const;
|
||||
double ephemerisTimeFromDate(const char* timeString) const;
|
||||
|
||||
/**
|
||||
* Converts the passed \p ephemerisTime into a human-readable date string with a
|
||||
@@ -469,15 +476,40 @@ public:
|
||||
*
|
||||
* \param ephemerisTime The ephemeris time, that is the number of TDB seconds past the
|
||||
* J2000 epoch
|
||||
* \param formatString The format string describing the output format
|
||||
* \param format The format string describing the output format
|
||||
* \return The destination for the converted date.
|
||||
*
|
||||
* \pre \p formatString must not be empty
|
||||
* \pre \p format must not be empty
|
||||
*
|
||||
* \sa http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html
|
||||
*/
|
||||
template <int N = 31>
|
||||
std::string dateFromEphemerisTime(double ephemerisTime,
|
||||
const std::string& formatString = "YYYY MON DDTHR:MN:SC.### ::RND") const;
|
||||
const char (&format)[N] = "YYYY MON DDTHR:MN:SC.### ::RND") const
|
||||
{
|
||||
static_assert(N != 0, "Format must not be empty");
|
||||
|
||||
std::string res;
|
||||
res.resize(N);
|
||||
dateFromEphemerisTime(ephemerisTime, res.data(), N, format);
|
||||
return res;
|
||||
}
|
||||
|
||||
template <int N>
|
||||
void dateFromEphemerisTime(double ephemerisTime, char* outBuf, int bufferSize,
|
||||
const char (&format)[N] = "YYYY MON DDTHR:MN:SC.### ::RND") const
|
||||
{
|
||||
static_assert(N != 0, "Format must not be empty");
|
||||
ghoul_assert(N >= bufferSize - 1, "Buffer size too small");
|
||||
|
||||
timout_c(ephemerisTime, format, bufferSize, outBuf);
|
||||
if (failed_c()) {
|
||||
throwSpiceError(fmt::format(
|
||||
"Error converting ephemeris time '{}' to date with format '{}'",
|
||||
ephemerisTime, format
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the \p position of a \p target body relative to an \p observer in a
|
||||
|
||||
@@ -64,8 +64,10 @@ public:
|
||||
* \pre \p timeString must not be empty
|
||||
*/
|
||||
static double convertTime(const std::string& time);
|
||||
static double convertTime(const char* time);
|
||||
|
||||
explicit Time(double secondsJ2000 = -1);
|
||||
explicit Time(const std::string& time);
|
||||
Time(const Time& other) = default;
|
||||
|
||||
/**
|
||||
@@ -98,7 +100,8 @@ public:
|
||||
* (http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/str2et_c.html)
|
||||
* \param time The time to be set as a date string
|
||||
*/
|
||||
void setTime(std::string time);
|
||||
void setTime(const std::string& time);
|
||||
void setTime(const char* time);
|
||||
|
||||
/**
|
||||
* Returns the current time as the number of seconds past the J2000 epoch. If the
|
||||
@@ -112,13 +115,19 @@ public:
|
||||
* thus also compliant with the Spice library.
|
||||
* \return The current time as a formatted date string
|
||||
*/
|
||||
std::string UTC() const;
|
||||
std::string_view UTC() const;
|
||||
|
||||
/**
|
||||
* Returns the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ
|
||||
* \return The current time as a ISO 8601 formatted string
|
||||
*/
|
||||
std::string ISO8601() const;
|
||||
* Returns the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ
|
||||
* \return The current time as a ISO 8601 formatted string
|
||||
*/
|
||||
std::string_view ISO8601() const;
|
||||
|
||||
/**
|
||||
* Creates the current time as a ISO 8601 formatted, i.e YYYY-MM-DDThh:mm:ssZ into the
|
||||
* provided Buffer. The buffer needs to have space for 25 characters.
|
||||
*/
|
||||
void ISO8601(char* buffer) const;
|
||||
|
||||
/**
|
||||
* Advances the simulation time using the deltaTime() and the <code>tickTime</code>.
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/util/time.h>
|
||||
#include <openspace/util/timeline.h>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -68,6 +69,7 @@ public:
|
||||
void setTimeNextFrame(Time t);
|
||||
void setDeltaTime(double deltaTime);
|
||||
void setPause(bool pause);
|
||||
void setDeltaTimeSteps(const std::vector<double> deltaTimes);
|
||||
|
||||
/**
|
||||
* Returns the delta time, unaffected by pause
|
||||
@@ -80,6 +82,8 @@ public:
|
||||
double deltaTime() const;
|
||||
bool isPaused() const;
|
||||
|
||||
std::vector<double> deltaTimeSteps() const;
|
||||
|
||||
float defaultTimeInterpolationDuration() const;
|
||||
float defaultDeltaTimeInterpolationDuration() const;
|
||||
float defaultPauseInterpolationDuration() const;
|
||||
@@ -90,6 +94,15 @@ public:
|
||||
void interpolateDeltaTime(double targetDeltaTime, double durationSeconds);
|
||||
void interpolatePause(bool pause, double durationSeconds);
|
||||
|
||||
std::optional<double> nextDeltaTimeStep();
|
||||
std::optional<double> previousDeltaTimeStep();
|
||||
bool hasNextDeltaTimeStep() const;
|
||||
bool hasPreviousDeltaTimeStep() const;
|
||||
void setNextDeltaTimeStep();
|
||||
void setPreviousDeltaTimeStep();
|
||||
void interpolateNextDeltaTimeStep(double durationSeconds);
|
||||
void interpolatePreviousDeltaTimeStep(double durationSeconds);
|
||||
|
||||
void addKeyframe(double timestamp, TimeKeyframeData kf);
|
||||
void removeKeyframesBefore(double timestamp, bool inclusive = false);
|
||||
void removeKeyframesAfter(double timestamp, bool inclusive = false);
|
||||
@@ -99,11 +112,13 @@ public:
|
||||
|
||||
CallbackHandle addTimeChangeCallback(TimeChangeCallback cb);
|
||||
CallbackHandle addDeltaTimeChangeCallback(TimeChangeCallback cb);
|
||||
CallbackHandle addDeltaTimeStepsChangeCallback(TimeChangeCallback cb);
|
||||
CallbackHandle addTimeJumpCallback(TimeChangeCallback cb);
|
||||
CallbackHandle addTimelineChangeCallback(TimeChangeCallback cb);
|
||||
|
||||
void removeTimeChangeCallback(CallbackHandle handle);
|
||||
void removeDeltaTimeChangeCallback(CallbackHandle handle);
|
||||
void removeDeltaTimeStepsChangeCallback(CallbackHandle handle);
|
||||
void triggerPlaybackStart();
|
||||
void stopPlayback();
|
||||
void removeTimeJumpCallback(CallbackHandle handle);
|
||||
@@ -127,6 +142,9 @@ private:
|
||||
double _lastDeltaTime = 0.0;
|
||||
double _lastTargetDeltaTime = 0.0;
|
||||
|
||||
std::vector<double> _deltaTimeSteps;
|
||||
bool _deltaTimeStepsChanged = false;
|
||||
|
||||
properties::FloatProperty _defaultTimeInterpolationDuration;
|
||||
properties::FloatProperty _defaultDeltaTimeInterpolationDuration;
|
||||
properties::FloatProperty _defaultPauseInterpolationDuration;
|
||||
@@ -143,6 +161,7 @@ private:
|
||||
|
||||
std::vector<std::pair<CallbackHandle, TimeChangeCallback>> _timeChangeCallbacks;
|
||||
std::vector<std::pair<CallbackHandle, TimeChangeCallback>> _deltaTimeChangeCallbacks;
|
||||
std::vector<std::pair<CallbackHandle, TimeChangeCallback>> _deltaTimeStepsChangeCallbacks;
|
||||
|
||||
std::vector<std::pair<CallbackHandle, TimeChangeCallback>> _timeJumpCallbacks;
|
||||
std::vector<std::pair<CallbackHandle, TimeChangeCallback>> _timelineChangeCallbacks;
|
||||
|
||||
@@ -45,13 +45,11 @@ struct UpdateData {
|
||||
TransformData modelTransform;
|
||||
const Time time;
|
||||
const Time previousFrameTime;
|
||||
const bool doPerformanceMeasurement;
|
||||
};
|
||||
|
||||
struct RenderData {
|
||||
const Camera& camera;
|
||||
const Time time;
|
||||
bool doPerformanceMeasurement = false;
|
||||
int renderBinMask = -1;
|
||||
TransformData modelTransform;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user