Fix globe transformations not updating from height map if simulation time paused (#1766)

This commit is contained in:
Emma Broman
2021-10-12 08:37:25 +02:00
committed by GitHub
parent 76dd45e5ce
commit bc306c6f1b
6 changed files with 22 additions and 20 deletions

View File

@@ -51,7 +51,7 @@ public:
const glm::dmat3& matrix() const;
virtual glm::dmat3 matrix(const UpdateData& time) const = 0;
void update(const UpdateData& data);
virtual void update(const UpdateData& data);
static documentation::Documentation Documentation();

View File

@@ -50,8 +50,8 @@ public:
virtual ~Translation() = default;
virtual bool initialize();
virtual void update(const UpdateData& data);
glm::dvec3 position() const;
void update(const UpdateData& data);
virtual glm::dvec3 position(const UpdateData& data) const = 0;

View File

@@ -174,22 +174,22 @@ glm::vec3 GlobeRotation::computeSurfacePosition(double latitude, double longitud
);
}
glm::dmat3 GlobeRotation::matrix(const UpdateData&) const {
void GlobeRotation::update(const UpdateData& data) {
if (!_globeNode) {
// @TODO(abock): The const cast should be removed on a redesign of the rotation
// to make the matrix function not constant. Const casting this
// away is fine as the factories that create the rotations don't
// create them as constant objects
const_cast<GlobeRotation*>(this)->findGlobe();
_matrixIsDirty = true;
findGlobe();
setUpdateVariables();
}
if (_useHeightmap) {
// If we use the heightmap, we have to compute the height every frame
_matrixIsDirty = true;
setUpdateVariables();
}
if (!_matrixIsDirty) {
Rotation::update(data);
}
glm::dmat3 GlobeRotation::matrix(const UpdateData&) const {
if (!_matrixIsDirty || !_globeNode) {
return _matrix;
}

View File

@@ -39,6 +39,7 @@ class GlobeRotation : public Rotation {
public:
GlobeRotation(const ghoul::Dictionary& dictionary);
void update(const UpdateData& data) override;
glm::dmat3 matrix(const UpdateData& data) const override;
static documentation::Documentation Documentation();

View File

@@ -153,22 +153,22 @@ void GlobeTranslation::setUpdateVariables() {
requireUpdate();
}
glm::dvec3 GlobeTranslation::position(const UpdateData&) const {
void GlobeTranslation::update(const UpdateData& data) {
if (!_attachedNode) {
// @TODO(abock): The const cast should be removed on a redesign of the translation
// to make the position function not constant. Const casting this
// away is fine as the factories that create the translations don't
// create them as constant objects
const_cast<GlobeTranslation*>(this)->fillAttachedNode();
_positionIsDirty = true;
fillAttachedNode();
setUpdateVariables();
}
if (_useHeightmap) {
// If we use the heightmap, we have to compute the height every frame
_positionIsDirty = true;
setUpdateVariables();
}
if (!_positionIsDirty) {
Translation::update(data);
}
glm::dvec3 GlobeTranslation::position(const UpdateData&) const {
if (!_positionIsDirty || !_attachedNode) {
return _position;
}

View File

@@ -39,6 +39,7 @@ class GlobeTranslation : public Translation {
public:
GlobeTranslation(const ghoul::Dictionary& dictionary);
void update(const UpdateData& data) override;
glm::dvec3 position(const UpdateData& data) const override;
static documentation::Documentation Documentation();