FixedRotation that depends on other nodes now updates correctly even if time is paused (#2069)

* Update fixed rotation every frame if it depends on another sgn (closes #1751)

This guards against any weird edge cases, where a node the rotation depends on is moved independently of simulation time

* Fix faulty indentation
This commit is contained in:
Emma Broman
2022-05-05 09:39:17 +02:00
committed by GitHub
parent 9a18e6f9ab
commit 679e2994f3
3 changed files with 40 additions and 25 deletions

View File

@@ -41,36 +41,36 @@ local initializeAndAddNodes = function()
},
Tag = { "earth_satellite", "ISS" },
GUI = {
Path = "/Solar System/Planets/Earth/Satellites/ISS"
Path = "/Solar System/Planets/Earth/Satellites/ISS"
}
}
local parentNode = {
Identifier = "ISSModel",
Parent = iss.Identifier,
Transform = {
Rotation = {
Type = "FixedRotation",
Attached = "ISSModel",
XAxis = { 0.01, -1.0, 0.56 },
XAxisOrthogonal = true,
YAxis = transforms.EarthInertial.Identifier
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = models .. "ISS.fbx",
ModelScale = "Centimeter",
LightSources = {
sun.LightSource
},
PerformShading = true,
DisableFaceCulling = true
},
GUI = {
Name = "ISS Model",
Path = "/Solar System/Planets/Earth/Satellites/ISS"
Identifier = "ISSModel",
Parent = iss.Identifier,
Transform = {
Rotation = {
Type = "FixedRotation",
Attached = "ISSModel",
XAxis = { 0.01, -1.0, 0.56 },
XAxisOrthogonal = true,
YAxis = transforms.EarthInertial.Identifier
}
},
Renderable = {
Type = "RenderableModel",
GeometryFile = models .. "ISS.fbx",
ModelScale = "Centimeter",
LightSources = {
sun.LightSource
},
PerformShading = true,
DisableFaceCulling = true
},
GUI = {
Name = "ISS Model",
Path = "/Solar System/Planets/Earth/Satellites/ISS"
}
}
local issTrail = {

View File

@@ -485,6 +485,20 @@ bool FixedRotation::initialize() {
return res;
}
void FixedRotation::update(const UpdateData& data) {
bool anyAxisIsObjectType = (
_xAxis.type == Axis::Type::Object ||
_yAxis.type == Axis::Type::Object ||
_zAxis.type == Axis::Type::Object
);
if (_attachedNode || anyAxisIsObjectType) {
requireUpdate();
}
Rotation::update(data);
}
glm::dmat3 FixedRotation::matrix(const UpdateData&) const {
if (!_enabled) {
return glm::dmat3();

View File

@@ -47,6 +47,7 @@ public:
static documentation::Documentation Documentation();
void update(const UpdateData& data) override;
glm::dmat3 matrix(const UpdateData& data) const override;
private: