Skip to content

Commit fce1b60

Browse files
committed
Enabled glows showing on ALL MovableObjects
1 parent e7cd556 commit fce1b60

File tree

9 files changed

+32
-31
lines changed

9 files changed

+32
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1414

1515
- Improvements to AI navigation in automovers, so they get stuck less often.
1616

17+
- Screen effects (glows) now show on *any* `MovableObject` they're attached to; you may need to set `EffectAlwaysShows = 1` to see them. Try `InheritEffectRotAngle = 1` on a `MOSRotating`!
18+
1719
</details>
1820

1921
<details><summary><b>Fixed</b></summary>

Source/Entities/AEmitter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ void AEmitter::SetFlash(Attachable* newFlash) {
339339
m_pFlash->SetInheritsRotAngle(false);
340340
m_pFlash->SetDeleteWhenRemovedFromParent(true);
341341
m_pFlash->SetCollidesWithTerrainWhileAttached(false);
342+
m_pFlash->MovableObject::SetEffectDrawEveryFrame(false);
342343
}
343344
}
344345

Source/Entities/HDFirearm.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ void HDFirearm::SetFlash(Attachable* newFlash) {
407407
m_pFlash->SetDrawnNormallyByParent(false);
408408
m_pFlash->SetDeleteWhenRemovedFromParent(true);
409409
m_pFlash->SetCollidesWithTerrainWhileAttached(false);
410+
m_pFlash->MovableObject::SetEffectDrawEveryFrame(false);
410411
}
411412
}
412413

Source/Entities/MOPixel.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,6 @@ void MOPixel::Update() {
217217
}
218218
}
219219
}
220-
221-
if (m_pScreenEffect) {
222-
SetPostScreenEffectToDraw();
223-
}
224220
}
225221

226222
void MOPixel::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const {
@@ -259,12 +255,4 @@ void MOPixel::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode,
259255
}
260256

261257
g_SceneMan.RegisterDrawing(targetBitmap, mode == g_DrawNoMOID ? g_NoMOID : m_MOID, pixelPos, 1.0F);
262-
}
263-
264-
void MOPixel::SetPostScreenEffectToDraw() const {
265-
if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) {
266-
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) {
267-
g_PostProcessMan.RegisterPostEffect(m_Pos, m_pScreenEffect, m_ScreenEffectHash, LERP(m_EffectStartTime, m_EffectStopTime, m_EffectStartStrength, m_EffectStopStrength, m_AgeTimer.GetElapsedSimTimeMS()), m_EffectRotAngle);
268-
}
269-
}
270-
}
258+
}

Source/Entities/MOPixel.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ namespace RTE {
176176
float m_Staininess; //!< How likely a pixel is to stain a surface when it collides with it. Defaults to 0 (never stain).
177177

178178
private:
179-
/// Sets the screen effect to draw at the final post-processing stage.
180-
void SetPostScreenEffectToDraw() const;
181-
182179
/// Clears all the member variables of this MOPixel, effectively resetting the members of this abstraction level only.
183180
void Clear();
184181
};

Source/Entities/MOSParticle.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ void MOSParticle::Travel() {
147147

148148
void MOSParticle::Update() {
149149
MOSprite::Update();
150-
151-
if (m_pScreenEffect) {
152-
SetPostScreenEffectToDraw();
153-
}
154150
}
155151

156152
void MOSParticle::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const {
@@ -224,11 +220,3 @@ void MOSParticle::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode m
224220
g_SceneMan.RegisterDrawing(targetBitmap, mode == g_DrawNoMOID ? g_NoMOID : m_MOID, spriteX, spriteY, spriteX + m_aSprite[m_Frame]->w, spriteY + m_aSprite[m_Frame]->h);
225221
}
226222
}
227-
228-
void MOSParticle::SetPostScreenEffectToDraw() const {
229-
if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) {
230-
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) {
231-
g_PostProcessMan.RegisterPostEffect(m_Pos, m_pScreenEffect, m_ScreenEffectHash, LERP(m_EffectStartTime, m_EffectStopTime, m_EffectStartStrength, m_EffectStopStrength, m_AgeTimer.GetElapsedSimTimeMS()), m_EffectRotAngle);
232-
}
233-
}
234-
}

