Skip to content

Commit ed02ced

Browse files
authored
Merge branch 'development' into code-cleanup
2 parents 32a05c6 + f60b870 commit ed02ced

File tree

8 files changed

+42
-30
lines changed

8 files changed

+42
-30
lines changed

CHANGELOG.md

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

77
## [Unreleased]
88

9+
<details><summary><b>Added</b></summary>
10+
11+
- New `MovableObject` INI and Lua property `PostEffectEnabled` (R/W), which determines whether or not the screen effect of an MO is enabled. Defaults to `true` for `MOPixels` and `MOSParticles`, `false` for everything else (to avoid backwards compatibility issues).
12+
13+
</details>
14+
915
<details><summary><b>Changed</b></summary>
1016

1117
- Massacre now displays the remaining kill count to each player's screen instead of just the first one.
@@ -14,6 +20,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1420

1521
- Improvements to AI navigation in automovers, so they get stuck less often.
1622

23+
- Screen effects (glows) can now show on *any* `MovableObject` they're attached to; you may need to set `EffectAlwaysShows = 1` to see them on `MOSRotatings`. Try `InheritEffectRotAngle = 1` on one of them!
24+
1725
</details>
1826

1927
<details><summary><b>Fixed</b></summary>

Source/Entities/MOPixel.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ void MOPixel::Clear() {
2424
m_MaxLethalRange = 1;
2525
m_LethalSharpness = 1;
2626
m_Staininess = 0;
27+
m_PostEffectEnabled = true; // Default to true for backwards compatibility reasons
2728
}
2829

2930
int MOPixel::Create() {
@@ -218,10 +219,6 @@ void MOPixel::Update() {
218219
}
219220
}
220221
}
221-
222-
if (m_pScreenEffect) {
223-
SetPostScreenEffectToDraw();
224-
}
225222
}
226223

227224
void MOPixel::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const {
@@ -248,11 +245,3 @@ void MOPixel::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode,
248245

249246
g_SceneMan.RegisterDrawing(targetBitmap, m_MOID, pixelPos, 1.0F);
250247
}
251-
252-
void MOPixel::SetPostScreenEffectToDraw() const {
253-
if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) {
254-
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) {
255-
g_PostProcessMan.RegisterPostEffect(m_Pos, m_pScreenEffect, m_ScreenEffectHash, LERP(m_EffectStartTime, m_EffectStopTime, m_EffectStartStrength, m_EffectStopStrength, m_AgeTimer.GetElapsedSimTimeMS()), m_EffectRotAngle);
256-
}
257-
}
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: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ MOSParticle::~MOSParticle() {
2020
void MOSParticle::Clear() {
2121
m_Atom = nullptr;
2222
m_SpriteAnimMode = OVERLIFETIME;
23+
m_PostEffectEnabled = true; // Default to true for backwards compatibility reasons
2324
}
2425

2526
int MOSParticle::Create() {
@@ -147,10 +148,6 @@ void MOSParticle::Travel() {
147148

148149
void MOSParticle::Update() {
149150
MOSprite::Update();
150-
151-
if (m_pScreenEffect) {
152-
SetPostScreenEffectToDraw();
153-
}
154151
}
155152

156153
void MOSParticle::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const {
@@ -220,11 +217,3 @@ void MOSParticle::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode m
220217
g_SceneMan.RegisterDrawing(targetBitmap, m_MOID, spriteX, spriteY, spriteX + m_aSprite[m_Frame]->w, spriteY + m_aSprite[m_Frame]->h);
221218
}
222219
}
223-
224-
void MOSParticle::SetPostScreenEffectToDraw() const {
225-
if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) {
226-
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) {
227-
g_PostProcessMan.RegisterPostEffect(m_Pos, m_pScreenEffect, m_ScreenEffectHash, LERP(m_EffectStartTime, m_EffectStopTime, m_EffectStartStrength, m_EffectStopStrength, m_AgeTimer.GetElapsedSimTimeMS()), m_EffectRotAngle);
228-
}
229-
}
230-
}

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "PieMenu.h"
1313
#include "Serializable.h"
1414
#include "System.h"
15+
#include "PostProcessMan.h"
1516

