Skip to content

Commit 277d54a

Browse files
sam52796sturnclaw
authored andcommitted
Pause thruster flame flicker when game is paused
1 parent c6f6368 commit 277d54a

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/ModelBody.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include "Camera.h"
77
#include "Frame.h"
8+
#include "Game.h"
89
#include "GameSaveError.h"
910
#include "JsonUtils.h"
1011
#include "Pi.h"
@@ -296,7 +297,10 @@ void ModelBody::MoveGeoms(const matrix4x4d &m, const vector3d &p)
296297
void ModelBody::RenderModel(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform)
297298
{
298299
// HACK: this uses the global application time as a "render clock". This should be accessible through the Camera instead.
299-
m_model->SetRenderTime(Pi::GetApp()->GetTime());
300+
double renderTime = Pi::GetApp()->GetTime();
301+
if (Pi::game)
302+
renderTime = Pi::game->GetTime() + (Pi::GetGameTickAlpha() * Pi::game->GetTimeStep());
303+
m_model->SetRenderTime(renderTime);
300304
m_model->Render(matrix4x4f(viewTransform * GetInterpMatrix()));
301305
}
302306

src/scenegraph/Thruster.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ namespace SceneGraph {
130130
// generated once per frame, not for every vertex
131131
float hash = pos.x + pos.y + pos.z;
132132
hash = (uint16_t(hash32(*reinterpret_cast<uint32_t *>(&hash)) & 0xFFFF)) / 65535.f;
133-
const float x = static_cast<float>(rd->renderTime) * 35.f * (0.75f + hash * 0.5f);
133+
const double x = rd->renderTime * 35.0 * (0.75 + hash * 0.5);
134134
const float flicker = abs(sin(x) * sin(pow(x, 1.1)));
135135

136136
// pass the power setting and flicker value using the material emissive

0 commit comments

Comments
 (0)