Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(w3ddevice): -volsmoke building fireball, debris dust, black column

Olcay Seygand6f455065cf7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d418b973c..2f2070070 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -117,7 +117,7 @@ found and fixed, EA's own, not port damage.**
- A nuke builds a mushroom you can read. The flash is light: the ground, the buildings and the missile's own smoke trail go white for a third of a second, where a flat white disc used to cover half the screen for most of a second. From the first frame a lumpy ball of fire sits on the ground, yellow-white inside an orange-red rim, with a thin white dome running out round it, and the orange disc that lay on the ground under it is gone. The ball rises and slows, and by five seconds is an orange cap on a thin grey-brown stem. A white collar rings the stem for a few seconds. The cap cools to cream and lumpy cauliflower, three to four times as wide as the stem, and it stays up for over a minute; the old one was a dark brown disc that had thinned away inside twelve seconds. The dark dust that used to bury the whole base under the cloud is gone, and a low wall of dust runs out along the ground between the buildings instead. The missile's own trail is smoke in the same air now, a thick pale column behind it on the way up from the silo and on the way down, drifting with the wind and spreading as it thins, where it used to stay a column of flat sprites.
- Every other smoke goes the same way while it is on: missile and rocket trails, the dust behind a tank, a burning building's column, muzzle smoke. They are fed into one body of air round the camera instead of being drawn as sprites, and a unit moving through it pushes it. A tank's hull shoves the smoke aside and leaves a turning wake, a jet drags a sheet of it down between two wingtip vortices, and a helicopter hovering low flattens a burning column into a dark ring on the ground and lifts a band of dust round itself. A blast's front pushes the smoke already hanging round it outwards. Units you cannot see push nothing, so the smoke never gives away a stealthed tank or an unscouted base.
- Missile and rocket trails are thin ribbons of real smoke. A Tomahawk's, a Rocket Buggy's and a Scud Launcher's lay a pale line that breaks into puffs, widens towards its old end, stirs and drifts off with the wind, and fades out along its length as it goes, the oldest end first, so a Rocket Buggy salvo no longer leaves a tan haze over the field: a Tomahawk's arc over Heartland Shield is gone about 2 s after the launch, where it hung on for 5 to 6 and the game's own lasts about 3. A trail that climbs high, a Scud's arc or the nine columns a Scud Storm puts up, goes into a second, taller body of air over the battlefield, a thousand units high, where it thins just as fast. The trails are lit by the sun like any smoke: the Scud Storm's columns had stood as straight glowing pillars of one width that read as beams of light, and at night on Dark Night the trails stood out pale blue as if lit from inside. Now a big missile, a Scud's, a Tomahawk's or the nuclear missile's, leaves a white plume that billows out wider as it ages, lumpy and shaded on its far side, while a Rocket Buggy's, a Stinger's or a Comanche's rocket leaves a thin grey trail. Every one burns at the nozzle, a short white-yellow flame that is gone a few frames behind the missile. A launch throws a cloud: a Scud Storm, a Scud Launcher, a Tomahawk launcher and the nuclear silo blow a white cloud out sideways over the pad and the ground round it, under a flash at the nozzle, and it is gone in about four seconds. A rocket's backblast leaves a white puff at the launcher, where before it was gone before it showed. Before, a fast missile's trail broke into a dotted line of brown blobs, and once a missile climbed past about 200 units over the ground the top of its trail simply vanished.
-- Buildings come down in their own shape. The smoke reads the building's model: the moment one dies, smoke and dust fill each of its parts where it stood, a War Factory's hall and its two stacks, a Speaker Tower's mast, and slump down, while fire bursts out of the tops of the biggest parts and a ragged plume climbs out of them and cools to smoke. The collapse throws a pale dust cloud that rolls out along the ground on every side, heavier than the air and hugging the terrain, two to three times the building's width out before it thins, and runs round the buildings beside it, between their real walls and stacks rather than over one box. Before, the dust had nowhere to go but up, and a fall was only a column. The ruin burns under a grey-brown column for two seconds, so a fall's own smoke and dust are off the screen 3 to 4 s after it and only the game's own column is left in the air until about 6, sooner than the game's own at 7 to 8 (it stayed for fourteen at first, and in a fast game that hid the next fight); a damaged building's own smoke and the dust round it thin within a couple of seconds of their puffs. The size follows the building: an American Power Plant's is about half the width of a War Factory's or a Particle Cannon's. Each damaged stage on the way down blows fire out of the top of the standing building with a little smoke, where it used to leave a big black cloud over the roof, and the shells landing on it in that moment no longer leave their fireballs floating over the cloud. A Rocket Buggy's rockets hitting the rubble throw their dirt for a second and it falls back, where their brown fountains stood beside a fallen War Factory as tan fingers for six seconds after everything else had gone. The fall's smoke is lit on its sunny side: on Winter Wolf's snow it had stood as one block of pure black across the middle of the screen. The game's own fireball sprites, flare and flat shock ring for that moment are gone while the smoke is on; flying debris keeps its sparks.
+- Buildings come down in their own shape. The smoke reads the building's model: the moment one dies, a white-yellow fireball bursts out of each of its parts, a War Factory's hall and its two stacks, a Speaker Tower's mast, bigger than the part it came from and pushed out through its walls, cools to orange under a sooty edge and is gone in well under a second, while a ragged plume climbs out of the tops and cools to smoke. Before, the parts filled with dull dust that slumped and only three small fires came off the roof. The chunks the building throws trail pale dust as they fly, where they used to fly bare; with the smoke Off they stay as they were. The collapse throws a pale dust cloud that rolls out along the ground on every side, heavier than the air and hugging the terrain, two to three times the building's width out before it thins, and runs round the buildings beside it, between their real walls and stacks rather than over one box. Before, the dust had nowhere to go but up, and a fall was only a column. The ruin burns under a thick black-grey column with the fire still glowing in its foot, where it used to be a thin pale wisp, for two seconds, so a fall's own smoke and dust are off the screen 3 to 4 s after it and only the game's own column is left in the air until about 6, sooner than the game's own at 7 to 8 (it stayed for fourteen at first, and in a fast game that hid the next fight); a damaged building's own smoke and the dust round it thin within a couple of seconds of their puffs. The size follows the building: an American Power Plant's is about half the width of a War Factory's or a Particle Cannon's. Each damaged stage on the way down blows fire out of the top of the standing building with a little smoke, where it used to leave a big black cloud over the roof, and the shells landing on it in that moment no longer leave their fireballs floating over the cloud. A Rocket Buggy's rockets hitting the rubble throw their dirt for a second and it falls back, where their brown fountains stood beside a fallen War Factory as tan fingers for six seconds after everything else had gone. The fall's smoke is lit on its sunny side: on Winter Wolf's snow it had stood as one block of pure black across the middle of the screen. The game's own fireball sprites, flare and flat shock ring for that moment are gone while the smoke is on; flying debris keeps its sparks.
- Burning buildings burn. A damaged building's fires are flames in that same air now, where they were flat sprites: each burning spot gives off fuel off the building's own roof and wall tops, read from its model, at the heat the game's own flame there stands for, so the flames stand on the building instead of hanging over it; the fuel comes off in patches and lights, burns hottest on its outside where the air reaches it, rises on its own heat and leans with the wind. The flame glows the colour hot soot glows, yellow-white at its foot where it burns hottest and orange to dull red higher up, where it breaks into licks with clear air between them, and it puffs the way a real fire puffs, a wide one slower than a small one. The fuel a flame carries past its tips is too cool to burn by then and turns into near-black smoke, which climbs off the building and thins away in about three seconds; while it does, the game's own smoke on that building stands aside. The building's own floors and roofs are what the flames stand on, so a GLA barracks, whose outline is one big box over its tents, no longer smothers all but one of its fires. Units push it like any smoke: a helicopter hovering over a burning factory fans its flames down and out. It goes out within two seconds of the game's own fire, so a repaired building stops burning and a fire never outlasts the building's damage. Fires on the move, a burning tank driving off or a running soldier, keep the game's own flames, and so do sparks, embers and a burning car wreck, whose flame the first version had put out altogether. Eight burning buildings on Twilight Flame's plateau cost 0.4 ms of GPU time a frame on Low and 1.0 on High over the smoke alone, on an RTX 2060.
- It costs the graphics card. Three armies and three superweapons on Twilight Flame at 1920x1080, on an RTX 2060: 5.2 ms of GPU time a frame with it Off, 8.6 on Low and 10.0 to 10.2 on High; the frame itself took 5.3, 5.6 and 6.9 to 7.2 ms. Low runs half as many blasts at once in a coarser body of air, so a weak card should leave it Off or take Low. A nuke on an American base on the same map costs 2.4 ms of GPU time a frame Off, 4.1 to 4.7 on Low and 6.9 to 7.1 on High. A rocket fight with Scud Launchers, then a Scud Storm and a nuke, seen from over the rockets: 2.2 ms Off, 3.1 on Low, 4.1 to 4.2 on High. Five buildings brought down one after another on that base: 1.3 ms Off, 1.9 to 2.0 on Low, 2.2 on High.
diff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
index a59db3b01..aaa684635 100644
--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini
@@ -6987,3 +6987,65 @@ ParticleSystem ReforgedDebrisTrail
WindPingPongEndAngleMin = 5.497787
WindPingPongEndAngleMax = 6.283185
End
+
+; A fallen building's flying debris (GenericDebris out of OCL_LargeStructureDebris and the rest) trails
+; pale dust, as in the building explosion photos, where the game's own chunks fly bare. Hung on each
+; chunk by the smoke simulation (DX11VolumeSmoke.cpp, attachDebrisDust) only while that setting is on,
+; so Off keeps the game's own look and no logic file changes. A grey-tan ribbon that widens and is gone
+; in under a second; the system stops after a second and a half, the chunk's flight.
+
+ParticleSystem ReforgedStructureDebrisDust
+ Priority = WEAPON_EXPLOSION
+ IsOneShot = No
+ Shader = ALPHA
+ Type = STREAK
+ ParticleName = EXJetSmoke.tga
+ AngleZ = 0.00 0.00
+ AngularRateZ = 0.00 0.00
+ AngularDamping = 1.00 1.00
+ VelocityDamping = 0.95 0.95
+ Gravity = 0.00
+ Lifetime = 24.00 24.00
+ SystemLifetime = 45
+ Size = 2.60 2.60
+ StartSizeRate = 0.00 0.00
+ SizeRate = 0.25 0.25
+ SizeRateDamping = 0.95 0.95
+ Alpha1 = 0.00 0.00 0
+ Alpha2 = 0.55 0.55 2
+ Alpha3 = 0.25 0.25 12
+ Alpha4 = 0.00 0.00 24
+ Alpha5 = 0.00 0.00 0
+ Alpha6 = 0.00 0.00 0
+ Alpha7 = 0.00 0.00 0
+ Alpha8 = 0.00 0.00 0
+ Color1 = R:150 G:140 B:125 0
+ Color2 = R:175 G:166 B:152 12
+ Color3 = R:0 G:0 B:0 0
+ Color4 = R:0 G:0 B:0 0
+ Color5 = R:0 G:0 B:0 0
+ Color6 = R:0 G:0 B:0 0
+ Color7 = R:0 G:0 B:0 0
+ Color8 = R:0 G:0 B:0 0
+ ColorScale = 0.00 0.00
+ BurstDelay = 1.00 1.00
+ BurstCount = 1.00 1.00
+ InitialDelay = 0.00 0.00
+ DriftVelocity = X:0.00 Y:0.00 Z:0.05
+ VelocityType = ORTHO
+ VelOrthoX = 0.00 0.00
+ VelOrthoY = 0.00 0.00
+ VelOrthoZ = 0.00 0.00
+ VolumeType = POINT
+ IsHollow = No
+ IsGroundAligned = No
+ IsEmitAboveGroundOnly = No
+ IsParticleUpTowardsEmitter = No
+ WindMotion = Unused
+ WindAngleChangeMin = 0.149924
+ WindAngleChangeMax = 0.449946
+ WindPingPongStartAngleMin = 0.000000
+ WindPingPongStartAngleMax = 0.785398
+ WindPingPongEndAngleMin = 5.497787
+ WindPingPongEndAngleMax = 6.283185
+End
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
index c75fc267c..7006545ea 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/DX11VolumeSmoke.cpp
@@ -153,6 +153,9 @@ const float GroundDustHalfLife = 0.38f, GroundRollHalfLife = 1.5f;
// dirt fountains stood beside a fallen War Factory as tan fingers for ten seconds.
const float RollWeight = 10.0f, DirtWeight = 30.0f, TankMassWeight = 0.2f;
const float CapSpillHalfLife = 1.0f; // a nuclear cap's soot once the flow has carried it out of the cap
+const float FireballSeconds = 0.6f; // a building's fall's fireball, burst to cooled
+const float FireballHalfLife = 0.15f; // and its heat after that, over the shared HeatHalfLife (the column's fire is laid again each step)
+const float DebrisDustSeconds = 0.6f; // how long after a fall its flying debris is given dust trails (Gather)
const float StructureSootHalfLife = 0.75f; // a building's blast's soot: at 7 a fall's smoke was on screen for 14 s, at 3 for 7 to 10, at 1.5 for 5 to 6
// A tank's soot from 1.25 s on, once its column is falling: its black column is gone from the play
// camera about 2 s after the death and a thin smoulder fades out by 3.5 s (the volume lives 4.25, its
@@ -268,7 +271,7 @@ struct SimConstants {
float Origins[MaxSlabs][4]; // each slab's world corner, for the movers below
float MoverCount[4];
float Movers[MaxMovers * 4][4]; // the units that push the air this step, in world units (Mover)
- float Thin[MaxSlabs][4]; // a blast's soot kept over this step (a building's thins; 1 for the rest), its cold dust's weight, its ground dust kept, its heat kept on top of Keep.x (a gun's; 1 for the rest)
+ float Thin[MaxSlabs][4]; // a blast's soot kept over this step (a building's thins; 1 for the rest), its cold dust's weight, its ground dust kept, its heat kept, its heat kept on top of Keep.x (a gun's; 1 for the rest)
// A fire's slab (FireFields, after Thin in its programs' cbuffer only): burn rate, heat a unit of
// fuel gives, soot yield, ignition heat; the fuel that starves it, radiation, soot burn,
// expansion; its lift in cells/s^2 at heat 1.
@@ -2561,12 +2564,12 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
auto unit = [&](unsigned salt) { return hashUnit(volume.seed, salt); };
const bool standing = volume.standing;
dust[0] = 0.76f; dust[1] = 0.72f; dust[2] = 0.65f; // pale concrete and plaster dust; at 0.66 it lay grey-brown in its own shade
- // grey-brown smoke of a burning building, where a tank's black soot made a factory's fall
- // one black box
- soot[0] = 0.2f; soot[1] = 0.19f; soot[2] = 0.18f;
+ // black-grey smoke off the fire, as in the building explosion photos (at grey-brown 0.2 the
+ // ruin's column stood pale; a tank's 0.06 had made a factory's fall one black box)
+ soot[0] = 0.085f; soot[1] = 0.08f; soot[2] = 0.075f;
// and lit on its sunny side, with more sky in its shade: on Winter Wolf's snow the column
// stood pure black with no side lit at 0.26 and 0.75
- shade = 0.4f;
+ shade = 0.32f;
sunShare = 0.95f;
// Its meshes (readParts): the tallest first, then the biggest. With none read, its
// footprint stands in as one box.
@@ -2585,38 +2588,43 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
unsigned big[MaxParts];
for (unsigned i = 0; i < partCount; ++i) big[i] = i;
std::sort(big, big + partCount, [&](unsigned a, unsigned b) { return areaOf(a) > areaOf(b); });
- // The fall starts as the building's own shape in smoke and dust: each mesh's box filled at
- // the moment it comes down, slumping, with a dull glow inside, two bodies one over the other
- // for a mesh taller than it is wide. A factory's hall, its stacks and a mast each leave their
- // own outline before it settles, where the footprint's quarters drew one square.
- if (!standing && t < 0.45f) {
- const float fade = 1 - t / 0.45f;
- unsigned laid = 0;
- for (unsigned i = 0; i < partCount && laid < 9; ++i) {
+ // The fall's fireball, after the building explosion photos: a white-yellow ball out of every
+ // mesh, bigger than the mesh, swelling and pushed out through its walls from the building's
+ // middle, cooling to orange, under a sooty rim that lags it and stays dark where the core's
+ // heat does not reach. Gone in 0.6 s. The mesh boxes once filled with dust and a dull glow
+ // read as a slump, and three bursts off the roof as small fires: dust never glows.
+ if (!standing && t < FireballSeconds) {
+ const float fade = 1 - t / FireballSeconds, swell = 1 + 0.7f * smoothstep01(t, 0.0f, 0.5f);
+ for (unsigned i = 0; i < (std::min)(partCount, 6u); ++i) {
const Part &p = parts[i];
- const float tall = (std::max)(p.top - p.bottom, 1.0f), narrow = (std::min)(p.halfAlong, p.halfAcross);
- const unsigned stack = tall > 3.2f * narrow ? 2 : 1;
- for (unsigned k = 0; k < stack && laid < 9; ++k, ++laid) {
- const float radius = (std::min)(narrow, tall / (2.0f * stack)) * 1.15f + 0.4f;
- onFootprint(p.along, p.across, p.bottom + tall * (k + 0.5f) / stack, radius, p.along * 0.4f, p.across * 0.4f, -4.0f * fade,
- 3.0f * fade, 1.0f, 16.0f * fade, 0.25f);
- }
+ const float tall = (std::max)(p.top - p.bottom, 1.0f), middle = p.bottom + tall * 0.5f;
+ const float out = std::sqrt(p.along * p.along + p.across * p.across);
+ const float da = out > 0.5f ? p.along / out : std::cos(6.2831853f * unit(560 + i));
+ const float dc = out > 0.5f ? p.across / out : std::sin(6.2831853f * unit(560 + i));
+ const float room = 0.6f * (TierShapes[0].gz - 10.0f - middle);
+ const float radius = (std::min)((std::max)((std::max)(std::sqrt(p.halfAlong * p.halfAlong + p.halfAcross * p.halfAcross) * 0.7f,
+ tall * 0.5f), 2.0f) * swell, (std::max)(room, 2.0f));
+ const float a = p.along + da * 4.0f * t, c = p.across + dc * 4.0f * t, z = middle + 3.0f * t;
+ const float heat = 2.2f * (1 - 0.55f * smoothstep01(t, 0.1f, FireballSeconds));
+ // (soot 8 in the ball and 12 in a rim 1.35 times as wide round it stood as one black dome
+ // over the fall, the fire hidden inside it, and pushed out at 8 the ball ran along the
+ // ground as a glowing carpet)
+ onFootprint(a, c, z, radius, da * 5.0f * fade, dc * 5.0f * fade, 8.0f * fade, 3.0f * fade, heat, 0, 0.35f);
+ if (t > 0.12f)
+ onFootprint(a, c, z + radius * 0.4f, radius * 1.15f, da * 4.0f * fade, dc * 4.0f * fade, 8.0f * fade, 2.5f * fade, 0.6f, 0, 0.2f);
}
}
- // Fire bursts out of the tops of its biggest meshes, thrown outwards; a damaged stage only
- // out of its tallest, with a third of the soot, so it is fire blowing out of a standing
- // building and not a black cloud over its roof.
- if (t < (standing ? 0.6f : 0.7f)) {
- const float fade = 1 - t / (standing ? 0.6f : 0.7f);
- const unsigned bursts = (std::min)(partCount, standing ? 2u : 3u);
- for (unsigned i = 0; i < bursts; ++i) {
- const Part &p = parts[standing ? i : big[i]];
+ // A damaged stage blows fire out of the top of its tallest meshes, thrown outwards, with
+ // little soot, so it is fire blowing out of a standing building and not a black cloud over
+ // its roof.
+ if (standing && t < 0.6f) {
+ const float fade = 1 - t / 0.6f;
+ for (unsigned i = 0; i < (std::min)(partCount, 2u); ++i) {
+ const Part &p = parts[i];
const float out = std::sqrt(p.along * p.along + p.across * p.across) + 1e-3f;
- // (a damaged stage's smaller: one of a mesh's size stood over the roof as a brown ball)
- onFootprint(p.along, p.across, p.top * (standing ? 1.0f : 0.85f) + 0.4f,
- (std::max)((std::min)(p.halfAlong, p.halfAcross) * (standing ? 0.45f : 0.75f), 2.0f),
- p.along / out * 6.0f * fade, p.across / out * 6.0f * fade, 4.0f + 3.0f * unit(560 + i),
- (standing ? 3.0f : 5.0f) * fade, standing ? 1.6f : 1.45f, 3.0f * fade, 0.3f);
+ // (smaller than a mesh: one of a mesh's size stood over the roof as a brown ball)
+ onFootprint(p.along, p.across, p.top + 0.4f, (std::max)((std::min)(p.halfAlong, p.halfAcross) * 0.45f, 2.0f),
+ p.along / out * 6.0f * fade, p.across / out * 6.0f * fade, 4.0f + 3.0f * unit(560 + i), 3.0f * fade, 1.6f, 3.0f * fade, 0.3f);
}
}
// The plume, the tank's jets out of the tops of its meshes: each lays thin smoke at a rate that
@@ -2694,8 +2702,9 @@ void schedule(const Volume &volume, unsigned slab, float t, DrawConstants *draw)
const float rise = (std::min)((t - 0.4f) / 0.4f, 1.0f), fall = t > 1.0f ? 1 - (t - 1.0f) / 1.25f : 1.0f;
for (unsigned i = 0; i < (std::min)(partCount, 2u); ++i) {
const Part &p = parts[big[i]];
+ // (thick: at 0.8 it was a thin pale wisp beside the photos' black column)
onFootprint(p.along, p.across, 0.6f, (std::max)((std::min)(p.halfAlong, p.halfAcross) * 0.6f, 2.0f), 0, 0, 12.0f,
- 0.8f * rise * fall * (i ? 0.6f : 1.0f), fall, 0.1f, 0.25f);
+ 2.0f * rise * fall * (i ? 0.6f : 1.0f), fall, 0.1f, 0.25f);
}
}
soot[3] = 1.6f + 2.4f * std::exp(-t / 0.3f);
@@ -3122,8 +3131,14 @@ void step(ID3D11DeviceContext *context, unsigned t, int now, float dt, float sec
sim.Thin[slab][1] = rolls ? RollWeight : volume.kind == TankDeath ? TankMassWeight
: volume.kind == Shell && volume.scale < 2.0f ? DirtWeight : 0.0f;
sim.Thin[slab][2] = std::pow(0.5f, dt / (rolls ? GroundRollHalfLife : GroundDustHalfLife));
- // its heat kept over this step on top of the tier's (a gun's fireball goes in a few frames)
- sim.Thin[slab][3] = volume.kind == Muzzle ? std::pow(0.5f, dt / MuzzleHeatHalfLife) : 1.0f;
+ // a fall's fireball cools on its own clock once its emitters stop, so it is gone inside a
+ // second (at the shared HeatHalfLife it still burned orange at 1.3 s)
+ // Its heat kept over this step on top of the tier's: a gun's fireball goes in a few frames, and
+ // a fall's cools on its own clock once its emitters stop, so it is gone inside a second (at
+ // the shared HeatHalfLife it still burned orange at 1.3 s).
+ const bool fireballCools = volume.kind == Structure && !volume.standing && volume.live && secondsSince(volume, now) > FireballSeconds;
+ sim.Thin[slab][3] = volume.kind == Muzzle ? std::pow(0.5f, dt / MuzzleHeatHalfLife)
+ : fireballCools ? std::pow(0.5f, dt / FireballHalfLife) : 1.0f;
for (unsigned i = 0; i < 3; ++i) sim.Origins[slab][i] = volume.origin[i];
if (!volume.live) continue;
layFloor(context, tier, slab, volumes[tier.shape.first + slab], now);
@@ -4726,6 +4741,45 @@ bool Takes(ParticleSystem *system)
return true;
}
+// A building's fall throws its stock debris (OCL_LargeStructureDebris and the rest, GenericDebris
+// objects), which flies with no trail: each chunk seen beside a fall in its first DebrisDustSeconds
+// gets a short dust trail of its own, a client particle system riding its drawable. Only with the
+// setting on (Gather), so Off keeps the game's own look; nothing goes back to the logic.
+void attachDebrisDust(int now)
+{
+ if (!TheGameClient || !TheParticleSystemManager) return;
+ static std::unordered_set<DrawableID> dusted;
+ const Volume *falls[MaxVolumes];
+ unsigned fallCount = 0;
+ for (const Volume &volume : volumes)
+ if (volume.live && volume.kind == Structure && !volume.standing
+ && now - volume.born <= (int)(DebrisDustSeconds * LOGICFRAMES_PER_SECOND))
+ falls[fallCount++] = &volume;
+ if (!fallCount) {
+ if (dusted.size() > 4096) dusted.clear();
+ return;
+ }
+ const ParticleSystemTemplate *trail = TheParticleSystemManager->findTemplate("ReforgedStructureDebrisDust");
+ if (!trail) return;
+ for (Drawable *drawable = TheGameClient->firstDrawable(); drawable; drawable = drawable->getNextDrawable()) {
+ // (not a tank's plates thrown beside a fall: they carry ReforgedDebrisTrail, a tank is no building)
+ if (!drawable->getTemplate() || drawable->getTemplate()->getName() != "GenericDebris" || dusted.count(drawable->getID())
+ || drawable->getFullyObscuredByShroud() || hullAt(*drawable->getPosition(), false)) continue;
+ const Coord3D *at = drawable->getPosition();
+ for (unsigned f = 0; f < fallCount; ++f) {
+ const Volume &volume = *falls[f];
+ const float dx = at->x - (volume.origin[0] + (volume.blast[0] + 0.5f) * volume.cell);
+ const float dy = at->y - (volume.origin[1] + (volume.blast[1] + 0.5f) * volume.cell);
+ if (dx * dx + dy * dy > joinRadius(volume) * joinRadius(volume)) continue;
+ dusted.insert(drawable->getID());
+ if (ParticleSystem *system = TheParticleSystemManager->createParticleSystem(trail)) system->attachToDrawable(drawable);
+ static unsigned dustLogged = 0;
+ if (dustLogged++ < 4) DEBUG_LOG(("VOLSMOKE: frame %d, a dust trail on a fallen building's debris\n", now));
+ break;
+ }
+ }
+}
+
void Gather()
{
if (!requested() || !TheGameLogic || TheGlobalData->m_classicGraphics || LogicThread::isInsideWindow()) return;
@@ -4750,6 +4804,7 @@ void Gather()
system->setPosition(&at);
pendingSparks.clear();
}
+ attachDebrisDust(now);
ownedHits.erase(std::remove_if(ownedHits.begin(), ownedHits.end(), [now](const OwnedHit &hit) { return hit.frame < now - 8; }),
ownedHits.end());
// A shell striking armour: one dense burst of sparks out of the point where it struck, in a cone