Skip to content

Commit

Permalink
Fix a bug in lunar eclipse rendering
Browse files Browse the repository at this point in the history
The function 'computeModelMatrix' was returning the wrong matrix,
because the transformations chain applied the local rotation before the
parent body translations.  This resulted in the Earth and Sun position
used in the shadow computation to be rotated from the center of the
Moon, making the shadow looks like it was seen from an observer outside
of Earth.

I commit this even though we should test a bit more, because a lunar
eclipse is coming.
  • Loading branch information
guillaumechereau committed Jul 23, 2018
1 parent c570438 commit a139dff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/modules/Planet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2449,13 +2449,14 @@ void sRing(Ring3DModel* model, const float rMin, const float rMax, int slices, c

void Planet::computeModelMatrix(Mat4d &result) const
{
result = Mat4d::translation(eclipticPos) * rotLocalToParent * Mat4d::zrotation(M_PI/180*(axisRotation + 90.));
result = Mat4d::translation(eclipticPos) * rotLocalToParent;
PlanetP p = parent;
while (p && p->parent)
{
result = Mat4d::translation(p->eclipticPos) * result * p->rotLocalToParent;
p = p->parent;
}
result = result * Mat4d::zrotation(M_PI/180*(axisRotation + 90.));
}

Planet::RenderData Planet::setCommonShaderUniforms(const StelPainter& painter, QOpenGLShaderProgram* shader, const PlanetShaderVars& shaderVars) const
Expand Down

0 comments on commit a139dff

Please sign in to comment.