Skip to content

Commit db8e12b

Browse files
committed
Make thruster visual more consistent
1 parent 893a900 commit db8e12b

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/scenegraph/Thruster.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,13 @@ namespace SceneGraph {
143143
m_tMat->diffuse = m_glowMat->diffuse = currentColor;
144144

145145
//directional fade
146-
vector3f cdir = vector3f(trans * -dir).Normalized();
147-
vector3f vdir = vector3f(trans[2], trans[6], -trans[10]).Normalized();
146+
// In view space, camera is at origin, so view direction is from thruster position to origin.
147+
vector3f flameDir = trans.ApplyRotationOnly(-dir).Normalized();
148+
vector3f thrusterPos = trans.GetTranslate();
149+
vector3f vdir = (thrusterPos.LengthSqr() > 1e-8f) ? (-thrusterPos).Normalized() : flameDir;
150+
float facing = Clamp(vdir.Dot(flameDir), 0.f, 1.f);
148151
// XXX check this for transition to new colors.
149-
m_glowMat->diffuse.a = Easing::Circ::EaseIn(Clamp(vdir.Dot(cdir), 0.f, 1.f), 0.f, 1.f, 1.f) * 255;
152+
m_glowMat->diffuse.a = Easing::Circ::EaseIn(facing, 0.f, 1.f, 1.f) * 255;
150153
m_tMat->diffuse.a = 255 - m_glowMat->diffuse.a;
151154

152155
Graphics::Renderer *r = GetRenderer();

0 commit comments

Comments
 (0)