1617
#include "Base64/base64.h"
1718
#include "tracy/Tracy.hpp"
@@ -97,6 +98,7 @@ void MovableObject::Clear() {
9798
m_EffectStartStrength = 128;
9899
m_EffectStopStrength = 128;
99100
m_EffectAlwaysShows = false;
101+
m_PostEffectEnabled = false;
100102

101103
m_UniqueID = 0;
102104

@@ -220,6 +222,7 @@ int MovableObject::Create(const MovableObject& reference) {
220222
m_MissionCritical = reference.m_MissionCritical;
221223
m_CanBeSquished = reference.m_CanBeSquished;
222224
m_HUDVisible = reference.m_HUDVisible;
225+
m_PostEffectEnabled = reference.m_PostEffectEnabled;
223226

224227
m_ForceIntoMasterLuaState = reference.m_ForceIntoMasterLuaState;
225228
for (auto& [scriptPath, scriptEnabled]: reference.m_AllLoadedScripts) {
@@ -341,6 +344,7 @@ int MovableObject::ReadProperty(const std::string_view& propName, Reader& reader
341344
m_pScreenEffect = m_ScreenEffectFile.GetAsBitmap();
342345
m_ScreenEffectHash = m_ScreenEffectFile.GetHash();
343346
});
347+
MatchProperty("PostEffectEnabled", { reader >> m_PostEffectEnabled; });
344348
MatchProperty("EffectStartTime", { reader >> m_EffectStartTime; });
345349
MatchProperty("EffectRotAngle", { reader >> m_EffectRotAngle; });
346350
MatchProperty("InheritEffectRotAngle", { reader >> m_InheritEffectRotAngle; });
@@ -446,6 +450,8 @@ int MovableObject::Save(Writer& writer) const {
446450
}
447451
writer.NewProperty("ScreenEffect");
448452
writer << m_ScreenEffectFile;
453+
writer.NewProperty("PostEffectEnabled");
454+
writer << m_PostEffectEnabled;
449455
writer.NewProperty("EffectStartTime");
450456
writer << m_EffectStartTime;
451457
writer.NewProperty("EffectStopTime");
@@ -883,6 +889,10 @@ void MovableObject::Update() {
883889
if (m_RandomizeEffectRotAngleEveryFrame) {
884890
m_EffectRotAngle = c_PI * 2.0F * RandomNormalNum();
885891
}
892+
893+
if (m_pScreenEffect && m_PostEffectEnabled) {
894+
SetPostScreenEffectToDraw();
895+
}
886896
}
887897

888898
void MovableObject::Draw(BITMAP* targetBitmap, const Vector& targetPos, DrawMode mode, bool onlyPhysical) const {
@@ -1111,3 +1121,11 @@ bool MovableObject::DrawToTerrain(SLTerrain* terrain) {
11111121
}
11121122
return true;
11131123
}
1124+
1125+
void MovableObject::SetPostScreenEffectToDraw() const {
1126+
if (m_AgeTimer.GetElapsedSimTimeMS() >= m_EffectStartTime && (m_EffectStopTime == 0 || !m_AgeTimer.IsPastSimMS(m_EffectStopTime))) {
1127+
if (m_EffectAlwaysShows || !g_SceneMan.ObscuredPoint(m_Pos.GetFloorIntX(), m_Pos.GetFloorIntY())) {
1128+
g_PostProcessMan.RegisterPostEffect(m_Pos, m_pScreenEffect, m_ScreenEffectHash, LERP(m_EffectStartTime, m_EffectStopTime, m_EffectStartStrength, m_EffectStopStrength, m_AgeTimer.GetElapsedSimTimeMS()), m_EffectRotAngle);
1129+
}
1130+
}
1131+
}

Source/Entities/MovableObject.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,14 @@ namespace RTE {
397397
/// @return The stopping strength of the effect, 0-255.
398398
int GetEffectStopStrength() const { return m_EffectStopStrength; }
399399

400+
/// Gets whether or not this MovableObject's effect is drawn every frame.
401+
/// @return Boolean indicating whether or not the effect is drawn.
402+
bool GetPostEffectEnabled() const { return m_PostEffectEnabled; }
403+
404+
/// Sets whether or not to draw this MovableObject's effect every frame.
405+
/// @param Boolean indicating whether or not to draw the effect.
406+
void SetPostEffectEnabled(bool newValue) { m_PostEffectEnabled = newValue; }
407+
400408
/// Sets the current angular velocity of this MovableObject. Positive is
401409
/// a counter clockwise rotation.
402410
/// @param newRotVel The new angular velocity in radians per second.
@@ -1221,6 +1229,8 @@ namespace RTE {
12211229
bool m_RandomizeEffectRotAngle;
12221230
// Whether effects rot angle should be randomized every frame
12231231
bool m_RandomizeEffectRotAngleEveryFrame;
1232+
// Whether or not to draw the effect every frame; used for flashes
1233+
bool m_PostEffectEnabled;
12241234

12251235
// This object's unique persistent ID
12261236
long m_UniqueID;
@@ -1271,6 +1281,9 @@ namespace RTE {
12711281
// Disallow the use of some implicit methods.
12721282
MovableObject(const MovableObject& reference) = delete;
12731283
MovableObject& operator=(const MovableObject& ref) = delete;
1284+
1285+
/// Sets the screen effect to draw at the final post-processing stage.
1286+
void SetPostScreenEffectToDraw() const;
12741287
};
12751288

12761289
} // namespace RTE

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, MovableObject) {
921921
.property("ApplyWoundDamageOnCollision", &MovableObject::GetApplyWoundDamageOnCollision, &MovableObject::SetApplyWoundDamageOnCollision)
922922
.property("ApplyWoundBurstDamageOnCollision", &MovableObject::GetApplyWoundBurstDamageOnCollision, &MovableObject::SetApplyWoundBurstDamageOnCollision)
923923
.property("SimUpdatesBetweenScriptedUpdates", &MovableObject::GetSimUpdatesBetweenScriptedUpdates, &MovableObject::SetSimUpdatesBetweenScriptedUpdates)
924+
.property("PostEffectEnabled", &MovableObject::GetPostEffectEnabled, &MovableObject::SetPostEffectEnabled)
924925

925926
.def("GetParent", (MOSRotating * (MovableObject::*)()) & MovableObject::GetParent)
926927
.def("GetParent", (const MOSRotating* (MovableObject::*)() const) & MovableObject::GetParent)

0 commit comments

Comments
 (0)