Source/Entities/MOSParticle.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ namespace RTE {
115115
float m_TimeRest; //!< Accumulated time in seconds that did not cause a frame change.
116116

117117
private:
118-
/// Sets the screen effect to draw at the final post-processing stage.
119-
void SetPostScreenEffectToDraw() const;
120-
121118
/// Clears all the member variables of this MOSParticle, effectively resetting the members of this abstraction level only.
122119
void Clear();
123120

Source/Entities/MovableObject.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void MovableObject::Clear() {
9797
m_EffectStartStrength = 128;
9898
m_EffectStopStrength = 128;
9999
m_EffectAlwaysShows = false;
100+
m_EffectDrawEveryFrame = true;
100101

101102
m_UniqueID = 0;
102103

@@ -893,6 +894,10 @@ void MovableObject::Update() {
893894
if (m_RandomizeEffectRotAngleEveryFrame) {
894895
m_EffectRotAngle = c_PI * 2.0F * RandomNormalNum();
895896
}
897+
898+
if (m_pScreenEffect && m_EffectDrawEveryFrame) {
899+
MovableObject::SetPostScreenEffectToDraw();
900+
}
896901
}
897902

898903
void MovableObject::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const {
@@ -1121,3 +1126,11 @@ bool MovableObject::DrawToTerrain(SLTerrain* terrain) {
11211126
}
11221127
return true;
11231128
}
1129+
1130+
void MovableObject::SetPostScreenEffectToDraw() const {
1131+
if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) {
1132+
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) {
1133+
g_PostProcessMan.RegisterPostEffect(m_Pos, m_pScreenEffect, m_ScreenEffectHash, LERP(m_EffectStartTime, m_EffectStopTime, m_EffectStartStrength, m_EffectStopStrength, m_AgeTimer.GetElapsedSimTimeMS()), m_EffectRotAngle);
1134+
}
1135+
}
1136+
}

Source/Entities/MovableObject.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "LuabindObjectWrapper.h"
1313
#include "Material.h"
1414
#include "MovableMan.h"
15+
#include "PostProcessMan.h"
1516

1617
#include <set>
1718

@@ -397,6 +398,14 @@ namespace RTE {
397398
/// @return The stopping strength of the effect, 0-255.
398399
int GetEffectStopStrength() const { return m_EffectStopStrength; }
399400

401+
/// Gets whether or not this MovableObject's effect is drawn every frame.
402+
/// @return Boolean indicating whether or not the effect is drawn.
403+
bool GetEffectDrawEveryFrame() const { return m_EffectDrawEveryFrame; }
404+
405+
/// Sets whether or not to draw this MovableObject's effect every frame.
406+
/// @param Boolean indicating whether or not to draw the effect.
407+
void SetEffectDrawEveryFrame(bool newValue) { m_EffectDrawEveryFrame = newValue; }
408+
400409
/// Sets the current angular velocity of this MovableObject. Positive is
401410
/// a counter clockwise rotation.
402411
/// @param newRotVel The new angular velocity in radians per second.
@@ -1058,6 +1067,9 @@ namespace RTE {
10581067
/// @return Whether this MO has requested a synced update this frame.
10591068
virtual bool HasRequestedSyncedUpdate() { return m_RequestedSyncedUpdate; }
10601069

1070+
/// Sets the screen effect to draw at the final post-processing stage.
1071+
void SetPostScreenEffectToDraw() const;
1072+
10611073
/// Protected member variable and method declarations
10621074
protected:
10631075
/// Does necessary work to setup a script object name for this object, allowing it to be accessed in Lua, then runs all of the MO's scripts' Create functions in Lua.
@@ -1227,6 +1239,8 @@ namespace RTE {
12271239
bool m_RandomizeEffectRotAngle;
12281240
// Whether effects rot angle should be randomized every frame
12291241
bool m_RandomizeEffectRotAngleEveryFrame;
1242+
// Whether or not to draw the effect every frame; used for flashes
1243+
bool m_EffectDrawEveryFrame;
12301244

12311245
// This object's unique persistent ID
12321246
long m_UniqueID;

0 commit comments

Comments
 (0)