Merge remote-tracking branch 'origin/master' into feature/openglstatecache

# Conflicts:
#	ext/ghoul
#	modules/digitaluniverse/rendering/renderablebillboardscloud.cpp
#	modules/digitaluniverse/rendering/renderableplanescloud.cpp
#	src/util/screenlog.cpp
This commit is contained in:
Alexander Bock
2020-09-04 14:02:17 +02:00
199 changed files with 2985 additions and 1664 deletions
@@ -31,6 +31,7 @@
#include <openspace/util/touch.h>
#include <openspace/util/versionchecker.h>
#include <ghoul/glm.h>
#include <future>
#include <memory>
#include <string>
#include <vector>
@@ -127,6 +128,8 @@ private:
//grabs json from each module to pass to the documentation engine.
std::string _documentationJson;
std::future<void> _writeDocumentationTask;
ShutdownInformation _shutdown;
// The first frame might take some more time in the update loop, so we need to know to
+56 -113
View File
@@ -40,18 +40,18 @@ enum class Type : uint32_t {
};
struct CameraKeyframe {
CameraKeyframe() {}
CameraKeyframe(const std::vector<char> &buffer) {
CameraKeyframe() = default;
CameraKeyframe(const std::vector<char>& buffer) {
deserialize(buffer);
}
glm::dvec3 _position = glm::dvec3(0.0);
glm::dquat _rotation = glm::dquat(1.0, 0.0, 0.0, 0.0);
bool _followNodeRotation;
bool _followNodeRotation = false;
std::string _focusNode;
float _scale;
float _scale = 0.f;
double _timestamp;
double _timestamp = 0.0;
void serialize(std::vector<char> &buffer) const {
// Add position
@@ -104,28 +104,28 @@ struct CameraKeyframe {
);
};
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0) {
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
int size = 0;
// Position
size = sizeof(_position);
memcpy(&_position, buffer.data() + offset, size);
std::memcpy(&_position, buffer.data() + offset, size);
offset += size;
// Orientation
size = sizeof(_rotation);
memcpy(&_rotation, buffer.data() + offset, size);
std::memcpy(&_rotation, buffer.data() + offset, size);
offset += size;
// Follow focus node rotation?
size = sizeof(_followNodeRotation);
memcpy(&_followNodeRotation, buffer.data() + offset, size);
std::memcpy(&_followNodeRotation, buffer.data() + offset, size);
offset += size;
// Focus node
int nodeNameLength;
size = sizeof(int);
memcpy(&nodeNameLength, buffer.data() + offset, size);
std::memcpy(&nodeNameLength, buffer.data() + offset, size);
offset += size;
size = nodeNameLength;
_focusNode = std::string(buffer.data() + offset, buffer.data() + offset + size);
@@ -133,29 +133,20 @@ struct CameraKeyframe {
// Scale
size = sizeof(_scale);
memcpy(&_scale, buffer.data() + offset, size);
std::memcpy(&_scale, buffer.data() + offset, size);
offset += size;
// Timestamp
size = sizeof(_timestamp);
memcpy(&_timestamp, buffer.data() + offset, size);
std::memcpy(&_timestamp, buffer.data() + offset, size);
offset += size;
return offset;
};
void write(std::ostream& out) const {
// Write position
out.write(
reinterpret_cast<const char*>(&_position),
sizeof(_position)
);
// Write orientation
out.write(
reinterpret_cast<const char*>(&_rotation),
sizeof(_rotation)
);
out.write(reinterpret_cast<const char*>(&_position), sizeof(_position));
out.write(reinterpret_cast<const char*>(&_rotation), sizeof(_rotation));
// Write follow focus node rotation?
out.write(
@@ -166,88 +157,58 @@ struct CameraKeyframe {
int nodeNameLength = static_cast<int>(_focusNode.size());
// Write focus node
out.write(
reinterpret_cast<const char*>(&nodeNameLength),
sizeof(nodeNameLength)
);
out.write(
_focusNode.c_str(),
_focusNode.size()
);
out.write(reinterpret_cast<const char*>(&nodeNameLength), sizeof(nodeNameLength));
out.write(_focusNode.c_str(), _focusNode.size());
//Write scale
out.write(
reinterpret_cast<const char*>(&_scale),
sizeof(_scale)
);
// Write scale
out.write(reinterpret_cast<const char*>(&_scale), sizeof(_scale));
// Write timestamp
out.write(
reinterpret_cast<const char*>(&_timestamp),
sizeof(_timestamp)
);
out.write(reinterpret_cast<const char*>(&_timestamp), sizeof(_timestamp));
};
void read(std::istream* in) {
// Read position
in->read(
reinterpret_cast<char*>(&_position),
sizeof(_position)
);
in->read(reinterpret_cast<char*>(&_position), sizeof(_position));
// Read orientation
in->read(
reinterpret_cast<char*>(&_rotation),
sizeof(_rotation)
);
in->read(reinterpret_cast<char*>(&_rotation), sizeof(_rotation));
// Read follow focus node rotation
unsigned char b;
in->read(
reinterpret_cast<char*>(&b),
sizeof(unsigned char)
);
in->read(reinterpret_cast<char*>(&b), sizeof(unsigned char));
_followNodeRotation = (b == 1);
// Read focus node
int nodeNameLength = static_cast<int>(_focusNode.size());
in->read(
reinterpret_cast<char*>(&nodeNameLength),
sizeof(nodeNameLength)
);
std::vector<char> temp(nodeNameLength + 1);
in->read(reinterpret_cast<char*>(&nodeNameLength), sizeof(nodeNameLength));
std::vector<char> temp(static_cast<size_t>(nodeNameLength) + 1);
in->read(temp.data(), nodeNameLength);
temp[nodeNameLength] = '\0';
_focusNode = temp.data();
// Read scale
in->read(
reinterpret_cast<char*>(&_scale),
sizeof(_scale)
);
in->read(reinterpret_cast<char*>(&_scale), sizeof(_scale));
// Read timestamp
in->read(
reinterpret_cast<char*>(&_timestamp),
sizeof(_timestamp)
);
in->read(reinterpret_cast<char*>(&_timestamp), sizeof(_timestamp));
};
};
struct TimeKeyframe {
TimeKeyframe() {}
TimeKeyframe(const std::vector<char> &buffer) {
TimeKeyframe() = default;
TimeKeyframe(const std::vector<char>& buffer) {
deserialize(buffer);
}
double _time;
double _dt;
bool _paused;
bool _requiresTimeJump;
double _timestamp;
double _time = 0.0;
double _dt = 0.0;
bool _paused = false;
bool _requiresTimeJump = false;
double _timestamp = 0.0;
void serialize(std::vector<char> &buffer) const {
void serialize(std::vector<char>& buffer) const {
buffer.insert(
buffer.end(),
reinterpret_cast<const char*>(this),
@@ -255,37 +216,31 @@ struct TimeKeyframe {
);
};
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0){
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
*this = *reinterpret_cast<const TimeKeyframe*>(buffer.data() + offset);
offset += sizeof(TimeKeyframe);
return offset;
};
void write(std::ostream* out) const {
out->write(
reinterpret_cast<const char*>(this),
sizeof(TimeKeyframe)
);
out->write(reinterpret_cast<const char*>(this), sizeof(TimeKeyframe));
};
void read(std::istream* in) {
in->read(
reinterpret_cast<char*>(this),
sizeof(TimeKeyframe)
);
in->read(reinterpret_cast<char*>(this), sizeof(TimeKeyframe));
};
};
struct TimeTimeline {
TimeTimeline() {}
TimeTimeline(const std::vector<char> &buffer) {
TimeTimeline() = default;
TimeTimeline(const std::vector<char>& buffer) {
deserialize(buffer);
}
bool _clear = true;
std::vector<TimeKeyframe> _keyframes;
void serialize(std::vector<char> &buffer) const {
void serialize(std::vector<char>& buffer) const {
buffer.insert(
buffer.end(),
reinterpret_cast<const char*>(&_clear),
@@ -298,77 +253,65 @@ struct TimeTimeline {
reinterpret_cast<const char*>(&nKeyframes),
reinterpret_cast<const char*>(&nKeyframes) + sizeof(int64_t)
);
for (const auto& k : _keyframes) {
for (const TimeKeyframe& k : _keyframes) {
k.serialize(buffer);
}
};
size_t deserialize(const std::vector<char> &buffer, size_t offset = 0) {
size_t deserialize(const std::vector<char>& buffer, size_t offset = 0) {
int size = 0;
size = sizeof(_clear);
memcpy(&_clear, buffer.data() + offset, size);
std::memcpy(&_clear, buffer.data() + offset, size);
offset += size;
int64_t nKeyframes = _keyframes.size();
size = sizeof(nKeyframes);
memcpy(&nKeyframes, buffer.data() + offset, size);
std::memcpy(&nKeyframes, buffer.data() + offset, size);
offset += size;
_keyframes.resize(nKeyframes);
for (auto& k : _keyframes) {
for (TimeKeyframe& k : _keyframes) {
offset = k.deserialize(buffer, offset);
}
return offset;
};
void write(std::ostream* out) const {
out->write(
reinterpret_cast<const char*>(&_clear),
sizeof(bool)
);
out->write(reinterpret_cast<const char*>(&_clear), sizeof(bool));
int64_t nKeyframes = _keyframes.size();
out->write(
reinterpret_cast<const char*>(&nKeyframes),
sizeof(int64_t)
);
for (const auto& k : _keyframes) {
out->write(reinterpret_cast<const char*>(&nKeyframes), sizeof(int64_t));
for (const TimeKeyframe& k : _keyframes) {
k.write(out);
}
};
void read(std::istream* in) {
in->read(
reinterpret_cast<char*>(&_clear),
sizeof(bool)
);
in->read(reinterpret_cast<char*>(&_clear), sizeof(bool));
int64_t nKeyframes = _keyframes.size();
in->read(
reinterpret_cast<char*>(&nKeyframes),
sizeof(int64_t)
);
for (auto& k : _keyframes) {
in->read(reinterpret_cast<char*>(&nKeyframes), sizeof(int64_t));
for (TimeKeyframe& k : _keyframes) {
k.read(in);
}
};
};
struct ScriptMessage {
ScriptMessage() {}
ScriptMessage(const std::vector<char> &buffer) {
ScriptMessage() = default;
ScriptMessage(const std::vector<char>& buffer) {
deserialize(buffer);
}
std::string _script;
double _timestamp;
double _timestamp = 0.0;
void serialize(std::vector<char> &buffer) const {
void serialize(std::vector<char>& buffer) const {
buffer.insert(buffer.end(), _script.begin(), _script.end());
};
void deserialize(const std::vector<char> &buffer) {
void deserialize(const std::vector<char>& buffer) {
_script.assign(buffer.begin(), buffer.end());
};
+1 -1
View File
@@ -291,7 +291,7 @@ public:
*/
void removeTag(const std::string& tag);
//Generate JSON for documentation
// Generate JSON for documentation
std::string generateJson() const override;
+4 -1
View File
@@ -36,7 +36,7 @@ namespace ghoul { class Dictionary; }
namespace ghoul::opengl {
class ProgramObject;
class Texture;
}
} // namespace ghoul::opengl
namespace openspace {
@@ -72,6 +72,7 @@ public:
virtual bool isReady() const = 0;
bool isEnabled() const;
bool shouldUpdateIfDisabled() const;
void setBoundingSphere(float boundingSphere);
float boundingSphere() const;
@@ -99,6 +100,8 @@ protected:
properties::FloatProperty _boundingSphere;
properties::StringProperty _renderableType;
bool _shouldUpdateIfDisabled = false;
void setRenderBinFromOpacity();
void registerUpdateRenderBinFromOpacity();
@@ -250,6 +250,8 @@ private:
glm::ivec4 zoom = glm::ivec4(0);
glm::ivec4 roll = glm::ivec4(0);
} _cameraButtonLocations;
std::string _versionString;
};
} // namespace openspace
-3
View File
@@ -45,7 +45,6 @@ int onDeinitialize(lua_State* state);
int onInitializeDependency(lua_State* state);
int onDeinitializeDependency(lua_State* state);
int require(lua_State* state);
int request(lua_State* state);
int exists(lua_State* state);
int localResource(lua_State* state);
int syncedResource(lua_State* state);
@@ -164,7 +163,6 @@ public:
void assetUnrequested(Asset* parent, std::shared_ptr<Asset> child);
private:
std::shared_ptr<Asset> request(const std::string& identifier);
void unrequest(const std::string& identifier);
void setUpAssetLuaTable(Asset* asset);
@@ -194,7 +192,6 @@ private:
friend int assetloader::onInitializeDependency(lua_State* state);
friend int assetloader::onDeinitializeDependency(lua_State* state);
friend int assetloader::require(lua_State* state);
friend int assetloader::request(lua_State* state);
friend int assetloader::exists(lua_State* state);
friend int assetloader::localResource(lua_State* state);
friend int assetloader::syncedResource(lua_State* state);
+2 -1
View File
@@ -121,7 +121,7 @@ public:
* and all of the property & asset changes that were made since startup.
*/
void saveCurrentSettingsToProfile(const properties::PropertyOwner& rootOwner,
const std::string& currentTime,
std::string currentTime,
interaction::NavigationHandler::NavigationState navState);
/// If the value passed to this function is 'true', the addAsset and removeAsset
@@ -151,6 +151,7 @@ private:
std::vector<Property> properties;
std::vector<Keybinding> keybindings;
std::optional<Time> time;
std::vector<double> deltaTimes;
std::optional<CameraType> camera;
std::vector<std::string> markNodes;
std::vector<std::string> additionalScripts;
-2
View File
@@ -120,7 +120,6 @@ public:
glm::dvec3 worldPosition() const;
const glm::dmat3& worldRotationMatrix() const;
glm::dmat4 modelTransform() const;
glm::dmat4 inverseModelTransform() const;
glm::dvec3 worldScale() const;
bool isTimeFrameActive(const Time& time) const;
@@ -176,7 +175,6 @@ private:
glm::dvec3 _worldScaleCached = glm::dvec3(1.0);
glm::dmat4 _modelTransformCached = glm::dmat4(1.0);
glm::dmat4 _inverseModelTransformCached = glm::dmat4(1.0);
properties::FloatProperty _boundingSphere;
properties::BoolProperty _computeScreenSpaceValues;
+5 -1
View File
@@ -26,13 +26,17 @@
#define __OPENSPACE_CORE___MEMORYMANAGER___H__
#include <ghoul/misc/memorypool.h>
#include <memory_resource>
namespace openspace {
class MemoryManager {
public:
ghoul::MemoryPool<8 * 1024 * 1024, false> PersistentMemory;
ghoul::MemoryPool<10 * 1024, false> TemporaryMemory;
// 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
+34 -3
View File
@@ -26,6 +26,7 @@
#define __OPENSPACE_CORE___SPICEMANAGER___H__
#include <ghoul/glm.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/boolean.h>
#include <ghoul/misc/exception.h>
#include <array>
@@ -33,11 +34,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 +467,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 +475,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
+15 -6
View File
@@ -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>.
+19
View File
@@ -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 removeTimeJumpCallback(CallbackHandle handle);
void removeTimelineChangeCallback(CallbackHandle handle);
@@ -126,6 +141,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;
@@ -142,6 +160,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;