Skip to content

Commit cb940b2

Browse files
authored
Merge pull request #252 from Architector4/patch-constant-time-burst
Make emitter burst independent of delta time
2 parents a6ec694 + 25ecb92 commit cb940b2

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

Source/Entities/AEJetpack.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ void AEJetpack::Burst(Actor& parentActor, float fuelUseMultiplier) {
195195
EnableEmission(true);
196196
AlarmOnEmit(m_Team); // Jetpacks are noisy!
197197

198-
float fuelUsage = g_TimerMan.GetDeltaTimeMS() * static_cast<float>(std::max(GetTotalBurstSize(), 2)) * (CanTriggerBurst() ? 1.0F : 0.5F) * fuelUseMultiplier; // burst fuel
198+
// TODO: burst emissions shouldn't be affected by delta time, but they sort of are.
199+
// Hack here to use constant 60Hz deltatime in milliseconds.
200+
201+
float fuelUsage = (1000.0f / 60.0f) * static_cast<float>(std::max(GetTotalBurstSize(), 2)) * (CanTriggerBurst() ? 1.0F : 0.5F) * fuelUseMultiplier; // burst fuel
202+
199203
fuelUsage += g_TimerMan.GetDeltaTimeMS() * fuelUseMultiplier; // emit fuel
200204
m_JetTimeLeft -= fuelUsage;
201205
}

Source/Entities/AEmitter.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,14 @@ float AEmitter::EstimateImpulse(bool burst) {
276276
for (Emission* emission: m_EmissionList) {
277277
// Only check emissions that push the emitter
278278
if (emission->PushesEmitter()) {
279-
// Todo... we're not checking emission start/stop times here, so this will always calculate the impulse as if the emission was active.
279+
// TODO: we're not checking emission start/stop times here, so this will always calculate the impulse as if the emission was active.
280280
// There's not really an easy way to do this, since the emission rate is not necessarily constant over time.
281-
float emissions = (emission->GetRate() / 60.0f) * g_TimerMan.GetDeltaTimeSecs();
281+
282+
// TODO: burst emissions shouldn't be affected by delta time, but they sort of are.
283+
// Hack here to use constant 60Hz deltatime in seconds.
284+
float deltaTimeSecs = burst ? 1.0f / 60.0f : g_TimerMan.GetDeltaTimeSecs();
285+
286+
float emissions = (emission->GetRate() / 60.0f) * deltaTimeSecs;
282287
float scale = 1.0F;
283288
if (burst) {
284289
emissions *= emission->GetBurstSize();

Source/Entities/AHuman.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,9 @@ float AHuman::EstimateJumpHeight() const {
993993
// Account for the forces upon us.
994994
if (!hasBursted && fuelTime > 0.0F) {
995995
currentYVelocity += impulseBurst;
996-
fuelTime -= g_TimerMan.GetDeltaTimeMS() * fuelUseMultiplierBurst;
996+
// TODO: burst emissions shouldn't be affected by delta time, but they sort of are.
997+
// Hack here to use constant 60Hz deltatime in milliseconds.
998+
fuelTime -= (1000.0f / 60.0f) * fuelUseMultiplierBurst;
997999
hasBursted = true;
9981000
}
9991001

0 commit comments

Comments
 (0)