Fix the globetransformatons fix in previous commit (bc306c6f1b)

It broke the TimelineTranslation for when keyframes were using GlobeTranslations. The intial position was not set up correctly for these when the code for finding the globe was done in the update.

Bringing back the check in the matrix/position methods solved the problem. Probably the globe is guaranteed to be created when reaching this function
This commit is contained in:
Emma Broman
2021-10-12 13:25:24 +02:00
parent bc306c6f1b
commit f38a7242e7
2 changed files with 20 additions and 12 deletions

View File

@@ -175,11 +175,6 @@ glm::vec3 GlobeRotation::computeSurfacePosition(double latitude, double longitud
}
void GlobeRotation::update(const UpdateData& data) {
if (!_globeNode) {
findGlobe();
setUpdateVariables();
}
if (_useHeightmap) {
// If we use the heightmap, we have to compute the height every frame
setUpdateVariables();
@@ -189,7 +184,16 @@ void GlobeRotation::update(const UpdateData& data) {
}
glm::dmat3 GlobeRotation::matrix(const UpdateData&) const {
if (!_matrixIsDirty || !_globeNode) {
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;
}
if (!_matrixIsDirty) {
return _matrix;
}

View File

@@ -154,11 +154,6 @@ void GlobeTranslation::setUpdateVariables() {
}
void GlobeTranslation::update(const UpdateData& data) {
if (!_attachedNode) {
fillAttachedNode();
setUpdateVariables();
}
if (_useHeightmap) {
// If we use the heightmap, we have to compute the height every frame
setUpdateVariables();
@@ -168,7 +163,16 @@ void GlobeTranslation::update(const UpdateData& data) {
}
glm::dvec3 GlobeTranslation::position(const UpdateData&) const {
if (!_positionIsDirty || !_attachedNode) {
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;
}
if (!_positionIsDirty) {
return _position;
}