From d54e9b7675d8f32779aee690502a1845aea4788d Mon Sep 17 00:00:00 2001 From: Colin Geniet Date: Wed, 13 Jan 2021 12:18:22 +0100 Subject: [PATCH] Animations: Fix spin for Compositor lights The 'spin' animation has a strange behaviour: it pushes a temporary rotation matrix on the transformation stack during cull traversal, and removes it thereafter. Thus, the rotation matrix is missing outside of cull traversal, e.g. when the position of Compositor lights is computed. The same issue was fixed for the 'rotate' animation by commit e202d4e4a516b802b96dc75b1172b74f75fcce1a (this mentions broken 'picking' animations as a different manifestation of the same issue). Fix this by setting the angle of the persistent SGRotateTransform, instead of creating a temporary rotation matrix. --- simgear/scene/model/animation.cxx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/simgear/scene/model/animation.cxx b/simgear/scene/model/animation.cxx index 9bc9fddd..32e71b46 100644 --- a/simgear/scene/model/animation.cxx +++ b/simgear/scene/model/animation.cxx @@ -1134,16 +1134,8 @@ void SpinAnimCallback::operator()(osg::Node* node, osg::NodeVisitor* nv) double intPart; double rot = modf(rotation, &intPart); double angle = rot * 2.0 * osg::PI; - const SGVec3d& sgcenter = transform->getCenter(); - const SGVec3d& sgaxis = transform->getAxis(); - Matrixd mat = Matrixd::translate(-sgcenter[0], -sgcenter[1], -sgcenter[2]) - * Matrixd::rotate(angle, sgaxis[0], sgaxis[1], sgaxis[2]) - * Matrixd::translate(sgcenter[0], sgcenter[1], sgcenter[2]) - * *cv->getModelViewMatrix(); - ref_ptr refmat = new RefMatrix(mat); - cv->pushModelViewMatrix(refmat.get(), transform->getReferenceFrame()); + transform->setAngleRad(angle); traverse(transform, nv); - cv->popModelViewMatrix(); } else { traverse(transform, nv); }