TimeFrame specification and status (#3553)

* Makes Translation/Scale/Rotation all able to have a TimeFrame, not just the SpiceRotation.  Add read-only BoolProperty to the TimeFrame that indicates whether the current time is a in the timeframe

---------

Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
Alexander Bock
2025-03-10 13:53:32 +01:00
committed by GitHub
parent 842b63f6ea
commit 7328a94fb1
47 changed files with 440 additions and 206 deletions
+20 -1
View File
@@ -27,6 +27,7 @@
#include <openspace/properties/propertyowner.h>
#include <openspace/scene/timeframe.h>
#include <ghoul/glm.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
@@ -38,12 +39,29 @@ struct UpdateData;
namespace documentation { struct Documentation; }
/**
* This class represents a configurable rotation which may or may not be time-dependent.
* Generally, classes of this type should be created through the #createFromDictionary
* function, which takes a dictionary that describes the type of Rotation to create and
* the parameters for the specific type that should be created.
*
* For general use-case by the wider system, the Rotation class should get at most one
* call to the #update method, which call calculate the Rotation using the provided data
* and cache the results, making subsequent calls to matrix() very efficient. For more
* advanced use cases, the matrix(const UpdateDate&) function will calulcate the rotation
* every time it is called.
*
* Generally, when implementing a new type of this class, only the
* matrix(const UpdateDate&) verison needs to be implemented as this base class will
* handle the caching.
*/
class Rotation : public properties::PropertyOwner {
public:
static ghoul::mm_unique_ptr<Rotation> createFromDictionary(
const ghoul::Dictionary& dictionary);
Rotation();
explicit Rotation(const ghoul::Dictionary& dictionary);
virtual ~Rotation() override = default;
virtual bool initialize();
@@ -59,6 +77,7 @@ protected:
private:
bool _needsUpdate = true;
ghoul::mm_unique_ptr<TimeFrame> _timeFrame;
double _cachedTime = -std::numeric_limits<double>::max();
glm::dmat3 _cachedMatrix = glm::dmat3(1.0);
};
+3 -1
View File
@@ -27,6 +27,7 @@
#include <openspace/properties/propertyowner.h>
#include <openspace/scene/timeframe.h>
#include <ghoul/glm.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
@@ -43,7 +44,7 @@ public:
static ghoul::mm_unique_ptr<Scale> createFromDictionary(
const ghoul::Dictionary& dictionary);
Scale();
Scale(const ghoul::Dictionary& dictionary);
virtual ~Scale() override = default;
virtual bool initialize();
@@ -59,6 +60,7 @@ protected:
private:
bool _needsUpdate = true;
ghoul::mm_unique_ptr<TimeFrame> _timeFrame;
double _cachedTime = -std::numeric_limits<double>::max();
glm::dvec3 _cachedScale = glm::dvec3(1.0);
};
+1 -1
View File
@@ -120,7 +120,7 @@ public:
const glm::dmat3& worldRotationMatrix() const;
glm::dmat4 modelTransform() const;
glm::dvec3 worldScale() const;
bool isTimeFrameActive(const Time& time) const;
bool isTimeFrameActive() const;
SceneGraphNode* parent() const;
std::vector<SceneGraphNode*> children() const;
+6 -1
View File
@@ -27,6 +27,7 @@
#include <openspace/properties/propertyowner.h>
#include <openspace/properties//scalar/boolproperty.h>
#include <ghoul/glm.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
#include <memory>
@@ -48,10 +49,14 @@ public:
virtual ~TimeFrame() override = default;
virtual bool initialize();
virtual void update(const Time& time) = 0;
virtual bool isActive(const Time& time) const = 0;
bool isActive() const;
static documentation::Documentation Documentation();
protected:
properties::BoolProperty _isInTimeFrame;
};
} // namespace openspace
+4 -1
View File
@@ -27,6 +27,7 @@
#include <openspace/properties/propertyowner.h>
#include <openspace/scene/timeframe.h>
#include <ghoul/glm.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
#include <functional>
@@ -44,8 +45,9 @@ public:
static ghoul::mm_unique_ptr<Translation> createFromDictionary(
const ghoul::Dictionary& dictionary);
Translation();
explicit Translation(const ghoul::Dictionary& dictionary);
virtual ~Translation() override = default;
virtual bool initialize();
virtual void update(const UpdateData& data);
@@ -65,6 +67,7 @@ protected:
private:
bool _needsUpdate = true;
ghoul::mm_unique_ptr<TimeFrame> _timeFrame;
double _cachedTime = -std::numeric_limits<double>::max();
glm::dvec3 _cachedPosition = glm::dvec3(0.0);
std::function<void()> _onParameterChangeCallback;