FixedRotation rerequests a missing attached node or target node every frame to prevent incorrect initialization order

This commit is contained in:
Alexander Bock
2024-06-15 18:07:39 +02:00
parent f76215961c
commit 01fa2898db
3 changed files with 18 additions and 2 deletions

View File

@@ -21,7 +21,7 @@ local ArtemisModel = {
Attached = "ArtemisModel",
XAxis = { 1.0, 0.0, 0.0 },
XAxisOrthogonal = true,
YAxis = "Sun",
YAxis = sun.SunCenter.Identifier,
YAxisInvert = true
}
},

View File

@@ -30,7 +30,7 @@ local Euclid = {
Rotation = {
Type = "FixedRotation",
Attached = "Euclid",
ZAxis = "Sun",
ZAxis = sun.SunCenter.Identifier,
YAxis = { 0.0, 1.0, 0.0 },
YAxisOrthogonal = true
}

View File

@@ -505,6 +505,22 @@ void FixedRotation::update(const UpdateData& data) {
_zAxis.type == Axis::Type::Object
);
// @TODO (2024-06-15, abock) None of the following four checks should be necessary
// as the nodes are retrieved whenever the property value is changed, but we
// had an initialization issue and this was the fastest way to fix the bug
if (!_attachedNode) {
_attachedNode = sceneGraphNode(_attachedObject);
}
if (_xAxis.type == Axis::Type::Object && !_xAxis.node) {
_xAxis.node = sceneGraphNode(_xAxis.object);
}
if (_yAxis.type == Axis::Type::Object && !_yAxis.node) {
_yAxis.node = sceneGraphNode(_yAxis.object);
}
if (_zAxis.type == Axis::Type::Object && !_zAxis.node) {
_zAxis.node = sceneGraphNode(_zAxis.object);
}
if (_attachedNode || anyAxisIsObjectType) {
requireUpdate();
}